Backed out 2 changesets (bug 1329319) because it will not build a=backout

Backed out changeset ae96a44e6a8f (bug 1329319)
Backed out changeset a75ecabf7129 (bug 1329319)

MozReview-Commit-ID: HQ3on7jlZXN
This commit is contained in:
Wes Kocher 2017-01-09 15:46:42 -08:00
Родитель 53855b51b8
Коммит b0df943433
3 изменённых файлов: 52 добавлений и 113 удалений

Просмотреть файл

@ -960,7 +960,7 @@ TrackBuffersManager::OnDemuxerInitDone(nsresult)
// 1. Update the duration attribute if it currently equals NaN. // 1. Update the duration attribute if it currently equals NaN.
// Those steps are performed by the MediaSourceDecoder::SetInitialDuration // Those steps are performed by the MediaSourceDecoder::SetInitialDuration
AbstractThread::MainThread()->Dispatch(NewRunnableMethod<int64_t> AbstractThread::MainThread()->Dispatch(NewRunnableMethod<int64_t>
(mParentDecoder.get(), (mParentDecoder,
&MediaSourceDecoder::SetInitialDuration, &MediaSourceDecoder::SetInitialDuration,
duration ? duration : -1)); duration ? duration : -1));

Просмотреть файл

@ -463,70 +463,57 @@ struct nsRunnableMethodReceiver<ClassType, false>
void Revoke() { mObj = nullptr; } void Revoke() { mObj = nullptr; }
}; };
template<typename PtrType, typename Method, bool Owning, bool Cancelable> template<typename Method, bool Owning, bool Cancelable> struct nsRunnableMethodTraits;
struct nsRunnableMethodTraits;
template<typename PtrType, class C, typename R, bool Owning, bool Cancelable, typename... As> template<class C, typename R, bool Owning, bool Cancelable, typename... As>
struct nsRunnableMethodTraits<PtrType, R(C::*)(As...), Owning, Cancelable> struct nsRunnableMethodTraits<R(C::*)(As...), Owning, Cancelable>
{ {
typedef typename mozilla::RemoveAnyPointer<PtrType>::Type class_type; typedef C class_type;
static_assert(mozilla::IsBaseOf<C, class_type>::value,
"Stored class must inherit from method's class");
typedef R return_type; typedef R return_type;
typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type; typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type;
static const bool can_cancel = Cancelable; static const bool can_cancel = Cancelable;
}; };
template<typename PtrType, class C, typename R, bool Owning, bool Cancelable, typename... As> template<class C, typename R, bool Owning, bool Cancelable, typename... As>
struct nsRunnableMethodTraits<PtrType, R(C::*)(As...) const, Owning, Cancelable> struct nsRunnableMethodTraits<R(C::*)(As...) const, Owning, Cancelable>
{ {
typedef const typename mozilla::RemoveAnyPointer<PtrType>::Type class_type; typedef const C class_type;
static_assert(mozilla::IsBaseOf<C, class_type>::value,
"Stored class must inherit from method's class");
typedef R return_type; typedef R return_type;
typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type; typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type;
static const bool can_cancel = Cancelable; static const bool can_cancel = Cancelable;
}; };
#ifdef NS_HAVE_STDCALL #ifdef NS_HAVE_STDCALL
template<typename PtrType, class C, typename R, bool Owning, bool Cancelable, typename... As> template<class C, typename R, bool Owning, bool Cancelable, typename... As>
struct nsRunnableMethodTraits<PtrType, R(__stdcall C::*)(As...), Owning, Cancelable> struct nsRunnableMethodTraits<R(__stdcall C::*)(As...), Owning, Cancelable>
{ {
typedef typename mozilla::RemoveAnyPointer<PtrType>::Type class_type; typedef C class_type;
static_assert(mozilla::IsBaseOf<C, class_type>::value,
"Stored class must inherit from method's class");
typedef R return_type; typedef R return_type;
typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type; typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type;
static const bool can_cancel = Cancelable; static const bool can_cancel = Cancelable;
}; };
template<typename PtrType, class C, typename R, bool Owning, bool Cancelable> template<class C, typename R, bool Owning, bool Cancelable>
struct nsRunnableMethodTraits<PtrType, R(NS_STDCALL C::*)(), Owning, Cancelable> struct nsRunnableMethodTraits<R(NS_STDCALL C::*)(), Owning, Cancelable>
{ {
typedef typename mozilla::RemoveAnyPointer<PtrType>::Type class_type; typedef C class_type;
static_assert(mozilla::IsBaseOf<C, class_type>::value,
"Stored class must inherit from method's class");
typedef R return_type; typedef R return_type;
typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type; typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type;
static const bool can_cancel = Cancelable; static const bool can_cancel = Cancelable;
}; };
template<typename PtrType, class C, typename R, bool Owning, bool Cancelable, typename... As> template<class C, typename R, bool Owning, bool Cancelable, typename... As>
struct nsRunnableMethodTraits<PtrType, R(__stdcall C::*)(As...) const, Owning, Cancelable> struct nsRunnableMethodTraits<R(__stdcall C::*)(As...) const, Owning, Cancelable>
{ {
typedef const typename mozilla::RemoveAnyPointer<PtrType>::Type class_type; typedef const C class_type;
static_assert(mozilla::IsBaseOf<C, class_type>::value,
"Stored class must inherit from method's class");
typedef R return_type; typedef R return_type;
typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type; typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type;
static const bool can_cancel = Cancelable; static const bool can_cancel = Cancelable;
}; };
template<typename PtrType, class C, typename R, bool Owning, bool Cancelable> template<class C, typename R, bool Owning, bool Cancelable>
struct nsRunnableMethodTraits<PtrType, R(NS_STDCALL C::*)() const, Owning, Cancelable> struct nsRunnableMethodTraits<R(NS_STDCALL C::*)() const, Owning, Cancelable>
{ {
typedef const typename mozilla::RemoveAnyPointer<PtrType>::Type class_type; typedef const C class_type;
static_assert(mozilla::IsBaseOf<C, class_type>::value,
"Stored class must inherit from method's class");
typedef R return_type; typedef R return_type;
typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type; typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type;
static const bool can_cancel = Cancelable; static const bool can_cancel = Cancelable;
@ -833,11 +820,11 @@ struct RunnableMethodArguments final
} }
}; };
template<typename PtrType, typename Method, bool Owning, bool Cancelable, typename... Storages> template<typename Method, bool Owning, bool Cancelable, typename... Storages>
class RunnableMethodImpl final class RunnableMethodImpl final
: public ::nsRunnableMethodTraits<PtrType, Method, Owning, Cancelable>::base_type : public ::nsRunnableMethodTraits<Method, Owning, Cancelable>::base_type
{ {
typedef typename ::nsRunnableMethodTraits<PtrType, Method, Owning, Cancelable>::class_type typedef typename ::nsRunnableMethodTraits<Method, Owning, Cancelable>::class_type
ClassType; ClassType;
::nsRunnableMethodReceiver<ClassType, Owning> mReceiver; ::nsRunnableMethodReceiver<ClassType, Owning> mReceiver;
Method mMethod; Method mMethod;
@ -845,10 +832,10 @@ class RunnableMethodImpl final
private: private:
virtual ~RunnableMethodImpl() { Revoke(); }; virtual ~RunnableMethodImpl() { Revoke(); };
public: public:
template<typename ForwardedPtrType, typename... Args> template<typename... Args>
explicit RunnableMethodImpl(ForwardedPtrType&& aObj, Method aMethod, explicit RunnableMethodImpl(ClassType* aObj, Method aMethod,
Args&&... aArgs) Args&&... aArgs)
: mReceiver(Forward<ForwardedPtrType>(aObj)) : mReceiver(aObj)
, mMethod(aMethod) , mMethod(aMethod)
, mArgs(Forward<Args>(aArgs)...) , mArgs(Forward<Args>(aArgs)...)
{ {
@ -883,112 +870,76 @@ public:
// //
template<typename PtrType, typename Method> template<typename PtrType, typename Method>
already_AddRefed< already_AddRefed<typename ::nsRunnableMethodTraits<Method, true, false>::base_type>
typename ::nsRunnableMethodTraits< NewRunnableMethod(PtrType aPtr, Method aMethod)
typename RemoveReference<PtrType>::Type, Method, true, false>::base_type>
NewRunnableMethod(PtrType&& aPtr, Method aMethod)
{ {
return do_AddRef( return do_AddRef(new detail::RunnableMethodImpl<Method, true, false>(aPtr, aMethod));
new detail::RunnableMethodImpl
<typename RemoveReference<PtrType>::Type, Method, true, false>
(Forward<PtrType>(aPtr), aMethod));
} }
template<typename PtrType, typename Method> template<typename PtrType, typename Method>
already_AddRefed< already_AddRefed<typename ::nsRunnableMethodTraits<Method, true, true>::base_type>
typename ::nsRunnableMethodTraits< NewCancelableRunnableMethod(PtrType aPtr, Method aMethod)
typename RemoveReference<PtrType>::Type, Method, true, true>::base_type>
NewCancelableRunnableMethod(PtrType&& aPtr, Method aMethod)
{ {
return do_AddRef( return do_AddRef(new detail::RunnableMethodImpl<Method, true, true>(aPtr, aMethod));
new detail::RunnableMethodImpl
<typename RemoveReference<PtrType>::Type, Method, true, true>
(Forward<PtrType>(aPtr), aMethod));
} }
template<typename PtrType, typename Method> template<typename PtrType, typename Method>
already_AddRefed< already_AddRefed<typename ::nsRunnableMethodTraits<Method, false, false>::base_type>
typename ::nsRunnableMethodTraits<
typename RemoveReference<PtrType>::Type, Method, false, false>::base_type>
NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod) NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod)
{ {
return do_AddRef( return do_AddRef(new detail::RunnableMethodImpl<Method, false, false>(aPtr, aMethod));
new detail::RunnableMethodImpl
<typename RemoveReference<PtrType>::Type, Method, false, false>
(Forward<PtrType>(aPtr), aMethod));
} }
template<typename PtrType, typename Method> template<typename PtrType, typename Method>
already_AddRefed< already_AddRefed<typename ::nsRunnableMethodTraits<Method, false, true>::base_type>
typename ::nsRunnableMethodTraits<
typename RemoveReference<PtrType>::Type, Method, false, true>::base_type>
NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod) NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod)
{ {
return do_AddRef( return do_AddRef(new detail::RunnableMethodImpl<Method, false, true>(aPtr, aMethod));
new detail::RunnableMethodImpl
<typename RemoveReference<PtrType>::Type, Method, false, true>
(Forward<PtrType>(aPtr), aMethod));
} }
// Similar to NewRunnableMethod. Call like so: // Similar to NewRunnableMethod. Call like so:
// nsCOMPtr<nsIRunnable> event = // nsCOMPtr<nsIRunnable> event =
// NewRunnableMethod<Types,...>(myObject, &MyClass::HandleEvent, myArg1,...); // NewRunnableMethod<Types,...>(myObject, &MyClass::HandleEvent, myArg1,...);
// 'Types' are the stored type for each argument, see ParameterStorage for details. // 'Types' are the stored type for each argument, see ParameterStorage for details.
template<typename... Storages, typename PtrType, typename Method, typename... Args> template<typename... Storages, typename Method, typename PtrType, typename... Args>
already_AddRefed< already_AddRefed<typename ::nsRunnableMethodTraits<Method, true, false>::base_type>
typename ::nsRunnableMethodTraits<
typename RemoveReference<PtrType>::Type, Method, true, false>::base_type>
NewRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) NewRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
{ {
static_assert(sizeof...(Storages) == sizeof...(Args), static_assert(sizeof...(Storages) == sizeof...(Args),
"<Storages...> size should be equal to number of arguments"); "<Storages...> size should be equal to number of arguments");
return do_AddRef( return do_AddRef(new detail::RunnableMethodImpl<Method, true, false, Storages...>(
new detail::RunnableMethodImpl aPtr, aMethod, mozilla::Forward<Args>(aArgs)...));
<typename RemoveReference<PtrType>::Type, Method, true, false, Storages...>
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
} }
template<typename... Storages, typename PtrType, typename Method, typename... Args> template<typename... Storages, typename Method, typename PtrType, typename... Args>
already_AddRefed< already_AddRefed<typename ::nsRunnableMethodTraits<Method, false, false>::base_type>
typename ::nsRunnableMethodTraits<
typename RemoveReference<PtrType>::Type, Method, false, false>::base_type>
NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
{ {
static_assert(sizeof...(Storages) == sizeof...(Args), static_assert(sizeof...(Storages) == sizeof...(Args),
"<Storages...> size should be equal to number of arguments"); "<Storages...> size should be equal to number of arguments");
return do_AddRef( return do_AddRef(new detail::RunnableMethodImpl<Method, false, false, Storages...>(
new detail::RunnableMethodImpl aPtr, aMethod, mozilla::Forward<Args>(aArgs)...));
<typename RemoveReference<PtrType>::Type, Method, false, false, Storages...>
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
} }
template<typename... Storages, typename PtrType, typename Method, typename... Args> template<typename... Storages, typename Method, typename PtrType, typename... Args>
already_AddRefed< already_AddRefed<typename ::nsRunnableMethodTraits<Method, true, true>::base_type>
typename ::nsRunnableMethodTraits<
typename RemoveReference<PtrType>::Type, Method, true, true>::base_type>
NewCancelableRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) NewCancelableRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
{ {
static_assert(sizeof...(Storages) == sizeof...(Args), static_assert(sizeof...(Storages) == sizeof...(Args),
"<Storages...> size should be equal to number of arguments"); "<Storages...> size should be equal to number of arguments");
return do_AddRef( return do_AddRef(new detail::RunnableMethodImpl<Method, true, true, Storages...>(
new detail::RunnableMethodImpl aPtr, aMethod, mozilla::Forward<Args>(aArgs)...));
<typename RemoveReference<PtrType>::Type, Method, true, true, Storages...>
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
} }
template<typename... Storages, typename PtrType, typename Method, typename... Args> template<typename... Storages, typename Method, typename PtrType, typename... Args>
already_AddRefed< already_AddRefed<typename ::nsRunnableMethodTraits<Method, false, true>::base_type>
typename ::nsRunnableMethodTraits<
typename RemoveReference<PtrType>::Type, Method, false, true>::base_type>
NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod, NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod,
Args&&... aArgs) Args&&... aArgs)
{ {
static_assert(sizeof...(Storages) == sizeof...(Args), static_assert(sizeof...(Storages) == sizeof...(Args),
"<Storages...> size should be equal to number of arguments"); "<Storages...> size should be equal to number of arguments");
return do_AddRef( return do_AddRef(new detail::RunnableMethodImpl<Method, false, true, Storages...>(
new detail::RunnableMethodImpl aPtr, aMethod, mozilla::Forward<Args>(aArgs)...));
<typename RemoveReference<PtrType>::Type, Method, false, true, Storages...>
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
} }
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -180,13 +180,7 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(IThreadUtilsObject, NS_IFOO_IID) NS_DEFINE_STATIC_IID_ACCESSOR(IThreadUtilsObject, NS_IFOO_IID)
struct ThreadUtilsObjectNonRefCountedBase
{
virtual void MethodFromNonRefCountedBase() {}
};
struct ThreadUtilsObject : public IThreadUtilsObject struct ThreadUtilsObject : public IThreadUtilsObject
, public ThreadUtilsObjectNonRefCountedBase
{ {
// nsISupports implementation // nsISupports implementation
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -380,12 +374,6 @@ TEST(ThreadUtils, main)
EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(count += 2, rpt->mCount);
EXPECT_EQ(11, rpt->mA0); EXPECT_EQ(11, rpt->mA0);
// Test calling a method from a non-ref-counted base.
r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::MethodFromNonRefCountedBase);
r1->Run();
EXPECT_EQ(count, rpt->mCount);
// Test variadic function with simple POD arguments. // Test variadic function with simple POD arguments.
r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test0); r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test0);