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
Родитель 8c169acdd7
Коммит fb8e8e334c
1 изменённых файлов: 49 добавлений и 177 удалений

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

@ -519,12 +519,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
@ -617,20 +621,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 {
@ -1383,30 +1381,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>
@ -1414,15 +1396,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>
@ -1430,15 +1406,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>
@ -1448,17 +1418,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>
@ -1466,16 +1428,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>
@ -1484,15 +1439,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));
}
@ -1503,17 +1451,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>
@ -1522,26 +1462,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)
@ -1549,19 +1479,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>
@ -1572,19 +1492,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>
@ -1595,20 +1505,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>
@ -1619,21 +1518,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)...));
}
@ -1650,22 +1536,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)...));
}
@ -1682,9 +1554,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