Bug 953425 - Part d: Add DOMFileRequest::Create(); r=Ms2ger

This commit is contained in:
Jan Varga 2014-02-09 09:04:37 +01:00
parent 058946a78f
commit cbf55c77bc
6 changed files with 23 additions and 15 deletions

View File

@ -16,6 +16,18 @@ DOMFileRequest::DOMFileRequest(nsPIDOMWindow* aWindow)
{
}
// static
already_AddRefed<DOMFileRequest>
DOMFileRequest::Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile)
{
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
nsRefPtr<DOMFileRequest> request = new DOMFileRequest(aOwner);
request->mLockedFile = aLockedFile;
return request.forget();
}
/* virtual */ JSObject*
DOMFileRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{

View File

@ -16,13 +16,17 @@ BEGIN_FILE_NAMESPACE
class DOMFileRequest : public FileRequest
{
public:
DOMFileRequest(nsPIDOMWindow* aWindow);
static already_AddRefed<DOMFileRequest>
Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile);
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
nsIDOMLockedFile* GetLockedFile() const;
IMPL_EVENT_HANDLER(progress)
protected:
DOMFileRequest(nsPIDOMWindow* aWindow);
};
END_FILE_NAMESPACE

View File

@ -149,8 +149,7 @@ FileHandle::GetFile(ErrorResult& aError)
return nullptr;
}
nsRefPtr<FileRequest> request =
FileRequest::Create(GetOwner(), lockedFile, false);
nsRefPtr<FileRequest> request = FileRequest::Create(GetOwner(), lockedFile);
nsRefPtr<MetadataParameters> params = new MetadataParameters(true, false);

View File

@ -30,18 +30,11 @@ FileRequest::~FileRequest()
// static
already_AddRefed<FileRequest>
FileRequest::Create(nsPIDOMWindow* aOwner,
LockedFile* aLockedFile,
bool aIsFileRequest)
FileRequest::Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsRefPtr<FileRequest> request;
if (aIsFileRequest) {
request = new DOMFileRequest(aOwner);
} else {
request = new FileRequest(aOwner);
}
nsRefPtr<FileRequest> request = new FileRequest(aOwner);
request->mLockedFile = aLockedFile;
return request.forget();

View File

@ -24,7 +24,7 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileRequest, DOMRequest)
static already_AddRefed<FileRequest>
Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile, bool aIsFileRequest);
Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile);
// nsIDOMEventTarget
virtual nsresult

View File

@ -22,9 +22,9 @@
#include "xpcpublic.h"
#include "AsyncHelper.h"
#include "DOMFileRequest.h"
#include "FileHandle.h"
#include "FileHelper.h"
#include "FileRequest.h"
#include "FileService.h"
#include "FileStreamWrappers.h"
#include "MemoryStreams.h"
@ -424,7 +424,7 @@ already_AddRefed<DOMFileRequest>
LockedFile::GenerateFileRequest()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return FileRequest::Create(GetOwner(), this, true).downcast<DOMFileRequest>();
return DOMFileRequest::Create(GetOwner(), this);
}
bool