зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 4d33d0e50338 (bug 1372405
)
--HG-- extra : rebase_source : e615bdaa0bca09ea4b39c732dd952d2faddb8207
This commit is contained in:
Родитель
e7f9a1c388
Коммит
1083602212
|
@ -477,16 +477,12 @@ using RunnableFunctionImpl =
|
|||
|
||||
template <typename T>
|
||||
inline already_AddRefed<T>
|
||||
SetRunnableName(const char* aName, T* aObj)
|
||||
SetRunnableName(already_AddRefed<T>&& aObj, const char* aName)
|
||||
{
|
||||
#ifdef RELEASE_OR_BETA
|
||||
return do_AddRef(aObj);
|
||||
#else
|
||||
MOZ_RELEASE_ASSERT(aName);
|
||||
RefPtr<T> ref(aObj);
|
||||
ref->SetName(aName);
|
||||
return ref.forget();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
@ -579,14 +575,20 @@ ToSupports(mozilla::Runnable *p)
|
|||
|
||||
template<typename Function>
|
||||
already_AddRefed<mozilla::Runnable>
|
||||
NS_NewRunnableFunction(const char* aName, Function&& aFunction)
|
||||
NS_NewRunnableFunctionXXX(Function&& aFunction)
|
||||
{
|
||||
// We store a non-reference in RunnableFunction, but still forward aFunction
|
||||
// to move if possible.
|
||||
return do_AddRef(new mozilla::detail::RunnableFunctionImpl<Function>
|
||||
(mozilla::Forward<Function>(aFunction)));
|
||||
}
|
||||
|
||||
template<typename Function>
|
||||
already_AddRefed<mozilla::Runnable>
|
||||
NS_NewRunnableFunction(const char* aName, Function&& aFunction)
|
||||
{
|
||||
return mozilla::detail::SetRunnableName(
|
||||
aName,
|
||||
new mozilla::detail::RunnableFunctionImpl<Function>(
|
||||
mozilla::Forward<Function>(aFunction)));
|
||||
NS_NewRunnableFunctionXXX(mozilla::Forward<Function>(aFunction)), aName);
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -1339,14 +1341,30 @@ using NonOwningIdleRunnableMethodWithTimerImpl = RunnableMethodImpl<
|
|||
// these in older code. The `const char*` overload is preferred and
|
||||
// should be used in new code exclusively.
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
already_AddRefed<detail::OwningRunnableMethod<PtrType, Method>>
|
||||
NewRunnableMethodXXX(PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return do_AddRef(
|
||||
new detail::OwningRunnableMethodImpl<PtrType, Method>
|
||||
(Forward<PtrType>(aPtr), aMethod));
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
already_AddRefed<detail::OwningRunnableMethod<PtrType, Method>>
|
||||
NewRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::OwningRunnableMethodImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
NewRunnableMethodXXX(Forward<PtrType>(aPtr), aMethod), aName);
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
already_AddRefed<detail::CancelableRunnableMethod<PtrType, Method>>
|
||||
NewCancelableRunnableMethodXXX(PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return do_AddRef(
|
||||
new detail::CancelableRunnableMethodImpl<PtrType, Method>
|
||||
(Forward<PtrType>(aPtr), aMethod));
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
|
@ -1354,9 +1372,15 @@ already_AddRefed<detail::CancelableRunnableMethod<PtrType, Method>>
|
|||
NewCancelableRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::CancelableRunnableMethodImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
NewCancelableRunnableMethodXXX(Forward<PtrType>(aPtr), aMethod), aName);
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
already_AddRefed<detail::IdleRunnableMethod<PtrType, Method>>
|
||||
NewIdleRunnableMethodXXX(PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return do_AddRef(new detail::IdleRunnableMethodImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
|
@ -1364,9 +1388,15 @@ already_AddRefed<detail::IdleRunnableMethod<PtrType, Method>>
|
|||
NewIdleRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::IdleRunnableMethodImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
NewIdleRunnableMethodXXX(Forward<PtrType>(aPtr), aMethod), aName);
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
already_AddRefed<detail::IdleRunnableMethodWithTimer<PtrType, Method>>
|
||||
NewIdleRunnableMethodWithTimerXXX(PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return do_AddRef(new detail::IdleRunnableMethodWithTimerImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
|
@ -1376,9 +1406,17 @@ NewIdleRunnableMethodWithTimer(const char* aName,
|
|||
Method aMethod)
|
||||
{
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::IdleRunnableMethodWithTimerImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
NewIdleRunnableMethodWithTimerXXX(Forward<PtrType>(aPtr), aMethod),
|
||||
aName);
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
already_AddRefed<detail::NonOwningRunnableMethod<PtrType, Method>>
|
||||
NewNonOwningRunnableMethodXXX(PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return do_AddRef(
|
||||
new detail::NonOwningRunnableMethodImpl<PtrType, Method>
|
||||
(Forward<PtrType>(aPtr), aMethod));
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
|
@ -1386,9 +1424,16 @@ already_AddRefed<detail::NonOwningRunnableMethod<PtrType, Method>>
|
|||
NewNonOwningRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::NonOwningRunnableMethodImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
NewNonOwningRunnableMethodXXX(Forward<PtrType>(aPtr), aMethod), aName);
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
already_AddRefed<detail::NonOwningCancelableRunnableMethod<PtrType, Method>>
|
||||
NewNonOwningCancelableRunnableMethodXXX(PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return do_AddRef(
|
||||
new detail::NonOwningCancelableRunnableMethodImpl<PtrType, Method>
|
||||
(Forward<PtrType>(aPtr), aMethod));
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
|
@ -1397,8 +1442,15 @@ NewNonOwningCancelableRunnableMethod(const char* aName, PtrType&& aPtr,
|
|||
Method aMethod)
|
||||
{
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::NonOwningCancelableRunnableMethodImpl<PtrType, Method>(
|
||||
NewNonOwningCancelableRunnableMethodXXX(Forward<PtrType>(aPtr), aMethod), aName);
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
already_AddRefed<detail::NonOwningIdleRunnableMethod<PtrType, Method>>
|
||||
NewNonOwningIdleRunnableMethodXXX(PtrType&& aPtr, Method aMethod)
|
||||
{
|
||||
return do_AddRef(
|
||||
new detail::NonOwningIdleRunnableMethodImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
}
|
||||
|
||||
|
@ -1409,9 +1461,17 @@ NewNonOwningIdleRunnableMethod(const char* aName,
|
|||
Method aMethod)
|
||||
{
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::NonOwningIdleRunnableMethodImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
NewNonOwningIdleRunnableMethodXXX(Forward<PtrType>(aPtr), aMethod), aName);
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
already_AddRefed<detail::NonOwningIdleRunnableMethodWithTimer<PtrType, Method>>
|
||||
NewNonOwningIdleRunnableMethodWithTimerXXX(PtrType&& aPtr,
|
||||
Method aMethod)
|
||||
{
|
||||
return do_AddRef(
|
||||
new detail::NonOwningIdleRunnableMethodWithTimerImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
}
|
||||
|
||||
template<typename PtrType, typename Method>
|
||||
|
@ -1420,16 +1480,26 @@ NewNonOwningIdleRunnableMethodWithTimer(const char* aName,
|
|||
PtrType&& aPtr,
|
||||
Method aMethod)
|
||||
{
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::NonOwningIdleRunnableMethodWithTimerImpl<PtrType, Method>(
|
||||
Forward<PtrType>(aPtr), aMethod));
|
||||
return detail::SetRunnableName(NewNonOwningIdleRunnableMethodWithTimerXXX(
|
||||
Forward<PtrType>(aPtr), aMethod),
|
||||
aName);
|
||||
}
|
||||
|
||||
// Similar to NewRunnableMethod. Call like so:
|
||||
// nsCOMPtr<nsIRunnable> event =
|
||||
// NewRunnableMethod<Types,...>(myObject, &MyClass::HandleEvent, myArg1,...);
|
||||
// 'Types' are the stored type for each argument, see ParameterStorage for details.
|
||||
template<typename... Storages, typename PtrType, typename Method, typename... Args>
|
||||
already_AddRefed<detail::OwningRunnableMethod<PtrType, Method>>
|
||||
NewRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
|
||||
{
|
||||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return do_AddRef(
|
||||
new detail::OwningRunnableMethodImpl<PtrType, Method, Storages...>
|
||||
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
}
|
||||
|
||||
template<typename... Storages, typename PtrType, typename Method, typename... Args>
|
||||
already_AddRefed<detail::OwningRunnableMethod<PtrType, Method>>
|
||||
NewRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod, Args&&... aArgs)
|
||||
|
@ -1437,9 +1507,19 @@ NewRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod, Args&&... a
|
|||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::OwningRunnableMethodImpl<PtrType, Method, Storages...>(
|
||||
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
NewRunnableMethodXXX<Storages...>
|
||||
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...), aName);
|
||||
}
|
||||
|
||||
template<typename... Storages, typename PtrType, typename Method, typename... Args>
|
||||
already_AddRefed<detail::NonOwningRunnableMethod<PtrType, Method>>
|
||||
NewNonOwningRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
|
||||
{
|
||||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return do_AddRef(
|
||||
new detail::NonOwningRunnableMethodImpl<PtrType, Method, Storages...>
|
||||
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
}
|
||||
|
||||
template<typename... Storages, typename PtrType, typename Method, typename... Args>
|
||||
|
@ -1450,9 +1530,19 @@ NewNonOwningRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod,
|
|||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::NonOwningRunnableMethodImpl<PtrType, Method, Storages...>(
|
||||
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
NewNonOwningRunnableMethodXXX<Storages...>
|
||||
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...), aName);
|
||||
}
|
||||
|
||||
template<typename... Storages, typename PtrType, typename Method, typename... Args>
|
||||
already_AddRefed<detail::CancelableRunnableMethod<PtrType, Method>>
|
||||
NewCancelableRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
|
||||
{
|
||||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return do_AddRef(
|
||||
new detail::CancelableRunnableMethodImpl<PtrType, Method, Storages...>
|
||||
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
}
|
||||
|
||||
template<typename... Storages, typename PtrType, typename Method, typename... Args>
|
||||
|
@ -1463,9 +1553,20 @@ NewCancelableRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod,
|
|||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::CancelableRunnableMethodImpl<PtrType, Method, Storages...>(
|
||||
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
NewCancelableRunnableMethodXXX<Storages...>
|
||||
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...), aName);
|
||||
}
|
||||
|
||||
template<typename... Storages, typename PtrType, typename Method, typename... Args>
|
||||
already_AddRefed<detail::NonOwningCancelableRunnableMethod<PtrType, Method>>
|
||||
NewNonOwningCancelableRunnableMethodXXX(PtrType&& aPtr, Method aMethod,
|
||||
Args&&... aArgs)
|
||||
{
|
||||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return do_AddRef(
|
||||
new detail::NonOwningCancelableRunnableMethodImpl<PtrType, Method, Storages...>
|
||||
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
}
|
||||
|
||||
template<typename... Storages, typename PtrType, typename Method, typename... Args>
|
||||
|
@ -1476,8 +1577,21 @@ NewNonOwningCancelableRunnableMethod(const char* aName, PtrType&& aPtr,
|
|||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::NonOwningCancelableRunnableMethodImpl<PtrType, Method, Storages...>(
|
||||
NewNonOwningCancelableRunnableMethodXXX<Storages...>
|
||||
(Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...), aName);
|
||||
}
|
||||
|
||||
template<typename... Storages,
|
||||
typename PtrType,
|
||||
typename Method,
|
||||
typename... Args>
|
||||
already_AddRefed<detail::IdleRunnableMethod<PtrType, Method>>
|
||||
NewIdleRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
|
||||
{
|
||||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return do_AddRef(
|
||||
new detail::IdleRunnableMethodImpl<PtrType, Method, Storages...>(
|
||||
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
}
|
||||
|
||||
|
@ -1494,8 +1608,22 @@ NewIdleRunnableMethod(const char* aName,
|
|||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::IdleRunnableMethodImpl<PtrType, Method, Storages...>(
|
||||
NewIdleRunnableMethodXXX<Storages...>(
|
||||
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...),
|
||||
aName);
|
||||
}
|
||||
|
||||
template<typename... Storages,
|
||||
typename PtrType,
|
||||
typename Method,
|
||||
typename... Args>
|
||||
already_AddRefed<detail::NonOwningIdleRunnableMethod<PtrType, Method>>
|
||||
NewNonOwningIdleRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
|
||||
{
|
||||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return do_AddRef(
|
||||
new detail::NonOwningIdleRunnableMethodImpl<PtrType, Method, Storages...>(
|
||||
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
}
|
||||
|
||||
|
@ -1512,9 +1640,9 @@ NewNonOwningIdleRunnableMethod(const char* aName,
|
|||
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||
"<Storages...> size should be equal to number of arguments");
|
||||
return detail::SetRunnableName(
|
||||
aName,
|
||||
new detail::NonOwningIdleRunnableMethodImpl<PtrType, Method, Storages...>(
|
||||
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
|
||||
NewNonOwningIdleRunnableMethodXXX<Storages...>(
|
||||
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...),
|
||||
aName);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче