diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index a5ad9d09d5ec..4e82f06757cb 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -1103,7 +1103,7 @@ static auto& MediaManager_AnonymizeDevices = MediaManager::AnonymizeDevices; already_AddRefed MediaManager::SelectSettings( MediaStreamConstraints& aConstraints, - RefPtr>>& aSources) + RefPtr>>& aSources) { MOZ_ASSERT(NS_IsMainThread()); RefPtr p = new PledgeChar(); @@ -1414,7 +1414,7 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId, realBackend = manager->GetBackend(aWindowId); } - ScopedDeletePtr result(new SourceSet); + auto result = MakeUnique(); if (hasVideo) { nsTArray> videos; @@ -1432,16 +1432,16 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId, result->AppendElement(source); } } - SourceSet* handoff = result.forget(); + SourceSet* handoff = result.release(); NS_DispatchToMainThread(do_AddRef(NewRunnableFrom([id, handoff]() mutable { - ScopedDeletePtr result(handoff); // grab result + UniquePtr result(handoff); // grab result RefPtr mgr = MediaManager_GetInstance(); if (!mgr) { return NS_OK; } RefPtr p = mgr->mOutstandingPledges.Remove(id); if (p) { - p->Resolve(result.forget()); + p->Resolve(result.release()); } return NS_OK; }))); @@ -1609,9 +1609,9 @@ media::Parent* MediaManager::GetNonE10sParent() { if (!mNonE10sParent) { - mNonE10sParent = new media::Parent(true); + mNonE10sParent = MakeUnique>(true); } - return mNonE10sParent; + return mNonE10sParent.get(); } /* static */ void @@ -2115,8 +2115,8 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow, p->Then([this, onSuccess, onFailure, windowID, c, listener, askPermission, prefs, isHTTPS, callID, origin](SourceSet*& aDevices) mutable { - RefPtr>> devices( - new Refcountable>(aDevices)); // grab result + RefPtr>> devices( + new Refcountable>(aDevices)); // grab result // Ensure that the captured 'this' pointer and our windowID are still good. if (!MediaManager::Exists() || @@ -2176,7 +2176,7 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow, onFailure.forget(), windowID, listener, prefs, origin, - devices->forget())); + devices->release())); // Store the task w/callbacks. mActiveCallbacks.Put(callID, task.forget()); @@ -2335,7 +2335,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId, aVideoType, aAudioType, aFake, aFakeTracks); p->Then([id, aWindowId, aOriginKey](SourceSet*& aDevices) mutable { - ScopedDeletePtr devices(aDevices); // secondary result + UniquePtr devices(aDevices); // secondary result // Only run if window is still on our active list. RefPtr mgr = MediaManager_GetInstance(); @@ -2347,7 +2347,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId, return NS_OK; } MediaManager_AnonymizeDevices(*devices, aOriginKey); - p->Resolve(devices.forget()); + p->Resolve(devices.release()); return NS_OK; }); }); @@ -2381,7 +2381,7 @@ MediaManager::EnumerateDevices(nsPIDOMWindowInner* aWindow, MediaSourceEnum::Microphone, fake); p->Then([onSuccess, windowId, listener](SourceSet*& aDevices) mutable { - ScopedDeletePtr devices(aDevices); // grab result + UniquePtr devices(aDevices); // grab result RefPtr mgr = MediaManager_GetInstance(); mgr->RemoveFromWindowList(windowId, listener); nsCOMPtr array = MediaManager_ToJSArray(*devices); diff --git a/dom/media/MediaManager.h b/dom/media/MediaManager.h index 62db1408e5cd..fbc9891c2e3f 100644 --- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -30,6 +30,7 @@ #include "mozilla/media/MediaChild.h" #include "mozilla/media/MediaParent.h" #include "mozilla/Logging.h" +#include "mozilla/UniquePtr.h" #include "DOMMediaStream.h" #ifdef MOZ_WEBRTC @@ -501,7 +502,7 @@ private: already_AddRefed SelectSettings( dom::MediaStreamConstraints& aConstraints, - RefPtr>>& aSources); + RefPtr>>& aSources); StreamListeners* AddWindowID(uint64_t aWindowId); WindowTable *GetActiveWindows() { @@ -550,7 +551,7 @@ private: #endif public: media::CoatCheck> mGetOriginKeyPledges; - ScopedDeletePtr> mNonE10sParent; + UniquePtr> mNonE10sParent; }; } // namespace mozilla diff --git a/dom/media/VideoSegment.cpp b/dom/media/VideoSegment.cpp index e382eacfabb0..115bdc1d5c92 100644 --- a/dom/media/VideoSegment.cpp +++ b/dom/media/VideoSegment.cpp @@ -8,6 +8,7 @@ #include "gfx2DGlue.h" #include "ImageContainer.h" #include "Layers.h" +#include "mozilla/UniquePtr.h" namespace mozilla { @@ -52,18 +53,18 @@ VideoFrame::CreateBlackImage(const gfx::IntSize& aSize) int len = ((aSize.width * aSize.height) * 3 / 2); // Generate a black image. - ScopedDeletePtr frame(new uint8_t[len]); + auto frame = MakeUnique(len); int y = aSize.width * aSize.height; // Fill Y plane. - memset(frame.rwget(), 0x10, y); + memset(frame.get(), 0x10, y); // Fill Cb/Cr planes. - memset(frame.rwget() + y, 0x80, (len - y)); + memset(frame.get() + y, 0x80, (len - y)); const uint8_t lumaBpp = 8; const uint8_t chromaBpp = 4; layers::PlanarYCbCrData data; - data.mYChannel = frame.rwget(); + data.mYChannel = frame.get(); data.mYSize = gfx::IntSize(aSize.width, aSize.height); data.mYStride = (int32_t) (aSize.width * lumaBpp / 8.0); data.mCbCrStride = (int32_t) (aSize.width * chromaBpp / 8.0); diff --git a/dom/media/systemservices/MediaChild.cpp b/dom/media/systemservices/MediaChild.cpp index 0ff3ac081762..5d04f5f823df 100644 --- a/dom/media/systemservices/MediaChild.cpp +++ b/dom/media/systemservices/MediaChild.cpp @@ -46,7 +46,7 @@ SanitizeOriginKeys(const uint64_t& aSinceWhen, bool aOnlyPrivateBrowsing) if (XRE_GetProcessType() == GeckoProcessType_Default) { // Avoid opening MediaManager in this case, since this is called by // sanitize.js when cookies are cleared, which can happen on startup. - ScopedDeletePtr> tmpParent(new Parent(true)); + auto tmpParent = MakeUnique>(true); tmpParent->RecvSanitizeOriginKeys(aSinceWhen, aOnlyPrivateBrowsing); } else { Child::Get()->SendSanitizeOriginKeys(aSinceWhen, aOnlyPrivateBrowsing); diff --git a/dom/media/systemservices/MediaUtils.h b/dom/media/systemservices/MediaUtils.h index dad43bd34994..d6cdc0cc5c92 100644 --- a/dom/media/systemservices/MediaUtils.h +++ b/dom/media/systemservices/MediaUtils.h @@ -10,6 +10,7 @@ #include "nsAutoPtr.h" #include "nsThreadUtils.h" #include "nsIAsyncShutdown.h" +#include "mozilla/UniquePtr.h" #include "base/task.h" namespace mozilla { @@ -96,8 +97,8 @@ public: OnSuccessType mOnSuccess; OnFailureType mOnFailure; }; - mFunctors = new Functors(Forward(aOnSuccess), - Forward(aOnFailure)); + mFunctors = MakeUnique(Forward(aOnSuccess), + Forward(aOnFailure)); if (mDone) { if (!mRejected) { mFunctors->Succeed(mValue); @@ -142,7 +143,7 @@ private: bool mDone; bool mRejected; ErrorType mError; - ScopedDeletePtr mFunctors; + UniquePtr mFunctors; }; /* media::NewRunnableFrom() - Create an nsRunnable from a lambda. @@ -337,7 +338,7 @@ private: * (or owning smart-pointers to such objects) refcountable. * * Technical limitation: A template specialization is needed for types that take - * a constructor. Please add below (ScopedDeletePtr covers a lot of ground though). + * a constructor. Please add below (UniquePtr covers a lot of ground though). */ template @@ -350,13 +351,13 @@ private: }; template -class Refcountable> : public ScopedDeletePtr +class Refcountable> : public UniquePtr { public: - explicit Refcountable>(T* aPtr) : ScopedDeletePtr(aPtr) {} + explicit Refcountable>(T* aPtr) : UniquePtr(aPtr) {} NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Refcountable) private: - ~Refcountable>() {} + ~Refcountable>() {} }; /* media::ShutdownBlocker - Async shutdown helper.