Bug 998863: Asynchronous Plugin Initialization, Part 8: Plugin process launch changes; r=josh

This commit is contained in:
Aaron Klotz
2014-12-24 17:56:53 -07:00
parent 8564fb65b8
commit ca2e03dcae
4 changed files with 130 additions and 32 deletions

View File

@@ -12,6 +12,7 @@
#include "mozilla/ipc/BrowserProcessSubThread.h"
#include "mozilla/plugins/PluginMessageUtils.h"
#include "mozilla/Telemetry.h"
#include "nsThreadUtils.h"
using std::vector;
using std::string;
@@ -30,7 +31,9 @@ struct RunnableMethodTraits<PluginProcessParent>
PluginProcessParent::PluginProcessParent(const std::string& aPluginFilePath) :
GeckoChildProcessHost(GeckoProcessType_Plugin),
mPluginFilePath(aPluginFilePath)
mPluginFilePath(aPluginFilePath),
mMainMsgLoop(MessageLoop::current()),
mRunCompleteTaskImmediately(false)
{
}
@@ -39,7 +42,7 @@ PluginProcessParent::~PluginProcessParent()
}
bool
PluginProcessParent::Launch(int32_t timeoutMs)
PluginProcessParent::Launch(UniquePtr<LaunchCompleteTask> aLaunchCompleteTask)
{
ProcessArchitecture currentArchitecture = base::GetCurrentProcessArchitecture();
uint32_t containerArchitectures = GetSupportedArchitecturesForProcessType(GeckoProcessType_Plugin);
@@ -74,10 +77,16 @@ PluginProcessParent::Launch(int32_t timeoutMs)
}
}
mLaunchCompleteTask = Move(aLaunchCompleteTask);
vector<string> args;
args.push_back(MungePluginDsoPath(mPluginFilePath));
Telemetry::AutoTimer<Telemetry::PLUGIN_STARTUP_MS> timer;
return SyncLaunch(args, timeoutMs, selectedArchitecture);
bool result = AsyncLaunch(args, selectedArchitecture);
if (!result) {
mLaunchCompleteTask = nullptr;
}
return result;
}
void
@@ -94,3 +103,49 @@ PluginProcessParent::Delete()
ioLoop->PostTask(FROM_HERE,
NewRunnableMethod(this, &PluginProcessParent::Delete));
}
void
PluginProcessParent::SetCallRunnableImmediately(bool aCallImmediately)
{
mRunCompleteTaskImmediately = aCallImmediately;
}
bool
PluginProcessParent::WaitUntilConnected(int32_t aTimeoutMs)
{
bool result = GeckoChildProcessHost::WaitUntilConnected(aTimeoutMs);
if (mRunCompleteTaskImmediately && mLaunchCompleteTask) {
if (result) {
mLaunchCompleteTask->SetLaunchSucceeded();
}
mLaunchCompleteTask->Run();
mLaunchCompleteTask = nullptr;
}
return result;
}
void
PluginProcessParent::OnChannelConnected(int32_t peer_pid)
{
GeckoChildProcessHost::OnChannelConnected(peer_pid);
if (mLaunchCompleteTask && !mRunCompleteTaskImmediately) {
mMainMsgLoop->PostTask(FROM_HERE, mLaunchCompleteTask.release());
}
}
void
PluginProcessParent::OnChannelError()
{
GeckoChildProcessHost::OnChannelError();
if (mLaunchCompleteTask && !mRunCompleteTaskImmediately) {
mMainMsgLoop->PostTask(FROM_HERE, mLaunchCompleteTask.release());
}
}
bool
PluginProcessParent::IsConnected()
{
mozilla::MonitorAutoLock lock(mMonitor);
return mProcessState == PROCESS_CONNECTED;
}