From d3aef9130659df3bf5d922d814899f54e1a1b4c2 Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Fri, 17 Oct 2014 20:47:46 -0400 Subject: [PATCH] Bug 1033885 - rename error to onFailure in code before introducing an actual error object r=jesup --- dom/media/MediaManager.cpp | 170 ++++++++++++++++++------------------- dom/media/MediaManager.h | 20 ++--- 2 files changed, 95 insertions(+), 95 deletions(-) diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 2c40a45d2a69..afcde431c006 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -194,20 +194,20 @@ HostHasPermission(nsIURI &docURI) } ErrorCallbackRunnable::ErrorCallbackRunnable( - nsCOMPtr& aSuccess, - nsCOMPtr& aError, + nsCOMPtr& aOnSuccess, + nsCOMPtr& aOnFailure, const nsAString& aErrorMsg, uint64_t aWindowID) : mErrorMsg(aErrorMsg) , mWindowID(aWindowID) , mManager(MediaManager::GetInstance()) { - mSuccess.swap(aSuccess); - mError.swap(aError); + mOnSuccess.swap(aOnSuccess); + mOnFailure.swap(aOnFailure); } ErrorCallbackRunnable::~ErrorCallbackRunnable() { - MOZ_ASSERT(!mSuccess && !mError); + MOZ_ASSERT(!mOnSuccess && !mOnFailure); } NS_IMETHODIMP @@ -216,15 +216,15 @@ ErrorCallbackRunnable::Run() // Only run if the window is still active. NS_ASSERTION(NS_IsMainThread(), "Only call on main thread"); - nsCOMPtr success = mSuccess.forget(); - nsCOMPtr error = mError.forget(); + nsCOMPtr onSuccess = mOnSuccess.forget(); + nsCOMPtr onFailure = mOnFailure.forget(); if (!(mManager->IsWindowStillActive(mWindowID))) { return NS_OK; } // This is safe since we're on main-thread, and the windowlist can only // be invalidated from the main-thread (see OnNavigation) - error->OnError(mErrorMsg); + onFailure->OnError(mErrorMsg); return NS_OK; } @@ -238,15 +238,15 @@ class SuccessCallbackRunnable : public nsRunnable { public: SuccessCallbackRunnable( - nsCOMPtr& aSuccess, - nsCOMPtr& aError, + nsCOMPtr& aOnSuccess, + nsCOMPtr& aOnFailure, nsIDOMFile* aFile, uint64_t aWindowID) : mFile(aFile) , mWindowID(aWindowID) , mManager(MediaManager::GetInstance()) { - mSuccess.swap(aSuccess); - mError.swap(aError); + mOnSuccess.swap(aOnSuccess); + mOnFailure.swap(aOnFailure); } NS_IMETHOD @@ -255,21 +255,21 @@ public: // Only run if the window is still active. NS_ASSERTION(NS_IsMainThread(), "Only call on main thread"); - nsCOMPtr success = mSuccess.forget(); - nsCOMPtr error = mError.forget(); + nsCOMPtr onSuccess = mOnSuccess.forget(); + nsCOMPtr onFailure = mOnFailure.forget(); if (!(mManager->IsWindowStillActive(mWindowID))) { return NS_OK; } // This is safe since we're on main-thread, and the windowlist can only // be invalidated from the main-thread (see OnNavigation) - success->OnSuccess(mFile); + onSuccess->OnSuccess(mFile); return NS_OK; } private: - nsCOMPtr mSuccess; - nsCOMPtr mError; + nsCOMPtr mOnSuccess; + nsCOMPtr mOnFailure; nsCOMPtr mFile; uint64_t mWindowID; nsRefPtr mManager; // get ref to this when creating the runnable @@ -285,15 +285,15 @@ class DeviceSuccessCallbackRunnable: public nsRunnable public: DeviceSuccessCallbackRunnable( uint64_t aWindowID, - nsCOMPtr& aSuccess, - nsCOMPtr& aError, + nsCOMPtr& aOnSuccess, + nsCOMPtr& aOnFailure, nsTArray>* aDevices) : mDevices(aDevices) , mWindowID(aWindowID) , mManager(MediaManager::GetInstance()) { - mSuccess.swap(aSuccess); - mError.swap(aError); + mOnSuccess.swap(aOnSuccess); + mOnFailure.swap(aOnFailure); } NS_IMETHOD @@ -315,7 +315,7 @@ public: // We should in the future return an empty array, and dynamically add // devices to the dropdowns if things are hotplugged while the // requester is up. - mError->OnError(NS_LITERAL_STRING("NO_DEVICES_FOUND")); + mOnFailure->OnError(NS_LITERAL_STRING("NO_DEVICES_FOUND")); return NS_OK; } @@ -331,13 +331,13 @@ public: static_cast(tmp.Elements()) )); - mSuccess->OnSuccess(devices); + mOnSuccess->OnSuccess(devices); return NS_OK; } private: - nsCOMPtr mSuccess; - nsCOMPtr mError; + nsCOMPtr mOnSuccess; + nsCOMPtr mOnFailure; nsAutoPtr>> mDevices; uint64_t mWindowID; nsRefPtr mManager; @@ -723,8 +723,8 @@ class GetUserMediaStreamRunnable : public nsRunnable { public: GetUserMediaStreamRunnable( - nsCOMPtr& aSuccess, - nsCOMPtr& aError, + nsCOMPtr& aOnSuccess, + nsCOMPtr& aOnFailure, uint64_t aWindowID, GetUserMediaCallbackMediaStreamListener* aListener, MediaEngineSource* aAudioSource, @@ -737,8 +737,8 @@ public: , mPeerIdentity(aPeerIdentity) , mManager(MediaManager::GetInstance()) { - mSuccess.swap(aSuccess); - mError.swap(aError); + mOnSuccess.swap(aOnSuccess); + mOnFailure.swap(aOnFailure); } ~GetUserMediaStreamRunnable() {} @@ -750,7 +750,7 @@ public: nsIDOMGetUserMediaSuccessCallback* aSuccess, uint64_t aWindowID, DOMMediaStream* aStream) - : mWindowID(aWindowID), mSuccess(aSuccess), mManager(aManager), + : mWindowID(aWindowID), mOnSuccess(aSuccess), mManager(aManager), mStream(aStream) {} virtual void NotifyTracksAvailable(DOMMediaStream* aStream) MOZ_OVERRIDE { @@ -766,10 +766,10 @@ public: // This is safe since we're on main-thread, and the windowlist can only // be invalidated from the main-thread (see OnNavigation) LOG(("Returning success for getUserMedia()")); - mSuccess->OnSuccess(aStream); + mOnSuccess->OnSuccess(aStream); } uint64_t mWindowID; - nsCOMPtr mSuccess; + nsCOMPtr mOnSuccess; nsRefPtr mManager; // Keep the DOMMediaStream alive until the NotifyTracksAvailable callback // has fired, otherwise we might immediately destroy the DOMMediaStream and @@ -830,7 +830,7 @@ public: nsDOMUserMediaStream::CreateTrackUnionStream(window, mListener, mAudioSource, mVideoSource); if (!trackunion) { - nsCOMPtr error = mError.forget(); + nsCOMPtr error = mOnFailure.forget(); LOG(("Returning error for getUserMedia() - no stream")); error->OnError(NS_LITERAL_STRING("NO_STREAM")); return NS_OK; @@ -874,7 +874,7 @@ public: // Note: includes JS callbacks; must be released on MainThread TracksAvailableCallback* tracksAvailableCallback = - new TracksAvailableCallback(mManager, mSuccess, mWindowID, trackunion); + new TracksAvailableCallback(mManager, mOnSuccess, mWindowID, trackunion); mListener->AudioConfig(aec_on, (uint32_t) aec, agc_on, (uint32_t) agc, @@ -889,16 +889,16 @@ public: new MediaOperationTask(MEDIA_START, mListener, trackunion, tracksAvailableCallback, mAudioSource, mVideoSource, false, mWindowID, - mError.forget())); + mOnFailure.forget())); - // We won't need mError now. - mError = nullptr; + // We won't need mOnFailure now. + mOnFailure = nullptr; return NS_OK; } private: - nsCOMPtr mSuccess; - nsCOMPtr mError; + nsCOMPtr mOnSuccess; + nsCOMPtr mOnFailure; nsRefPtr mAudioSource; nsRefPtr mVideoSource; uint64_t mWindowID; @@ -1056,13 +1056,13 @@ class GetUserMediaTask : public Task public: GetUserMediaTask( const MediaStreamConstraints& aConstraints, - already_AddRefed aSuccess, - already_AddRefed aError, + already_AddRefed aOnSuccess, + already_AddRefed aOnFailure, uint64_t aWindowID, GetUserMediaCallbackMediaStreamListener *aListener, MediaEnginePrefs &aPrefs) : mConstraints(aConstraints) - , mSuccess(aSuccess) - , mError(aError) + , mOnSuccess(aOnSuccess) + , mOnFailure(aOnFailure) , mWindowID(aWindowID) , mListener(aListener) , mPrefs(aPrefs) @@ -1077,14 +1077,14 @@ public: */ GetUserMediaTask( const MediaStreamConstraints& aConstraints, - already_AddRefed aSuccess, - already_AddRefed aError, + already_AddRefed aOnSuccess, + already_AddRefed aOnFailure, uint64_t aWindowID, GetUserMediaCallbackMediaStreamListener *aListener, MediaEnginePrefs &aPrefs, MediaEngine* aBackend) : mConstraints(aConstraints) - , mSuccess(aSuccess) - , mError(aError) + , mOnSuccess(aOnSuccess) + , mOnFailure(aOnFailure) , mWindowID(aWindowID) , mListener(aListener) , mPrefs(aPrefs) @@ -1099,10 +1099,10 @@ public: void Fail(const nsAString& aMessage) { nsRefPtr runnable = - new ErrorCallbackRunnable(mSuccess, mError, aMessage, mWindowID); + new ErrorCallbackRunnable(mOnSuccess, mOnFailure, aMessage, mWindowID); // These should be empty now - MOZ_ASSERT(!mSuccess); - MOZ_ASSERT(!mError); + MOZ_ASSERT(!mOnSuccess); + MOZ_ASSERT(!mOnFailure); NS_DispatchToMainThread(runnable); } @@ -1111,8 +1111,8 @@ public: Run() { NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread"); - MOZ_ASSERT(mSuccess); - MOZ_ASSERT(mError); + MOZ_ASSERT(mOnSuccess); + MOZ_ASSERT(mOnFailure); MediaEngine* backend = mBackend; // Was a backend provided? @@ -1138,17 +1138,17 @@ public: nsresult Denied(const nsAString& aErrorMsg) { - MOZ_ASSERT(mSuccess); - MOZ_ASSERT(mError); + MOZ_ASSERT(mOnSuccess); + MOZ_ASSERT(mOnFailure); // We add a disabled listener to the StreamListeners array until accepted // If this was the only active MediaStream, remove the window from the list. if (NS_IsMainThread()) { // This is safe since we're on main-thread, and the window can only // be invalidated from the main-thread (see OnNavigation) - nsCOMPtr success = mSuccess.forget(); - nsCOMPtr error = mError.forget(); - error->OnError(aErrorMsg); + nsCOMPtr onSuccess = mOnSuccess.forget(); + nsCOMPtr onFailure = mOnFailure.forget(); + onFailure->OnError(aErrorMsg); // Should happen *after* error runs for consistency, but may not matter nsRefPtr manager(MediaManager::GetInstance()); @@ -1162,8 +1162,8 @@ public: NS_DispatchToMainThread(new GetUserMediaListenerRemove(mWindowID, mListener)); } - MOZ_ASSERT(!mSuccess); - MOZ_ASSERT(!mError); + MOZ_ASSERT(!mOnSuccess); + MOZ_ASSERT(!mOnFailure); return NS_OK; } @@ -1194,8 +1194,8 @@ public: nsresult SelectDevice(MediaEngine* backend) { - MOZ_ASSERT(mSuccess); - MOZ_ASSERT(mError); + MOZ_ASSERT(mOnSuccess); + MOZ_ASSERT(mOnFailure); if (IsOn(mConstraints.mVideo)) { VideoTrackConstraintsN constraints(GetInvariant(mConstraints.mVideo)); nsTArray> sources; @@ -1234,8 +1234,8 @@ public: ProcessGetUserMedia(MediaEngineAudioSource* aAudioSource, MediaEngineVideoSource* aVideoSource) { - MOZ_ASSERT(mSuccess); - MOZ_ASSERT(mError); + MOZ_ASSERT(mOnSuccess); + MOZ_ASSERT(mOnFailure); nsresult rv; if (aAudioSource) { rv = aAudioSource->Allocate(GetInvariant(mConstraints.mAudio), mPrefs); @@ -1262,12 +1262,12 @@ public: } NS_DispatchToMainThread(new GetUserMediaStreamRunnable( - mSuccess, mError, mWindowID, mListener, aAudioSource, aVideoSource, + mOnSuccess, mOnFailure, mWindowID, mListener, aAudioSource, aVideoSource, peerIdentity )); - MOZ_ASSERT(!mSuccess); - MOZ_ASSERT(!mError); + MOZ_ASSERT(!mOnSuccess); + MOZ_ASSERT(!mOnFailure); return; } @@ -1275,8 +1275,8 @@ public: private: MediaStreamConstraints mConstraints; - nsCOMPtr mSuccess; - nsCOMPtr mError; + nsCOMPtr mOnSuccess; + nsCOMPtr mOnFailure; uint64_t mWindowID; nsRefPtr mListener; nsRefPtr mAudioDevice; @@ -1322,13 +1322,13 @@ class GetUserMediaDevicesTask : public Task public: GetUserMediaDevicesTask( const MediaStreamConstraints& aConstraints, - already_AddRefed aSuccess, - already_AddRefed aError, + already_AddRefed aOnSuccess, + already_AddRefed aOnFailure, uint64_t aWindowId, nsACString& aAudioLoopbackDev, nsACString& aVideoLoopbackDev) : mConstraints(aConstraints) - , mSuccess(aSuccess) - , mError(aError) + , mOnSuccess(aOnSuccess) + , mOnFailure(aOnFailure) , mManager(MediaManager::GetInstance()) , mWindowId(aWindowId) , mLoopbackAudioDevice(aAudioLoopbackDev) @@ -1368,16 +1368,16 @@ public: } NS_DispatchToMainThread(new DeviceSuccessCallbackRunnable(mWindowId, - mSuccess, mError, + mOnSuccess, mOnFailure, final.forget())); // DeviceSuccessCallbackRunnable should have taken these. - MOZ_ASSERT(!mSuccess && !mError); + MOZ_ASSERT(!mOnSuccess && !mOnFailure); } private: MediaStreamConstraints mConstraints; - nsCOMPtr mSuccess; - nsCOMPtr mError; + nsCOMPtr mOnSuccess; + nsCOMPtr mOnFailure; nsRefPtr mManager; uint64_t mWindowId; const nsString mCallId; @@ -1544,18 +1544,18 @@ nsresult MediaManager::GetUserMedia( nsPIDOMWindow* aWindow, const MediaStreamConstraints& aConstraints, nsIDOMGetUserMediaSuccessCallback* aOnSuccess, - nsIDOMGetUserMediaErrorCallback* aOnError) + nsIDOMGetUserMediaErrorCallback* aOnFailure) { NS_ASSERTION(NS_IsMainThread(), "Only call on main thread"); NS_ENSURE_TRUE(aWindow, NS_ERROR_NULL_POINTER); - NS_ENSURE_TRUE(aOnError, NS_ERROR_NULL_POINTER); + NS_ENSURE_TRUE(aOnFailure, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(aOnSuccess, NS_ERROR_NULL_POINTER); bool privileged = nsContentUtils::IsChromeDoc(aWindow->GetExtantDoc()); nsCOMPtr onSuccess(aOnSuccess); - nsCOMPtr onError(aOnError); + nsCOMPtr onFailure(aOnFailure); MediaStreamConstraints c(aConstraints); // copy @@ -1640,11 +1640,11 @@ MediaManager::GetUserMedia( if (c.mFake) { // Fake stream from default backend. task = new GetUserMediaTask(c, onSuccess.forget(), - onError.forget(), windowID, listener, mPrefs, new MediaEngineDefault()); + onFailure.forget(), windowID, listener, mPrefs, new MediaEngineDefault()); } else { // Stream from default device from WebRTC backend. task = new GetUserMediaTask(c, onSuccess.forget(), - onError.forget(), windowID, listener, mPrefs); + onFailure.forget(), windowID, listener, mPrefs); } nsIURI* docURI = aWindow->GetDocumentURI(); @@ -1778,16 +1778,16 @@ nsresult MediaManager::GetUserMediaDevices(nsPIDOMWindow* aWindow, const MediaStreamConstraints& aConstraints, nsIGetUserMediaDevicesSuccessCallback* aOnSuccess, - nsIDOMGetUserMediaErrorCallback* aOnError, + nsIDOMGetUserMediaErrorCallback* aOnFailure, uint64_t aInnerWindowID) { NS_ASSERTION(NS_IsMainThread(), "Only call on main thread"); - NS_ENSURE_TRUE(aOnError, NS_ERROR_NULL_POINTER); + NS_ENSURE_TRUE(aOnFailure, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(aOnSuccess, NS_ERROR_NULL_POINTER); nsCOMPtr onSuccess(aOnSuccess); - nsCOMPtr onError(aOnError); + nsCOMPtr onFailure(aOnFailure); // Check if the preference for using loopback devices is enabled. nsAdoptingCString loopbackAudioDevice = @@ -1797,7 +1797,7 @@ MediaManager::GetUserMediaDevices(nsPIDOMWindow* aWindow, MediaManager::GetMessageLoop()->PostTask(FROM_HERE, new GetUserMediaDevicesTask( - aConstraints, onSuccess.forget(), onError.forget(), + aConstraints, onSuccess.forget(), onFailure.forget(), (aInnerWindowID ? aInnerWindowID : aWindow->WindowID()), loopbackAudioDevice, loopbackVideoDevice)); diff --git a/dom/media/MediaManager.h b/dom/media/MediaManager.h index 4ebbdc0b2c2c..730e90892718 100644 --- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -268,7 +268,7 @@ class GetUserMediaNotificationEvent: public nsRunnable already_AddRefed aError) : mStream(aStream), mOnTracksAvailableCallback(aOnTracksAvailableCallback), mStatus(aStatus), mIsAudio(aIsAudio), mIsVideo(aIsVideo), mWindowID(aWindowID), - mError(aError) {} + mOnFailure(aError) {} virtual ~GetUserMediaNotificationEvent() { @@ -284,7 +284,7 @@ class GetUserMediaNotificationEvent: public nsRunnable bool mIsAudio; bool mIsVideo; uint64_t mWindowID; - nsRefPtr mError; + nsRefPtr mOnFailure; }; typedef enum { @@ -299,7 +299,7 @@ class GetUserMediaTask; /** * Send an error back to content. The error is the form a string. - * Do this only on the main thread. The success callback is also passed here + * Do this only on the main thread. The onSuccess callback is also passed here * so it can be released correctly. */ class ErrorCallbackRunnable : public nsRunnable @@ -313,8 +313,8 @@ public: private: ~ErrorCallbackRunnable(); - nsCOMPtr mSuccess; - nsCOMPtr mError; + nsCOMPtr mOnSuccess; + nsCOMPtr mOnFailure; const nsString mErrorMsg; uint64_t mWindowID; nsRefPtr mManager; // get ref to this when creating the runnable @@ -357,7 +357,7 @@ public: , mListener(aListener) , mBool(aBool) , mWindowID(aWindowID) - , mError(aError) + , mOnFailure(aError) {} ~MediaOperationTask() @@ -374,8 +374,8 @@ public: nsString log; log.AssignASCII(errorLog, strlen(errorLog)); - nsCOMPtr success; - NS_DispatchToMainThread(new ErrorCallbackRunnable(success, mError, + nsCOMPtr onSuccess; + NS_DispatchToMainThread(new ErrorCallbackRunnable(onSuccess, mOnFailure, log, mWindowID)); } @@ -428,7 +428,7 @@ public: mOnTracksAvailableCallback.forget(), mAudioSource != nullptr, mVideoSource != nullptr, - mWindowID, mError.forget()); + mWindowID, mOnFailure.forget()); // event must always be released on mainthread due to the JS callbacks // in the TracksAvailableCallback NS_DispatchToMainThread(event); @@ -490,7 +490,7 @@ private: nsRefPtr mListener; // threadsafe bool mBool; uint64_t mWindowID; - nsCOMPtr mError; + nsCOMPtr mOnFailure; }; typedef nsTArray > StreamListeners;