diff --git a/mfbt/RefPtr.h b/mfbt/RefPtr.h index 7baa053eb5bd..af3180105cbd 100644 --- a/mfbt/RefPtr.h +++ b/mfbt/RefPtr.h @@ -30,7 +30,6 @@ namespace mozilla { template class RefCounted; template class RefPtr; -template class TemporaryRef; template class OutParamRef; template OutParamRef byRef(RefPtr&); @@ -227,7 +226,6 @@ template class RefPtr { // To allow them to use unref() - friend class TemporaryRef; friend class OutParamRef; struct DontRef {}; @@ -235,7 +233,6 @@ class RefPtr public: RefPtr() : mPtr(0) {} RefPtr(const RefPtr& aOther) : mPtr(ref(aOther.mPtr)) {} - MOZ_IMPLICIT RefPtr(const TemporaryRef& aOther) : mPtr(aOther.take()) {} MOZ_IMPLICIT RefPtr(already_AddRefed& aOther) : mPtr(aOther.take()) {} MOZ_IMPLICIT RefPtr(already_AddRefed&& aOther) : mPtr(aOther.take()) {} MOZ_IMPLICIT RefPtr(T* aVal) : mPtr(ref(aVal)) {} @@ -250,11 +247,6 @@ public: assign(ref(aOther.mPtr)); return *this; } - RefPtr& operator=(const TemporaryRef& aOther) - { - assign(aOther.take()); - return *this; - } RefPtr& operator=(already_AddRefed& aOther) { assign(aOther.take()); @@ -315,50 +307,6 @@ private: } }; -/** - * TemporaryRef represents an object that holds a temporary - * reference to a T. TemporaryRef objects can't be manually ref'd or - * unref'd (being temporaries, not lvalues), so can only relinquish - * references to other objects, or unref on destruction. - */ -template -class TemporaryRef -{ - // To allow it to construct TemporaryRef from a bare T* - friend class RefPtr; - - typedef typename RefPtr::DontRef DontRef; - -public: - // Please see already_AddRefed for a description of what these constructors - // do. - TemporaryRef() : mPtr(nullptr) {} - typedef void (TemporaryRef::* MatchNullptr)(double, float); - MOZ_IMPLICIT TemporaryRef(MatchNullptr aRawPtr) : mPtr(nullptr) {} - explicit TemporaryRef(T* aVal) : mPtr(RefPtr::ref(aVal)) {} - - TemporaryRef(const TemporaryRef& aOther) : mPtr(aOther.take()) {} - - template - TemporaryRef(const TemporaryRef& aOther) : mPtr(aOther.take()) {} - - ~TemporaryRef() { RefPtr::unref(mPtr); } - - MOZ_WARN_UNUSED_RESULT T* take() const - { - T* tmp = mPtr; - mPtr = nullptr; - return tmp; - } - -private: - TemporaryRef(T* aVal, const DontRef&) : mPtr(aVal) {} - - mutable T* MOZ_OWNING_REF mPtr; - - void operator=(const TemporaryRef&) = delete; -}; - /** * OutParamRef is a wrapper that tracks a refcounted pointer passed as * an outparam argument to a function. OutParamRef implements COM T** @@ -369,7 +317,7 @@ private: * returns the same T* passed to it through the T** outparam, as long * as the callee obeys the COM discipline. * - * Prefer returning TemporaryRef from functions over creating T** + * Prefer returning already_AddRefed from functions over creating T** * outparams and passing OutParamRef to T**. Prefer RefPtr* * outparams over T** outparams. */