mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1268313: Part 3 - Replace some NewCancelableRunnableMethod with NS_NewNonOwningCancelableRunnableMethod. r=froydnj
This commit is contained in:
parent
72c9966484
commit
a13954d079
@ -112,13 +112,6 @@ static const TCHAR kPluginIgnoreSubclassProperty[] = TEXT("PluginIgnoreSubclassP
|
|||||||
#include "PluginUtilsOSX.h"
|
#include "PluginUtilsOSX.h"
|
||||||
#endif // defined(XP_MACOSX)
|
#endif // defined(XP_MACOSX)
|
||||||
|
|
||||||
template<>
|
|
||||||
struct RunnableMethodTraits<PluginInstanceChild>
|
|
||||||
{
|
|
||||||
static void RetainCallee(PluginInstanceChild* obj) { }
|
|
||||||
static void ReleaseCallee(PluginInstanceChild* obj) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We can't use gfxPlatform::CreateDrawTargetForSurface() because calling
|
* We can't use gfxPlatform::CreateDrawTargetForSurface() because calling
|
||||||
* gfxPlatform::GetPlatform() instantiates the prefs service, and that's not
|
* gfxPlatform::GetPlatform() instantiates the prefs service, and that's not
|
||||||
@ -3299,11 +3292,8 @@ PluginInstanceChild::RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
|
|||||||
// RPC call, and both Flash and Java don't expect to receive setwindow calls
|
// RPC call, and both Flash and Java don't expect to receive setwindow calls
|
||||||
// at arbitrary times.
|
// at arbitrary times.
|
||||||
mCurrentAsyncSetWindowTask =
|
mCurrentAsyncSetWindowTask =
|
||||||
NewCancelableRunnableMethod<PluginInstanceChild,
|
NS_NewNonOwningCancelableRunnableMethodWithArgs<gfxSurfaceType, NPRemoteWindow, bool>
|
||||||
void (PluginInstanceChild::*)(const gfxSurfaceType&, const NPRemoteWindow&, bool),
|
(this, &PluginInstanceChild::DoAsyncSetWindow, aSurfaceType, aWindow, true);
|
||||||
const gfxSurfaceType&, const NPRemoteWindow&, bool>
|
|
||||||
(this, &PluginInstanceChild::DoAsyncSetWindow,
|
|
||||||
aSurfaceType, aWindow, true);
|
|
||||||
RefPtr<Runnable> addrefedTask = mCurrentAsyncSetWindowTask;
|
RefPtr<Runnable> addrefedTask = mCurrentAsyncSetWindowTask;
|
||||||
MessageLoop::current()->PostTask(addrefedTask.forget());
|
MessageLoop::current()->PostTask(addrefedTask.forget());
|
||||||
|
|
||||||
@ -4223,7 +4213,7 @@ PluginInstanceChild::AsyncShowPluginFrame(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mCurrentInvalidateTask =
|
mCurrentInvalidateTask =
|
||||||
NewCancelableRunnableMethod(this, &PluginInstanceChild::InvalidateRectDelayed);
|
NS_NewNonOwningCancelableRunnableMethod(this, &PluginInstanceChild::InvalidateRectDelayed);
|
||||||
RefPtr<Runnable> addrefedTask = mCurrentInvalidateTask;
|
RefPtr<Runnable> addrefedTask = mCurrentInvalidateTask;
|
||||||
MessageLoop::current()->PostTask(addrefedTask.forget());
|
MessageLoop::current()->PostTask(addrefedTask.forget());
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,6 @@ public:
|
|||||||
template<class U>
|
template<class U>
|
||||||
friend struct mozilla::RefPtrTraits;
|
friend struct mozilla::RefPtrTraits;
|
||||||
|
|
||||||
template<class U>
|
|
||||||
friend struct ::RunnableMethodTraits;
|
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
friend class ::mozilla::gl::RefSet;
|
friend class ::mozilla::gl::RefSet;
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ ImageBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
|
|||||||
mSubprocess = nullptr;
|
mSubprocess = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageLoop::current()->PostTask(
|
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ImageBridgeParent::DeferredDestroy);
|
||||||
NewRunnableMethod(this, &ImageBridgeParent::DeferredDestroy));
|
MessageLoop::current()->PostTask(runnable.forget());
|
||||||
|
|
||||||
// It is very important that this method gets called at shutdown (be it a clean
|
// It is very important that this method gets called at shutdown (be it a clean
|
||||||
// or an abnormal shutdown), because DeferredDestroy is what clears mSelfRef.
|
// or an abnormal shutdown), because DeferredDestroy is what clears mSelfRef.
|
||||||
|
@ -101,13 +101,6 @@ using mozilla::dom::ScriptSettingsInitialized;
|
|||||||
using mozilla::MonitorAutoLock;
|
using mozilla::MonitorAutoLock;
|
||||||
using mozilla::MonitorAutoUnlock;
|
using mozilla::MonitorAutoUnlock;
|
||||||
|
|
||||||
template<>
|
|
||||||
struct RunnableMethodTraits<mozilla::ipc::MessageChannel>
|
|
||||||
{
|
|
||||||
static void RetainCallee(mozilla::ipc::MessageChannel* obj) { }
|
|
||||||
static void ReleaseCallee(mozilla::ipc::MessageChannel* obj) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
#define IPC_ASSERT(_cond, ...) \
|
#define IPC_ASSERT(_cond, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (!(_cond)) \
|
if (!(_cond)) \
|
||||||
@ -502,13 +495,13 @@ MessageChannel::MessageChannel(MessageListener *aListener)
|
|||||||
mIsSyncWaitingOnNonMainThread = false;
|
mIsSyncWaitingOnNonMainThread = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mDequeueOneTask = new RefCountedTask(NewCancelableRunnableMethod(
|
RefPtr<CancelableRunnable> runnable =
|
||||||
this,
|
NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnMaybeDequeueOne);
|
||||||
&MessageChannel::OnMaybeDequeueOne));
|
mDequeueOneTask = new RefCountedTask(runnable.forget());
|
||||||
|
|
||||||
mOnChannelConnectedTask = new RefCountedTask(NewCancelableRunnableMethod(
|
runnable = NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::DispatchOnChannelConnected);
|
||||||
this,
|
|
||||||
&MessageChannel::DispatchOnChannelConnected));
|
mOnChannelConnectedTask = new RefCountedTask(runnable.forget());
|
||||||
|
|
||||||
#ifdef OS_WIN
|
#ifdef OS_WIN
|
||||||
mEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr);
|
mEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr);
|
||||||
@ -2094,7 +2087,7 @@ MessageChannel::OnNotifyMaybeChannelError()
|
|||||||
|
|
||||||
if (IsOnCxxStack()) {
|
if (IsOnCxxStack()) {
|
||||||
mChannelErrorTask =
|
mChannelErrorTask =
|
||||||
NewCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError);
|
NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError);
|
||||||
RefPtr<Runnable> task = mChannelErrorTask;
|
RefPtr<Runnable> task = mChannelErrorTask;
|
||||||
// 10 ms delay is completely arbitrary
|
// 10 ms delay is completely arbitrary
|
||||||
mWorkerLoop->PostDelayedTask(task.forget(), 10);
|
mWorkerLoop->PostDelayedTask(task.forget(), 10);
|
||||||
@ -2114,7 +2107,7 @@ MessageChannel::PostErrorNotifyTask()
|
|||||||
|
|
||||||
// This must be the last code that runs on this thread!
|
// This must be the last code that runs on this thread!
|
||||||
mChannelErrorTask =
|
mChannelErrorTask =
|
||||||
NewCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError);
|
NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError);
|
||||||
RefPtr<Runnable> task = mChannelErrorTask;
|
RefPtr<Runnable> task = mChannelErrorTask;
|
||||||
mWorkerLoop->PostTask(task.forget());
|
mWorkerLoop->PostTask(task.forget());
|
||||||
}
|
}
|
||||||
|
@ -283,8 +283,11 @@ nsRunnableFunction<Function>* NS_NewRunnableFunction(const Function& aFunction)
|
|||||||
// with nsRevocableEventPtr.
|
// with nsRevocableEventPtr.
|
||||||
template<class ClassType,
|
template<class ClassType,
|
||||||
typename ReturnType = void,
|
typename ReturnType = void,
|
||||||
bool Owning = true>
|
bool Owning = true,
|
||||||
class nsRunnableMethod : public mozilla::Runnable
|
bool Cancelable = false>
|
||||||
|
class nsRunnableMethod : public mozilla::Conditional<!Cancelable,
|
||||||
|
mozilla::Runnable,
|
||||||
|
mozilla::CancelableRunnable>::Type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Revoke() = 0;
|
virtual void Revoke() = 0;
|
||||||
@ -328,31 +331,34 @@ struct nsRunnableMethodReceiver<ClassType, false>
|
|||||||
void Revoke() { mObj = nullptr; }
|
void Revoke() { mObj = nullptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Method, bool Owning> struct nsRunnableMethodTraits;
|
template<typename Method, bool Owning, bool Cancelable> struct nsRunnableMethodTraits;
|
||||||
|
|
||||||
template<class C, typename R, bool Owning, typename... As>
|
template<class C, typename R, bool Owning, bool Cancelable, typename... As>
|
||||||
struct nsRunnableMethodTraits<R(C::*)(As...), Owning>
|
struct nsRunnableMethodTraits<R(C::*)(As...), Owning, Cancelable>
|
||||||
{
|
{
|
||||||
typedef C class_type;
|
typedef C class_type;
|
||||||
typedef R return_type;
|
typedef R return_type;
|
||||||
typedef nsRunnableMethod<C, R, Owning> base_type;
|
typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type;
|
||||||
|
static const bool can_cancel = Cancelable;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef NS_HAVE_STDCALL
|
#ifdef NS_HAVE_STDCALL
|
||||||
template<class C, typename R, bool Owning, typename... As>
|
template<class C, typename R, bool Owning, bool Cancelable, typename... As>
|
||||||
struct nsRunnableMethodTraits<R(__stdcall C::*)(As...), Owning>
|
struct nsRunnableMethodTraits<R(__stdcall C::*)(As...), Owning, Cancelable>
|
||||||
{
|
{
|
||||||
typedef C class_type;
|
typedef C class_type;
|
||||||
typedef R return_type;
|
typedef R return_type;
|
||||||
typedef nsRunnableMethod<C, R, Owning> base_type;
|
typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type;
|
||||||
|
static const bool can_cancel = Cancelable;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class C, typename R, bool Owning>
|
template<class C, typename R, bool Owning, bool Cancelable>
|
||||||
struct nsRunnableMethodTraits<R(NS_STDCALL C::*)(), Owning>
|
struct nsRunnableMethodTraits<R(NS_STDCALL C::*)(), Owning, Cancelable>
|
||||||
{
|
{
|
||||||
typedef C class_type;
|
typedef C class_type;
|
||||||
typedef R return_type;
|
typedef R return_type;
|
||||||
typedef nsRunnableMethod<C, R, Owning> base_type;
|
typedef nsRunnableMethod<C, R, Owning, Cancelable> base_type;
|
||||||
|
static const bool can_cancel = Cancelable;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -683,11 +689,11 @@ struct nsRunnableMethodArguments
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Method, bool Owning, typename... Storages>
|
template<typename Method, bool Owning, bool Cancelable, typename... Storages>
|
||||||
class nsRunnableMethodImpl
|
class nsRunnableMethodImpl
|
||||||
: public nsRunnableMethodTraits<Method, Owning>::base_type
|
: public nsRunnableMethodTraits<Method, Owning, Cancelable>::base_type
|
||||||
{
|
{
|
||||||
typedef typename nsRunnableMethodTraits<Method, Owning>::class_type
|
typedef typename nsRunnableMethodTraits<Method, Owning, Cancelable>::class_type
|
||||||
ClassType;
|
ClassType;
|
||||||
nsRunnableMethodReceiver<ClassType, Owning> mReceiver;
|
nsRunnableMethodReceiver<ClassType, Owning> mReceiver;
|
||||||
Method mMethod;
|
Method mMethod;
|
||||||
@ -710,6 +716,11 @@ public:
|
|||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
nsresult Cancel() {
|
||||||
|
static_assert(Cancelable, "Don't use me!");
|
||||||
|
Revoke();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
void Revoke() { mReceiver.Revoke(); }
|
void Revoke() { mReceiver.Revoke(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -724,17 +735,24 @@ public:
|
|||||||
// - MyClass must defined AddRef and Release methods
|
// - MyClass must defined AddRef and Release methods
|
||||||
//
|
//
|
||||||
template<typename PtrType, typename Method>
|
template<typename PtrType, typename Method>
|
||||||
typename nsRunnableMethodTraits<Method, true>::base_type*
|
typename nsRunnableMethodTraits<Method, true, false>::base_type*
|
||||||
NS_NewRunnableMethod(PtrType aPtr, Method aMethod)
|
NS_NewRunnableMethod(PtrType aPtr, Method aMethod)
|
||||||
{
|
{
|
||||||
return new nsRunnableMethodImpl<Method, true>(aPtr, aMethod);
|
return new nsRunnableMethodImpl<Method, true, false>(aPtr, aMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PtrType, typename Method>
|
template<typename PtrType, typename Method>
|
||||||
typename nsRunnableMethodTraits<Method, false>::base_type*
|
typename nsRunnableMethodTraits<Method, false, false>::base_type*
|
||||||
NS_NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod)
|
NS_NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod)
|
||||||
{
|
{
|
||||||
return new nsRunnableMethodImpl<Method, false>(aPtr, aMethod);
|
return new nsRunnableMethodImpl<Method, false, false>(aPtr, aMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename PtrType, typename Method>
|
||||||
|
typename nsRunnableMethodTraits<Method, false, true>::base_type*
|
||||||
|
NS_NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod)
|
||||||
|
{
|
||||||
|
return new nsRunnableMethodImpl<Method, false, true>(aPtr, aMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar to NS_NewRunnableMethod. Call like so:
|
// Similar to NS_NewRunnableMethod. Call like so:
|
||||||
@ -742,10 +760,10 @@ NS_NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod)
|
|||||||
// NS_NewRunnableMethodWithArg<Type>(myObject, &MyClass::HandleEvent, myArg);
|
// NS_NewRunnableMethodWithArg<Type>(myObject, &MyClass::HandleEvent, myArg);
|
||||||
// 'Type' is the stored type for the argument, see ParameterStorage for details.
|
// 'Type' is the stored type for the argument, see ParameterStorage for details.
|
||||||
template<typename Storage, typename Method, typename PtrType, typename Arg>
|
template<typename Storage, typename Method, typename PtrType, typename Arg>
|
||||||
typename nsRunnableMethodTraits<Method, true>::base_type*
|
typename nsRunnableMethodTraits<Method, true, false>::base_type*
|
||||||
NS_NewRunnableMethodWithArg(PtrType&& aPtr, Method aMethod, Arg&& aArg)
|
NS_NewRunnableMethodWithArg(PtrType&& aPtr, Method aMethod, Arg&& aArg)
|
||||||
{
|
{
|
||||||
return new nsRunnableMethodImpl<Method, true, Storage>(
|
return new nsRunnableMethodImpl<Method, true, false, Storage>(
|
||||||
aPtr, aMethod, mozilla::Forward<Arg>(aArg));
|
aPtr, aMethod, mozilla::Forward<Arg>(aArg));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,23 +772,34 @@ NS_NewRunnableMethodWithArg(PtrType&& aPtr, Method aMethod, Arg&& aArg)
|
|||||||
// NS_NewRunnableMethodWithArg<Types,...>(myObject, &MyClass::HandleEvent, myArg1,...);
|
// NS_NewRunnableMethodWithArg<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 Method, typename PtrType, typename... Args>
|
template<typename... Storages, typename Method, typename PtrType, typename... Args>
|
||||||
typename nsRunnableMethodTraits<Method, true>::base_type*
|
typename nsRunnableMethodTraits<Method, true, false>::base_type*
|
||||||
NS_NewRunnableMethodWithArgs(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
|
NS_NewRunnableMethodWithArgs(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 new nsRunnableMethodImpl<Method, true, Storages...>(
|
return new nsRunnableMethodImpl<Method, true, false, Storages...>(
|
||||||
aPtr, aMethod, mozilla::Forward<Args>(aArgs)...);
|
aPtr, aMethod, mozilla::Forward<Args>(aArgs)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Storages, typename Method, typename PtrType, typename... Args>
|
template<typename... Storages, typename Method, typename PtrType, typename... Args>
|
||||||
typename nsRunnableMethodTraits<Method, false>::base_type*
|
typename nsRunnableMethodTraits<Method, false, false>::base_type*
|
||||||
NS_NewNonOwningRunnableMethodWithArgs(PtrType&& aPtr, Method aMethod,
|
NS_NewNonOwningRunnableMethodWithArgs(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 new nsRunnableMethodImpl<Method, false, Storages...>(
|
return new nsRunnableMethodImpl<Method, false, false, Storages...>(
|
||||||
|
aPtr, aMethod, mozilla::Forward<Args>(aArgs)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename... Storages, typename Method, typename PtrType, typename... Args>
|
||||||
|
typename nsRunnableMethodTraits<Method, false, true>::base_type*
|
||||||
|
NS_NewNonOwningCancelableRunnableMethodWithArgs(PtrType&& aPtr, Method aMethod,
|
||||||
|
Args&&... aArgs)
|
||||||
|
{
|
||||||
|
static_assert(sizeof...(Storages) == sizeof...(Args),
|
||||||
|
"<Storages...> size should be equal to number of arguments");
|
||||||
|
return new nsRunnableMethodImpl<Method, false, true, Storages...>(
|
||||||
aPtr, aMethod, mozilla::Forward<Args>(aArgs)...);
|
aPtr, aMethod, mozilla::Forward<Args>(aArgs)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user