Bug 544945, part 2: Periodically unblock the parent to allow it to process events while the plugin subprocess is in a nested event loop. r=karlt

This commit is contained in:
Chris Jones
2010-02-16 12:44:25 -06:00
parent 03f40b0810
commit 5c1338abf5
4 changed files with 43 additions and 1 deletions

View File

@@ -45,6 +45,7 @@
#include "nsContentUtils.h"
#include "nsCRT.h"
#include "nsNPAPIPlugin.h"
#include "nsThreadUtils.h"
using base::KillProcess;
@@ -837,3 +838,35 @@ PluginModuleParent::AnswerNPN_GetValue_WithBoolReturn(const NPNVariable& aVariab
*aBoolVal = boolVal ? true : false;
return true;
}
#if !defined(MOZ_WIDGET_GTK2)
bool
PluginModuleParent::AnswerProcessSomeEvents()
{
NS_RUNTIMEABORT("unreached");
return false;
}
#else
static const int kMaxChancesToProcessEvents = 20;
bool
PluginModuleParent::AnswerProcessSomeEvents()
{
PLUGIN_LOG_DEBUG(("Spinning mini nested loop ..."));
// XXX it would seem sensical to make the condition be
// |NS_HasPendingEvents() && i < kMaxEventsToProcess|. The
// problem is, the native appshell is just an observer of our
// nsThread, and processes native events as a side effect of
// nsThread::ProcessNextEvent(). Since native events are the ones
// we really care about here, we need to go straight to
// NS_ProcessNextEvent().
for (int i = 0; i < kMaxChancesToProcessEvents; ++i)
NS_ProcessNextEvent(nsnull, PR_FALSE);
PLUGIN_LOG_DEBUG(("... quitting mini nested loop"));
return true;
}
#endif