Bug 1156800: Post a task to send async NPP_New result from child to parent; r=jimm

This commit is contained in:
Aaron Klotz
2015-04-27 16:07:28 -06:00
parent 0b5579d9dc
commit c8bcf590a7
3 changed files with 32 additions and 8 deletions

View File

@@ -2365,11 +2365,7 @@ PluginInstanceChild::RecvAsyncNPP_NewStream(PBrowserStreamChild* actor,
BrowserStreamChild* child = static_cast<BrowserStreamChild*>(actor); BrowserStreamChild* child = static_cast<BrowserStreamChild*>(actor);
NewStreamAsyncCall* task = new NewStreamAsyncCall(this, child, mimeType, NewStreamAsyncCall* task = new NewStreamAsyncCall(this, child, mimeType,
seekable); seekable);
{ PostChildAsyncCall(task);
MutexAutoLock lock(mAsyncCallMutex);
mPendingAsyncCalls.AppendElement(task);
}
MessageLoop::current()->PostTask(FROM_HERE, task);
return true; return true;
} }
@@ -3645,12 +3641,17 @@ void
PluginInstanceChild::AsyncCall(PluginThreadCallback aFunc, void* aUserData) PluginInstanceChild::AsyncCall(PluginThreadCallback aFunc, void* aUserData)
{ {
ChildAsyncCall* task = new ChildAsyncCall(this, aFunc, aUserData); ChildAsyncCall* task = new ChildAsyncCall(this, aFunc, aUserData);
PostChildAsyncCall(task);
}
void
PluginInstanceChild::PostChildAsyncCall(ChildAsyncCall* aTask)
{
{ {
MutexAutoLock lock(mAsyncCallMutex); MutexAutoLock lock(mAsyncCallMutex);
mPendingAsyncCalls.AppendElement(task); mPendingAsyncCalls.AppendElement(aTask);
} }
ProcessChild::message_loop()->PostTask(FROM_HERE, task); ProcessChild::message_loop()->PostTask(FROM_HERE, aTask);
} }
static PLDHashOperator static PLDHashOperator

View File

@@ -245,6 +245,8 @@ public:
void UnscheduleTimer(uint32_t id); void UnscheduleTimer(uint32_t id);
void AsyncCall(PluginThreadCallback aFunc, void* aUserData); void AsyncCall(PluginThreadCallback aFunc, void* aUserData);
// This function is a more general version of AsyncCall
void PostChildAsyncCall(ChildAsyncCall* aTask);
int GetQuirks(); int GetQuirks();

View File

@@ -2177,6 +2177,26 @@ PluginModuleChild::AnswerSyncNPP_New(PPluginInstanceChild* aActor, NPError* rv)
return true; return true;
} }
class AsyncNewResultSender : public ChildAsyncCall
{
public:
AsyncNewResultSender(PluginInstanceChild* aInstance, NPError aResult)
: ChildAsyncCall(aInstance, nullptr, nullptr)
, mResult(aResult)
{
}
void Run() override
{
RemoveFromAsyncList();
DebugOnly<bool> sendOk = mInstance->SendAsyncNPP_NewResult(mResult);
MOZ_ASSERT(sendOk);
}
private:
NPError mResult;
};
bool bool
PluginModuleChild::RecvAsyncNPP_New(PPluginInstanceChild* aActor) PluginModuleChild::RecvAsyncNPP_New(PPluginInstanceChild* aActor)
{ {
@@ -2185,7 +2205,8 @@ PluginModuleChild::RecvAsyncNPP_New(PPluginInstanceChild* aActor)
reinterpret_cast<PluginInstanceChild*>(aActor); reinterpret_cast<PluginInstanceChild*>(aActor);
AssertPluginThread(); AssertPluginThread();
NPError rv = childInstance->DoNPP_New(); NPError rv = childInstance->DoNPP_New();
childInstance->SendAsyncNPP_NewResult(rv); AsyncNewResultSender* task = new AsyncNewResultSender(childInstance, rv);
childInstance->PostChildAsyncCall(task);
return true; return true;
} }