Bug 514280 Only use nsCOMPtr for interfaces r=bsmedberg

This commit is contained in:
Neil Rashbrook 2014-04-03 23:06:26 +01:00
parent 60238a9741
commit a8a5decf6f
14 changed files with 38 additions and 40 deletions

View File

@ -797,7 +797,7 @@ nsDOMTemporaryFileBlob::CreateSlice(uint64_t aStart, uint64_t aLength,
NS_IMETHODIMP NS_IMETHODIMP
nsDOMTemporaryFileBlob::GetInternalStream(nsIInputStream **aStream) nsDOMTemporaryFileBlob::GetInternalStream(nsIInputStream **aStream)
{ {
nsCOMPtr<nsTemporaryFileInputStream> stream = nsCOMPtr<nsIInputStream> stream =
new nsTemporaryFileInputStream(mFileDescOwner, mStartPos, mStartPos + mLength); new nsTemporaryFileInputStream(mFileDescOwner, mStartPos, mStartPos + mLength);
stream.forget(aStream); stream.forget(aStream);
return NS_OK; return NS_OK;

View File

@ -61,7 +61,7 @@ static bool GetIntPref(const char* aPref, int32_t* aResult)
// can only be called on the main thread. Post a runnable and wait. // can only be called on the main thread. Post a runnable and wait.
NS_ENSURE_TRUE(aPref, false); NS_ENSURE_TRUE(aPref, false);
NS_ENSURE_TRUE(aResult, false); NS_ENSURE_TRUE(aResult, false);
nsCOMPtr<GetIntPrefEvent> event = new GetIntPrefEvent(aPref, aResult); nsCOMPtr<nsIRunnable> event = new GetIntPrefEvent(aPref, aResult);
return NS_SUCCEEDED(NS_DispatchToMainThread(event, NS_DISPATCH_SYNC)); return NS_SUCCEEDED(NS_DispatchToMainThread(event, NS_DISPATCH_SYNC));
} }

View File

@ -929,7 +929,7 @@ nsDocShell::Init()
// We want to hold a strong ref to the loadgroup, so it better hold a weak // We want to hold a strong ref to the loadgroup, so it better hold a weak
// ref to us... use an InterfaceRequestorProxy to do this. // ref to us... use an InterfaceRequestorProxy to do this.
nsCOMPtr<InterfaceRequestorProxy> proxy = nsCOMPtr<nsIInterfaceRequestor> proxy =
new InterfaceRequestorProxy(static_cast<nsIInterfaceRequestor*> new InterfaceRequestorProxy(static_cast<nsIInterfaceRequestor*>
(this)); (this));
NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY);

View File

@ -126,7 +126,7 @@ public:
return NS_OK; return NS_OK;
} }
nsRefPtr<AudioChannelAgent> mAgent; nsCOMPtr<nsIAudioChannelAgent> mAgent;
AudioChannelType mType; AudioChannelType mType;
bool mWaitCallback; bool mWaitCallback;
bool mRegistered; bool mRegistered;

View File

@ -550,14 +550,13 @@ DeviceStorageRequestParent::CreateFdEvent::CancelableRun()
{ {
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread());
nsRefPtr<nsRunnable> r; nsCOMPtr<nsIRunnable> r;
bool check = false; bool check = false;
mFile->mFile->Exists(&check); mFile->mFile->Exists(&check);
if (check) { if (check) {
nsCOMPtr<PostErrorEvent> event r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS);
= new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS); return NS_DispatchToMainThread(r);
return NS_DispatchToMainThread(event);
} }
FileDescriptor fileDescriptor; FileDescriptor fileDescriptor;
@ -593,7 +592,7 @@ DeviceStorageRequestParent::WriteFileEvent::CancelableRun()
{ {
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread());
nsRefPtr<nsRunnable> r; nsCOMPtr<nsIRunnable> r;
if (!mInputStream) { if (!mInputStream) {
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN); r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
@ -603,9 +602,8 @@ DeviceStorageRequestParent::WriteFileEvent::CancelableRun()
bool check = false; bool check = false;
mFile->mFile->Exists(&check); mFile->mFile->Exists(&check);
if (check) { if (check) {
nsCOMPtr<PostErrorEvent> event r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS);
= new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS); return NS_DispatchToMainThread(r);
return NS_DispatchToMainThread(event);
} }
nsresult rv = mFile->Write(mInputStream); nsresult rv = mFile->Write(mInputStream);
@ -638,7 +636,7 @@ DeviceStorageRequestParent::DeleteFileEvent::CancelableRun()
mFile->Remove(); mFile->Remove();
nsRefPtr<nsRunnable> r; nsCOMPtr<nsIRunnable> r;
bool check = false; bool check = false;
mFile->mFile->Exists(&check); mFile->mFile->Exists(&check);

View File

@ -1054,7 +1054,7 @@ DeviceStorageFile::Write(nsIInputStream* aInputStream)
return rv; return rv;
} }
nsCOMPtr<IOEventComplete> iocomplete = new IOEventComplete(this, "created"); nsCOMPtr<nsIRunnable> iocomplete = new IOEventComplete(this, "created");
rv = NS_DispatchToMainThread(iocomplete); rv = NS_DispatchToMainThread(iocomplete);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
@ -1114,7 +1114,7 @@ DeviceStorageFile::Write(InfallibleTArray<uint8_t>& aBits)
return rv; return rv;
} }
nsCOMPtr<IOEventComplete> iocomplete = new IOEventComplete(this, "created"); nsCOMPtr<nsIRunnable> iocomplete = new IOEventComplete(this, "created");
rv = NS_DispatchToMainThread(iocomplete); rv = NS_DispatchToMainThread(iocomplete);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
@ -1167,7 +1167,7 @@ DeviceStorageFile::Remove()
return rv; return rv;
} }
nsCOMPtr<IOEventComplete> iocomplete = new IOEventComplete(this, "deleted"); nsCOMPtr<nsIRunnable> iocomplete = new IOEventComplete(this, "deleted");
return NS_DispatchToMainThread(iocomplete); return NS_DispatchToMainThread(iocomplete);
} }
@ -1914,7 +1914,7 @@ public:
bool check; bool check;
mFile->mFile->IsDirectory(&check); mFile->mFile->IsDirectory(&check);
if (!check) { if (!check) {
nsCOMPtr<PostErrorEvent> event = nsCOMPtr<nsIRunnable> event =
new PostErrorEvent(mRequest.forget(), new PostErrorEvent(mRequest.forget(),
POST_ERROR_EVENT_FILE_NOT_ENUMERABLE); POST_ERROR_EVENT_FILE_NOT_ENUMERABLE);
return NS_DispatchToMainThread(event); return NS_DispatchToMainThread(event);
@ -1925,7 +1925,7 @@ public:
= static_cast<nsDOMDeviceStorageCursor*>(mRequest.get()); = static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());
mFile->CollectFiles(cursor->mFiles, cursor->mSince); mFile->CollectFiles(cursor->mFiles, cursor->mSince);
nsCOMPtr<ContinueCursorEvent> event nsRefPtr<ContinueCursorEvent> event
= new ContinueCursorEvent(mRequest.forget()); = new ContinueCursorEvent(mRequest.forget());
event->Continue(); event->Continue();
@ -2006,7 +2006,7 @@ nsDOMDeviceStorageCursor::GetElement(nsIDOMElement * *aRequestingElement)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMDeviceStorageCursor::Cancel() nsDOMDeviceStorageCursor::Cancel()
{ {
nsCOMPtr<PostErrorEvent> event nsCOMPtr<nsIRunnable> event
= new PostErrorEvent(this, POST_ERROR_EVENT_PERMISSION_DENIED); = new PostErrorEvent(this, POST_ERROR_EVENT_PERMISSION_DENIED);
return NS_DispatchToMainThread(event); return NS_DispatchToMainThread(event);
} }
@ -2038,7 +2038,7 @@ nsDOMDeviceStorageCursor::Allow(JS::HandleValue aChoices)
= do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
MOZ_ASSERT(target); MOZ_ASSERT(target);
nsCOMPtr<InitCursorEvent> event = new InitCursorEvent(this, mFile); nsCOMPtr<nsIRunnable> event = new InitCursorEvent(this, mFile);
target->Dispatch(event, NS_DISPATCH_NORMAL); target->Dispatch(event, NS_DISPATCH_NORMAL);
return NS_OK; return NS_OK;
} }
@ -2058,7 +2058,7 @@ nsDOMDeviceStorageCursor::Continue(ErrorResult& aRv)
mDone = false; mDone = false;
} }
nsCOMPtr<ContinueCursorEvent> event = new ContinueCursorEvent(this); nsRefPtr<ContinueCursorEvent> event = new ContinueCursorEvent(this);
event->Continue(); event->Continue();
mOkToCallContinue = false; mOkToCallContinue = false;
@ -2346,7 +2346,7 @@ public:
bool check = false; bool check = false;
dsFile->mFile->Exists(&check); dsFile->mFile->Exists(&check);
if (check) { if (check) {
nsCOMPtr<PostErrorEvent> event = nsCOMPtr<nsIRunnable> event =
new PostErrorEvent(mRequest.forget(), POST_ERROR_EVENT_FILE_EXISTS); new PostErrorEvent(mRequest.forget(), POST_ERROR_EVENT_FILE_EXISTS);
return NS_DispatchToMainThread(event); return NS_DispatchToMainThread(event);
} }
@ -2356,12 +2356,12 @@ public:
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
dsFile->mFile->Remove(false); dsFile->mFile->Remove(false);
nsCOMPtr<PostErrorEvent> event = nsCOMPtr<nsIRunnable> event =
new PostErrorEvent(mRequest.forget(), POST_ERROR_EVENT_UNKNOWN); new PostErrorEvent(mRequest.forget(), POST_ERROR_EVENT_UNKNOWN);
return NS_DispatchToMainThread(event); return NS_DispatchToMainThread(event);
} }
nsCOMPtr<PostResultEvent> event = nsCOMPtr<nsIRunnable> event =
new PostResultEvent(mRequest.forget(), fullPath); new PostResultEvent(mRequest.forget(), fullPath);
return NS_DispatchToMainThread(event); return NS_DispatchToMainThread(event);
} }
@ -2397,7 +2397,7 @@ public:
bool check = false; bool check = false;
mFile->mFile->Exists(&check); mFile->mFile->Exists(&check);
if (check) { if (check) {
nsCOMPtr<PostErrorEvent> event = nsCOMPtr<nsIRunnable> event =
new PostErrorEvent(mRequest.forget(), POST_ERROR_EVENT_FILE_EXISTS); new PostErrorEvent(mRequest.forget(), POST_ERROR_EVENT_FILE_EXISTS);
return NS_DispatchToMainThread(event); return NS_DispatchToMainThread(event);
} }
@ -2407,14 +2407,14 @@ public:
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
mFile->mFile->Remove(false); mFile->mFile->Remove(false);
nsCOMPtr<PostErrorEvent> event = nsCOMPtr<nsIRunnable> event =
new PostErrorEvent(mRequest.forget(), POST_ERROR_EVENT_UNKNOWN); new PostErrorEvent(mRequest.forget(), POST_ERROR_EVENT_UNKNOWN);
return NS_DispatchToMainThread(event); return NS_DispatchToMainThread(event);
} }
nsString fullPath; nsString fullPath;
mFile->GetFullPath(fullPath); mFile->GetFullPath(fullPath);
nsCOMPtr<PostResultEvent> event = nsCOMPtr<nsIRunnable> event =
new PostResultEvent(mRequest.forget(), fullPath); new PostResultEvent(mRequest.forget(), fullPath);
return NS_DispatchToMainThread(event); return NS_DispatchToMainThread(event);
} }
@ -2444,7 +2444,7 @@ public:
{ {
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread());
nsRefPtr<nsRunnable> r; nsCOMPtr<nsIRunnable> r;
if (!mFile->mEditable) { if (!mFile->mEditable) {
bool check = false; bool check = false;
mFile->mFile->Exists(&check); mFile->mFile->Exists(&check);
@ -2491,7 +2491,7 @@ public:
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread());
mFile->Remove(); mFile->Remove();
nsRefPtr<nsRunnable> r; nsCOMPtr<nsIRunnable> r;
bool check = false; bool check = false;
mFile->mFile->Exists(&check); mFile->mFile->Exists(&check);
if (check) { if (check) {
@ -2749,7 +2749,7 @@ public:
NS_IMETHOD Cancel() NS_IMETHOD Cancel()
{ {
nsCOMPtr<PostErrorEvent> event nsCOMPtr<nsIRunnable> event
= new PostErrorEvent(mRequest.forget(), = new PostErrorEvent(mRequest.forget(),
POST_ERROR_EVENT_PERMISSION_DENIED); POST_ERROR_EVENT_PERMISSION_DENIED);
return NS_DispatchToMainThread(event); return NS_DispatchToMainThread(event);

View File

@ -204,7 +204,7 @@ MediaPermissionRequest::GetTypes(nsIArray** aTypes)
if (mAudio) { if (mAudio) {
nsTArray<nsString> audioDeviceNames; nsTArray<nsString> audioDeviceNames;
CreateDeviceNameList(mAudioDevices, audioDeviceNames); CreateDeviceNameList(mAudioDevices, audioDeviceNames);
nsCOMPtr<ContentPermissionType> AudioType = nsCOMPtr<nsISupports> AudioType =
new ContentPermissionType(NS_LITERAL_CSTRING(AUDIO_PERMISSION_NAME), new ContentPermissionType(NS_LITERAL_CSTRING(AUDIO_PERMISSION_NAME),
NS_LITERAL_CSTRING("unused"), NS_LITERAL_CSTRING("unused"),
audioDeviceNames); audioDeviceNames);
@ -213,7 +213,7 @@ MediaPermissionRequest::GetTypes(nsIArray** aTypes)
if (mVideo) { if (mVideo) {
nsTArray<nsString> videoDeviceNames; nsTArray<nsString> videoDeviceNames;
CreateDeviceNameList(mVideoDevices, videoDeviceNames); CreateDeviceNameList(mVideoDevices, videoDeviceNames);
nsCOMPtr<ContentPermissionType> VideoType = nsCOMPtr<nsISupports> VideoType =
new ContentPermissionType(NS_LITERAL_CSTRING(VIDEO_PERMISSION_NAME), new ContentPermissionType(NS_LITERAL_CSTRING(VIDEO_PERMISSION_NAME),
NS_LITERAL_CSTRING("unused"), NS_LITERAL_CSTRING("unused"),
videoDeviceNames); videoDeviceNames);

View File

@ -63,7 +63,7 @@ protected:
private: private:
nsAutoPtr<mozilla::hal::SwitchObserver> mObserver; nsAutoPtr<mozilla::hal::SwitchObserver> mObserver;
nsCOMPtr<AudioChannelAgent> mPhoneAudioAgent; nsCOMPtr<nsIAudioChannelAgent> mPhoneAudioAgent;
#ifdef MOZ_B2G_RIL #ifdef MOZ_B2G_RIL
bool mMuteCallToRIL; bool mMuteCallToRIL;
// mIsMicMuted is only used for toggling mute call to RIL. // mIsMicMuted is only used for toggling mute call to RIL.

View File

@ -3565,7 +3565,7 @@ RasterImage::DecodeDoneWorker::NotifyFinishedSomeDecoding(RasterImage* image, De
{ {
image->mDecodingMonitor.AssertCurrentThreadIn(); image->mDecodingMonitor.AssertCurrentThreadIn();
nsCOMPtr<DecodeDoneWorker> worker = new DecodeDoneWorker(image, request); nsCOMPtr<nsIRunnable> worker = new DecodeDoneWorker(image, request);
NS_DispatchToMainThread(worker); NS_DispatchToMainThread(worker);
} }
@ -3588,7 +3588,7 @@ RasterImage::FrameNeededWorker::FrameNeededWorker(RasterImage* image)
void void
RasterImage::FrameNeededWorker::GetNewFrame(RasterImage* image) RasterImage::FrameNeededWorker::GetNewFrame(RasterImage* image)
{ {
nsCOMPtr<FrameNeededWorker> worker = new FrameNeededWorker(image); nsCOMPtr<nsIRunnable> worker = new FrameNeededWorker(image);
NS_DispatchToMainThread(worker); NS_DispatchToMainThread(worker);
} }

View File

@ -451,7 +451,7 @@ Seer::Init()
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
#ifdef MOZ_NUWA_PROCESS #ifdef MOZ_NUWA_PROCESS
nsCOMPtr<NuwaMarkSeerThreadRunner> runner = new NuwaMarkSeerThreadRunner(); nsCOMPtr<nsIRunnable> runner = new NuwaMarkSeerThreadRunner();
mIOThread->Dispatch(runner, NS_DISPATCH_NORMAL); mIOThread->Dispatch(runner, NS_DISPATCH_NORMAL);
#endif #endif

View File

@ -707,7 +707,7 @@ nsCookieService::GetSingleton()
nsCookieService::AppClearDataObserverInit() nsCookieService::AppClearDataObserverInit()
{ {
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1"); nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<AppClearDataObserver> obs = new AppClearDataObserver(); nsCOMPtr<nsIObserver> obs = new AppClearDataObserver();
observerService->AddObserver(obs, TOPIC_WEB_APP_CLEAR_DATA, observerService->AddObserver(obs, TOPIC_WEB_APP_CLEAR_DATA,
/* holdsWeak= */ false); /* holdsWeak= */ false);
} }

View File

@ -139,7 +139,7 @@ private:
const KeyType mKeyType; // in const KeyType mKeyType; // in
nsMainThreadPtrHandle<nsIIdentityKeyGenCallback> mCallback; // in nsMainThreadPtrHandle<nsIIdentityKeyGenCallback> mCallback; // in
nsresult mRv; // out nsresult mRv; // out
nsCOMPtr<KeyPair> mKeyPair; // out nsCOMPtr<nsIIdentityKeyPair> mKeyPair; // out
KeyGenRunnable(const KeyGenRunnable &) MOZ_DELETE; KeyGenRunnable(const KeyGenRunnable &) MOZ_DELETE;
void operator=(const KeyGenRunnable &) MOZ_DELETE; void operator=(const KeyGenRunnable &) MOZ_DELETE;

View File

@ -683,7 +683,7 @@ nsresult AsyncFaviconDataReady::OnFaviconDataNotAvailable(void)
rv = NS_NewChannel(getter_AddRefs(channel), mozIconURI); rv = NS_NewChannel(getter_AddRefs(channel), mozIconURI);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<myDownloadObserver> downloadObserver = new myDownloadObserver; nsCOMPtr<nsIDownloadObserver> downloadObserver = new myDownloadObserver;
nsCOMPtr<nsIStreamListener> listener; nsCOMPtr<nsIStreamListener> listener;
rv = NS_NewDownloader(getter_AddRefs(listener), downloadObserver, icoFile); rv = NS_NewDownloader(getter_AddRefs(listener), downloadObserver, icoFile);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View File

@ -256,7 +256,7 @@ protected:
Microsoft::WRL::ComPtr<FrameworkView> mView; Microsoft::WRL::ComPtr<FrameworkView> mView;
nsTransparencyMode mTransparencyMode; nsTransparencyMode mTransparencyMode;
nsIntRegion mInvalidatedRegion; nsIntRegion mInvalidatedRegion;
nsCOMPtr<nsIdleService> mIdleService; nsCOMPtr<nsIIdleServiceInternal> mIdleService;
HWND mWnd; HWND mWnd;
static HWND sICoreHwnd; static HWND sICoreHwnd;
WNDPROC mMetroWndProc; WNDPROC mMetroWndProc;