mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1352573 (part 1) - Convert FlashThrottleAsyncMsg from a ChildAsyncCall to a CancelableRunnable. r=bsmedberg.
This requires adding mPendingFlashThrottleMsgs to PluginInstanceChild. It also requires adding FlashThrottleMsg::mInstance, and a FlashThrottleMsg::Cancel() function that nulls mInstance. --HG-- extra : rebase_source : 87e5732ddf2ad57d4f3ff078ab66143797eac49f
This commit is contained in:
parent
6041274802
commit
2a1feb9d19
@ -2339,7 +2339,7 @@ PluginInstanceChild::SetupFlashMsgThrottle()
|
||||
}
|
||||
|
||||
WNDPROC
|
||||
PluginInstanceChild::FlashThrottleAsyncMsg::GetProc()
|
||||
PluginInstanceChild::FlashThrottleMsg::GetProc()
|
||||
{
|
||||
if (mInstance) {
|
||||
return mWindowed ? mInstance->mPluginWndProc :
|
||||
@ -2349,13 +2349,17 @@ PluginInstanceChild::FlashThrottleAsyncMsg::GetProc()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginInstanceChild::FlashThrottleAsyncMsg::Run()
|
||||
PluginInstanceChild::FlashThrottleMsg::Run()
|
||||
{
|
||||
RemoveFromAsyncList();
|
||||
if (!mInstance) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mInstance->mPendingFlashThrottleMsgs.RemoveElement(this);
|
||||
|
||||
// GetProc() checks mInstance, and pulls the procedure from
|
||||
// PluginInstanceChild. We don't transport sub-class procedure
|
||||
// ptrs around in FlashThrottleAsyncMsg msgs.
|
||||
// ptrs around in FlashThrottleMsg msgs.
|
||||
if (!GetProc())
|
||||
return NS_OK;
|
||||
|
||||
@ -2364,6 +2368,14 @@ PluginInstanceChild::FlashThrottleAsyncMsg::Run()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PluginInstanceChild::FlashThrottleMsg::Cancel()
|
||||
{
|
||||
MOZ_ASSERT(mInstance);
|
||||
mInstance = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
PluginInstanceChild::FlashThrottleMessage(HWND aWnd,
|
||||
UINT aMsg,
|
||||
@ -2371,15 +2383,13 @@ PluginInstanceChild::FlashThrottleMessage(HWND aWnd,
|
||||
LPARAM aLParam,
|
||||
bool isWindowed)
|
||||
{
|
||||
// We reuse ChildAsyncCall so we get the cancelation work
|
||||
// that's done in Destroy.
|
||||
RefPtr<FlashThrottleAsyncMsg> task =
|
||||
new FlashThrottleAsyncMsg(this, aWnd, aMsg, aWParam,
|
||||
aLParam, isWindowed);
|
||||
{
|
||||
MutexAutoLock lock(mAsyncCallMutex);
|
||||
mPendingAsyncCalls.AppendElement(task);
|
||||
}
|
||||
// We save a reference to the FlashThrottleMsg so we can cancel it in
|
||||
// Destroy if it's still alive.
|
||||
RefPtr<FlashThrottleMsg> task =
|
||||
new FlashThrottleMsg(this, aWnd, aMsg, aWParam, aLParam, isWindowed);
|
||||
|
||||
mPendingFlashThrottleMsgs.AppendElement(task);
|
||||
|
||||
MessageLoop::current()->PostDelayedTask(task.forget(),
|
||||
kFlashWMUSERMessageThrottleDelayMs);
|
||||
}
|
||||
@ -4262,6 +4272,11 @@ PluginInstanceChild::Destroy()
|
||||
DestroyWinlessPopupSurrogate();
|
||||
UnhookWinlessFlashThrottle();
|
||||
DestroyPluginWindow();
|
||||
|
||||
for (uint32_t i = 0; i < mPendingFlashThrottleMsgs.Length(); ++i) {
|
||||
mPendingFlashThrottleMsgs[i]->Cancel();
|
||||
}
|
||||
mPendingFlashThrottleMsgs.Clear();
|
||||
#endif
|
||||
|
||||
// Pending async calls are discarded, not delivered. This matches the
|
||||
|
@ -348,15 +348,13 @@ private:
|
||||
static BOOL WINAPI ImmNotifyIME(HIMC aIMC, DWORD aAction, DWORD aIndex,
|
||||
DWORD aValue);
|
||||
|
||||
class FlashThrottleAsyncMsg : public ChildAsyncCall
|
||||
class FlashThrottleMsg : public CancelableRunnable
|
||||
{
|
||||
public:
|
||||
FlashThrottleAsyncMsg();
|
||||
FlashThrottleAsyncMsg(PluginInstanceChild* aInst,
|
||||
HWND aWnd, UINT aMsg,
|
||||
WPARAM aWParam, LPARAM aLParam,
|
||||
bool isWindowed)
|
||||
: ChildAsyncCall(aInst, nullptr, nullptr),
|
||||
FlashThrottleMsg(PluginInstanceChild* aInstance, HWND aWnd, UINT aMsg,
|
||||
WPARAM aWParam, LPARAM aLParam, bool isWindowed)
|
||||
: CancelableRunnable("FlashThrottleMsg"),
|
||||
mInstance(aInstance),
|
||||
mWnd(aWnd),
|
||||
mMsg(aMsg),
|
||||
mWParam(aWParam),
|
||||
@ -365,6 +363,7 @@ private:
|
||||
{}
|
||||
|
||||
NS_IMETHOD Run() override;
|
||||
nsresult Cancel() override;
|
||||
|
||||
WNDPROC GetProc();
|
||||
HWND GetWnd() { return mWnd; }
|
||||
@ -373,6 +372,7 @@ private:
|
||||
LPARAM GetLParam() { return mLParam; }
|
||||
|
||||
private:
|
||||
PluginInstanceChild* mInstance;
|
||||
HWND mWnd;
|
||||
UINT mMsg;
|
||||
WPARAM mWParam;
|
||||
@ -450,6 +450,9 @@ private:
|
||||
|
||||
friend class ChildAsyncCall;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
nsTArray<FlashThrottleMsg*> mPendingFlashThrottleMsgs;
|
||||
#endif
|
||||
Mutex mAsyncCallMutex;
|
||||
nsTArray<ChildAsyncCall*> mPendingAsyncCalls;
|
||||
nsTArray<nsAutoPtr<ChildTimer> > mTimers;
|
||||
|
Loading…
Reference in New Issue
Block a user