Bug 1372405 - Remove NewRunnable functions that lack a name param (r=froydnj)

MozReview-Commit-ID: vGCnkBey03
This commit is contained in:
Bill McCloskey 2017-06-15 13:30:27 -07:00
parent b37fc62051
commit 78272721a6

View File

@ -477,12 +477,16 @@ using RunnableFunctionImpl =
template <typename T>
inline already_AddRefed<T>
SetRunnableName(already_AddRefed<T>&& aObj, const char* aName)
SetRunnableName(const char* aName, T* aObj)
{
#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
@ -575,20 +579,14 @@ ToSupports(mozilla::Runnable *p)
template<typename Function>
already_AddRefed<mozilla::Runnable>
NS_NewRunnableFunctionXXX(Function&& aFunction)
NS_NewRunnableFunction(const char* aName, 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(
NS_NewRunnableFunctionXXX(mozilla::Forward<Function>(aFunction)), aName);
aName,
new mozilla::detail::RunnableFunctionImpl<Function>(
mozilla::Forward<Function>(aFunction)));
}
namespace mozilla {
@ -1341,30 +1339,14 @@ 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(
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));
aName,
new detail::OwningRunnableMethodImpl<PtrType, Method>(
Forward<PtrType>(aPtr), aMethod));
}
template<typename PtrType, typename Method>
@ -1372,15 +1354,9 @@ already_AddRefed<detail::CancelableRunnableMethod<PtrType, Method>>
NewCancelableRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
{
return detail::SetRunnableName(
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));
aName,
new detail::CancelableRunnableMethodImpl<PtrType, Method>(
Forward<PtrType>(aPtr), aMethod));
}
template<typename PtrType, typename Method>
@ -1388,15 +1364,9 @@ already_AddRefed<detail::IdleRunnableMethod<PtrType, Method>>
NewIdleRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
{
return detail::SetRunnableName(
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));
aName,
new detail::IdleRunnableMethodImpl<PtrType, Method>(
Forward<PtrType>(aPtr), aMethod));
}
template<typename PtrType, typename Method>
@ -1406,17 +1376,9 @@ NewIdleRunnableMethodWithTimer(const char* aName,
Method aMethod)
{
return detail::SetRunnableName(
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));
aName,
new detail::IdleRunnableMethodWithTimerImpl<PtrType, Method>(
Forward<PtrType>(aPtr), aMethod));
}
template<typename PtrType, typename Method>
@ -1424,16 +1386,9 @@ already_AddRefed<detail::NonOwningRunnableMethod<PtrType, Method>>
NewNonOwningRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
{
return detail::SetRunnableName(
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));
aName,
new detail::NonOwningRunnableMethodImpl<PtrType, Method>(
Forward<PtrType>(aPtr), aMethod));
}
template<typename PtrType, typename Method>
@ -1442,15 +1397,8 @@ NewNonOwningCancelableRunnableMethod(const char* aName, PtrType&& aPtr,
Method aMethod)
{
return detail::SetRunnableName(
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>(
aName,
new detail::NonOwningCancelableRunnableMethodImpl<PtrType, Method>(
Forward<PtrType>(aPtr), aMethod));
}
@ -1461,17 +1409,9 @@ NewNonOwningIdleRunnableMethod(const char* aName,
Method aMethod)
{
return detail::SetRunnableName(
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));
aName,
new detail::NonOwningIdleRunnableMethodImpl<PtrType, Method>(
Forward<PtrType>(aPtr), aMethod));
}
template<typename PtrType, typename Method>
@ -1480,26 +1420,16 @@ NewNonOwningIdleRunnableMethodWithTimer(const char* aName,
PtrType&& aPtr,
Method aMethod)
{
return detail::SetRunnableName(NewNonOwningIdleRunnableMethodWithTimerXXX(
Forward<PtrType>(aPtr), aMethod),
aName);
return detail::SetRunnableName(
aName,
new detail::NonOwningIdleRunnableMethodWithTimerImpl<PtrType, Method>(
Forward<PtrType>(aPtr), aMethod));
}
// 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)
@ -1507,19 +1437,9 @@ 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(
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)...));
aName,
new detail::OwningRunnableMethodImpl<PtrType, Method, Storages...>(
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
}
template<typename... Storages, typename PtrType, typename Method, typename... Args>
@ -1530,19 +1450,9 @@ 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(
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)...));
aName,
new detail::NonOwningRunnableMethodImpl<PtrType, Method, Storages...>(
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
}
template<typename... Storages, typename PtrType, typename Method, typename... Args>
@ -1553,20 +1463,9 @@ 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(
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)...));
aName,
new detail::CancelableRunnableMethodImpl<PtrType, Method, Storages...>(
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
}
template<typename... Storages, typename PtrType, typename Method, typename... Args>
@ -1577,21 +1476,8 @@ NewNonOwningCancelableRunnableMethod(const char* aName, PtrType&& aPtr,
static_assert(sizeof...(Storages) == sizeof...(Args),
"<Storages...> size should be equal to number of arguments");
return detail::SetRunnableName(
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...>(
aName,
new detail::NonOwningCancelableRunnableMethodImpl<PtrType, Method, Storages...>(
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
}
@ -1608,22 +1494,8 @@ NewIdleRunnableMethod(const char* aName,
static_assert(sizeof...(Storages) == sizeof...(Args),
"<Storages...> size should be equal to number of arguments");
return detail::SetRunnableName(
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...>(
aName,
new detail::IdleRunnableMethodImpl<PtrType, Method, Storages...>(
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
}
@ -1640,9 +1512,9 @@ NewNonOwningIdleRunnableMethod(const char* aName,
static_assert(sizeof...(Storages) == sizeof...(Args),
"<Storages...> size should be equal to number of arguments");
return detail::SetRunnableName(
NewNonOwningIdleRunnableMethodXXX<Storages...>(
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...),
aName);
aName,
new detail::NonOwningIdleRunnableMethodImpl<PtrType, Method, Storages...>(
Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
}
} // namespace mozilla