mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1186750 part 11 - Convert all usage of Dispatch/NS_DispatchToMainThread in dom/devicestorage to pass in either already_AddRefed or raw pointer. r=dhylands
--HG-- extra : source : a3cc7c40096ea3fadb0971e0c7077ffcbfc56264
This commit is contained in:
parent
23ce331270
commit
21f5537d6f
@ -140,9 +140,8 @@ DeviceStorageRequestParent::Dispatch()
|
||||
|
||||
RefPtr<DeviceStorageFile> dsf =
|
||||
new DeviceStorageFile(p.type(), p.storageName());
|
||||
RefPtr<PostFormatResultEvent> r
|
||||
= new PostFormatResultEvent(this, dsf.forget());
|
||||
DebugOnly<nsresult> rv = NS_DispatchToMainThread(r);
|
||||
DebugOnly<nsresult> rv = NS_DispatchToMainThread(
|
||||
new PostFormatResultEvent(this, dsf.forget()));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
return;
|
||||
}
|
||||
@ -153,9 +152,8 @@ DeviceStorageRequestParent::Dispatch()
|
||||
|
||||
RefPtr<DeviceStorageFile> dsf =
|
||||
new DeviceStorageFile(p.type(), p.storageName());
|
||||
RefPtr<PostMountResultEvent> r
|
||||
= new PostMountResultEvent(this, dsf.forget());
|
||||
DebugOnly<nsresult> rv = NS_DispatchToMainThread(r);
|
||||
DebugOnly<nsresult> rv = NS_DispatchToMainThread(
|
||||
new PostMountResultEvent(this, dsf.forget()));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
return;
|
||||
}
|
||||
@ -166,9 +164,8 @@ DeviceStorageRequestParent::Dispatch()
|
||||
|
||||
RefPtr<DeviceStorageFile> dsf =
|
||||
new DeviceStorageFile(p.type(), p.storageName());
|
||||
RefPtr<PostUnmountResultEvent> r
|
||||
= new PostUnmountResultEvent(this, dsf.forget());
|
||||
DebugOnly<nsresult> rv = NS_DispatchToMainThread(r);
|
||||
DebugOnly<nsresult> rv = NS_DispatchToMainThread(
|
||||
new PostUnmountResultEvent(this, dsf.forget()));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
return;
|
||||
}
|
||||
@ -471,19 +468,18 @@ DeviceStorageRequestParent::CreateFdEvent::CancelableRun()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
|
||||
if (!mFile->mFile) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN));
|
||||
}
|
||||
bool check = false;
|
||||
mFile->mFile->Exists(&check);
|
||||
if (check) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
FileDescriptor fileDescriptor;
|
||||
nsresult rv = mFile->CreateFileDescriptor(fileDescriptor);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -495,7 +491,7 @@ DeviceStorageRequestParent::CreateFdEvent::CancelableRun()
|
||||
r = new PostFileDescriptorResultEvent(mParent, fileDescriptor);
|
||||
}
|
||||
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(r.forget());
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -503,11 +499,9 @@ DeviceStorageRequestParent::WriteFileEvent::CancelableRun()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
|
||||
if (!mInputStream || !mFile->mFile) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN));
|
||||
}
|
||||
|
||||
bool check = false;
|
||||
@ -516,21 +510,22 @@ DeviceStorageRequestParent::WriteFileEvent::CancelableRun()
|
||||
|
||||
if (mRequestType == DEVICE_STORAGE_REQUEST_CREATE) {
|
||||
if (check) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS));
|
||||
}
|
||||
rv = mFile->Write(mInputStream);
|
||||
} else if (mRequestType == DEVICE_STORAGE_REQUEST_APPEND) {
|
||||
if (!check) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST));
|
||||
}
|
||||
rv = mFile->Append(mInputStream);
|
||||
} else {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
if (NS_FAILED(rv)) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
}
|
||||
@ -538,7 +533,7 @@ DeviceStorageRequestParent::WriteFileEvent::CancelableRun()
|
||||
r = new PostPathResultEvent(mParent, mFile->mPath);
|
||||
}
|
||||
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(r.forget());
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -548,12 +543,11 @@ DeviceStorageRequestParent::DeleteFileEvent::CancelableRun()
|
||||
|
||||
mFile->Remove();
|
||||
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
|
||||
if (!mFile->mFile) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN));
|
||||
}
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
bool check = false;
|
||||
mFile->mFile->Exists(&check);
|
||||
if (check) {
|
||||
@ -563,7 +557,7 @@ DeviceStorageRequestParent::DeleteFileEvent::CancelableRun()
|
||||
r = new PostPathResultEvent(mParent, mFile->mPath);
|
||||
}
|
||||
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(r.forget());
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -576,9 +570,8 @@ DeviceStorageRequestParent::FreeSpaceFileEvent::CancelableRun()
|
||||
mFile->GetStorageFreeSpace(&freeSpace);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
r = new PostFreeSpaceResultEvent(mParent, static_cast<uint64_t>(freeSpace));
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostFreeSpaceResultEvent(mParent, static_cast<uint64_t>(freeSpace)));
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -602,7 +595,7 @@ DeviceStorageRequestParent::UsedSpaceFileEvent::CancelableRun()
|
||||
} else {
|
||||
r = new PostUsedSpaceResultEvent(mParent, mFile->mStorageType, totalUsage);
|
||||
}
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(r.forget());
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::ReadFileEvent::
|
||||
@ -625,38 +618,36 @@ DeviceStorageRequestParent::ReadFileEvent::CancelableRun()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
|
||||
if (!mFile->mFile) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN));
|
||||
}
|
||||
bool check = false;
|
||||
mFile->mFile->Exists(&check);
|
||||
|
||||
if (!check) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST));
|
||||
}
|
||||
|
||||
int64_t fileSize;
|
||||
nsresult rv = mFile->mFile->GetFileSize(&fileSize);
|
||||
if (NS_FAILED(rv)) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN));
|
||||
}
|
||||
|
||||
PRTime modDate;
|
||||
rv = mFile->mFile->GetLastModifiedTime(&modDate);
|
||||
if (NS_FAILED(rv)) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN));
|
||||
}
|
||||
|
||||
r = new PostBlobSuccessEvent(mParent, mFile.forget(),
|
||||
static_cast<uint64_t>(fileSize),
|
||||
mMimeType, modDate);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostBlobSuccessEvent(mParent, mFile.forget(),
|
||||
static_cast<uint64_t>(fileSize),
|
||||
mMimeType, modDate));
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -664,13 +655,12 @@ DeviceStorageRequestParent::EnumerateFileEvent::CancelableRun()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
if (mFile->mFile) {
|
||||
bool check = false;
|
||||
mFile->mFile->Exists(&check);
|
||||
if (!check) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST));
|
||||
}
|
||||
}
|
||||
|
||||
@ -685,9 +675,9 @@ DeviceStorageRequestParent::EnumerateFileEvent::CancelableRun()
|
||||
values.AppendElement(dsvf);
|
||||
}
|
||||
|
||||
r = new PostEnumerationSuccessEvent(mParent, mFile->mStorageType,
|
||||
mFile->mRootDir, values);
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(
|
||||
new PostEnumerationSuccessEvent(mParent, mFile->mStorageType,
|
||||
mFile->mRootDir, values));
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -831,7 +831,7 @@ DeviceStorageStatics::ListenerWrapper::OnFileWatcherUpdate(const nsCString& aDat
|
||||
listener->OnFileWatcherUpdate(data, file);
|
||||
}
|
||||
});
|
||||
mOwningThread->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
mOwningThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -844,7 +844,7 @@ DeviceStorageStatics::ListenerWrapper::OnDiskSpaceWatcher(bool aLowDiskSpace)
|
||||
listener->OnDiskSpaceWatcher(aLowDiskSpace);
|
||||
}
|
||||
});
|
||||
mOwningThread->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
mOwningThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -857,7 +857,7 @@ DeviceStorageStatics::ListenerWrapper::OnWritableNameChanged()
|
||||
listener->OnWritableNameChanged();
|
||||
}
|
||||
});
|
||||
mOwningThread->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
mOwningThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
@ -872,7 +872,7 @@ DeviceStorageStatics::ListenerWrapper::OnVolumeStateChanged(nsIVolume* aVolume)
|
||||
listener->OnVolumeStateChanged(volume);
|
||||
}
|
||||
});
|
||||
mOwningThread->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
mOwningThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -836,8 +836,7 @@ DeviceStorageFile::Write(nsIInputStream* aInputStream)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> iocomplete = new IOEventComplete(this, "created");
|
||||
rv = NS_DispatchToMainThread(iocomplete);
|
||||
rv = NS_DispatchToMainThread(new IOEventComplete(this, "created"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -864,8 +863,7 @@ DeviceStorageFile::Write(InfallibleTArray<uint8_t>& aBits)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> iocomplete = new IOEventComplete(this, "created");
|
||||
rv = NS_DispatchToMainThread(iocomplete);
|
||||
rv = NS_DispatchToMainThread(new IOEventComplete(this, "created"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -881,8 +879,7 @@ DeviceStorageFile::Write(InfallibleTArray<uint8_t>& aBits)
|
||||
outputStream->Write((char*) aBits.Elements(), aBits.Length(), &wrote);
|
||||
outputStream->Close();
|
||||
|
||||
iocomplete = new IOEventComplete(this, "modified");
|
||||
rv = NS_DispatchToMainThread(iocomplete);
|
||||
rv = NS_DispatchToMainThread(new IOEventComplete(this, "modified"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -935,8 +932,7 @@ DeviceStorageFile::Append(nsIInputStream* aInputStream, nsIOutputStream* aOutput
|
||||
bufSize -= wrote;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> iocomplete = new IOEventComplete(this, "modified");
|
||||
rv = NS_DispatchToMainThread(iocomplete);
|
||||
rv = NS_DispatchToMainThread(new IOEventComplete(this, "modified"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -973,8 +969,7 @@ DeviceStorageFile::Remove()
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> iocomplete = new IOEventComplete(this, "deleted");
|
||||
return NS_DispatchToMainThread(iocomplete);
|
||||
return NS_DispatchToMainThread(new IOEventComplete(this, "deleted"));
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1597,7 +1592,7 @@ DeviceStorageRequest::Allow()
|
||||
{
|
||||
self->Allow();
|
||||
});
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(r.forget());
|
||||
}
|
||||
|
||||
nsresult rv = AllowInternal();
|
||||
@ -1686,7 +1681,8 @@ DeviceStorageRequest::AllowInternal()
|
||||
nsCOMPtr<nsIEventTarget> target
|
||||
= do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
MOZ_ASSERT(target);
|
||||
return target->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||
nsCOMPtr<nsIRunnable> self = this;
|
||||
return target->Dispatch(self.forget(), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
DS_LOG_INFO("run %u", mId);
|
||||
@ -1706,7 +1702,7 @@ DeviceStorageRequest::SendToParentProcess()
|
||||
self->Reject(POST_ERROR_EVENT_UNKNOWN);
|
||||
}
|
||||
});
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(r.forget());
|
||||
}
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -1766,7 +1762,7 @@ DeviceStorageCursorRequest::SendContinueToParentProcess()
|
||||
{
|
||||
self->SendContinueToParentProcess();
|
||||
});
|
||||
return NS_DispatchToMainThread(r);
|
||||
return NS_DispatchToMainThread(r.forget());
|
||||
}
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -1793,7 +1789,7 @@ DeviceStorageCursorRequest::Continue()
|
||||
{
|
||||
self->Continue();
|
||||
});
|
||||
nsresult rv = NS_DispatchToMainThread(r);
|
||||
nsresult rv = NS_DispatchToMainThread(r.forget());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return Reject(POST_ERROR_EVENT_UNKNOWN);
|
||||
}
|
||||
|
@ -130,8 +130,8 @@ public:
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mIOThread);
|
||||
|
||||
RefPtr<InvalidateRunnable> r = new InvalidateRunnable(this, aStorageName);
|
||||
mIOThread->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
mIOThread->Dispatch(new InvalidateRunnable(this, aStorageName),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
void Dispatch(already_AddRefed<nsIRunnable>&& aRunnable)
|
||||
|
Loading…
Reference in New Issue
Block a user