Bug 953425 - Part c: Use DOMFileRequest in LockedFile; r=janv

This commit is contained in:
Ms2ger 2014-02-09 09:04:37 +01:00
parent 71e5a13f9d
commit bd2713204c
2 changed files with 10 additions and 15 deletions

View File

@ -420,11 +420,11 @@ LockedFile::GetOrCreateStream(nsISupports** aStream)
return NS_OK;
}
already_AddRefed<FileRequest>
already_AddRefed<DOMFileRequest>
LockedFile::GenerateFileRequest()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return FileRequest::Create(GetOwner(), this, true);
return FileRequest::Create(GetOwner(), this, true).downcast<DOMFileRequest>();
}
bool
@ -556,8 +556,7 @@ LockedFile::GetMetadata(JS::Handle<JS::Value> aParameters,
return NS_ERROR_TYPE_ERR;
}
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
NS_ENSURE_TRUE(fileRequest, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<MetadataHelper> helper =
new MetadataHelper(this, fileRequest, params);
@ -594,8 +593,7 @@ LockedFile::ReadAsArrayBuffer(uint64_t aSize,
return NS_OK;
}
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
NS_ENSURE_TRUE(fileRequest, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<ReadHelper> helper =
new ReadHelper(this, fileRequest, mLocation, aSize);
@ -637,8 +635,7 @@ LockedFile::ReadAsText(uint64_t aSize,
return NS_OK;
}
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
NS_ENSURE_TRUE(fileRequest, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<ReadTextHelper> helper =
new ReadTextHelper(this, fileRequest, mLocation, aSize, aEncoding);
@ -709,8 +706,7 @@ LockedFile::Truncate(uint64_t aSize,
return NS_OK;
}
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
NS_ENSURE_TRUE(fileRequest, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<TruncateHelper> helper =
new TruncateHelper(this, fileRequest, location);
@ -745,8 +741,7 @@ LockedFile::Flush(nsISupports** _retval)
return NS_OK;
}
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
NS_ENSURE_TRUE(fileRequest, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<FlushHelper> helper = new FlushHelper(this, fileRequest);
@ -868,8 +863,7 @@ LockedFile::WriteOrAppend(JS::Handle<JS::Value> aValue,
return NS_OK;
}
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
NS_ENSURE_TRUE(fileRequest, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
uint64_t location = aAppend ? UINT64_MAX : mLocation;

View File

@ -19,6 +19,7 @@ class nsIInputStream;
BEGIN_FILE_NAMESPACE
class DOMFileRequest;
class FileHandle;
class FileRequest;
class MetadataHelper;
@ -97,7 +98,7 @@ private:
void
OnRequestFinished();
inline already_AddRefed<FileRequest>
inline already_AddRefed<DOMFileRequest>
GenerateFileRequest();
nsresult