Bug 1333915, part 1 - Don't open the channel in CommonInit. r=jimm
The next patch will open the channel differently in each case, so move
that code into the callers.
MozReview-Commit-ID: 4zkLTcoZhUu
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -163,46 +163,40 @@ PluginModuleChild::GetChrome()
{
// A special PluginModuleChild instance that talks to the chrome process
// during startup and shutdown. Synchronous messages to or from this actor
// should be avoided because they may lead to hangs.
MOZ_ASSERT(gChromeInstance);
return gChromeInstance;
}
-bool
-PluginModuleChild::CommonInit(base::ProcessId aParentPid,
- MessageLoop* aIOLoop,
- IPC::Channel* aChannel)
+void
+PluginModuleChild::CommonInit()
{
PLUGIN_LOG_DEBUG_METHOD;
// Request Windows message deferral behavior on our channel. This
// applies to the top level and all sub plugin protocols since they
// all share the same channel.
// Bug 1090573 - Don't do this for connections to content processes.
GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
- if (!Open(aChannel, aParentPid, aIOLoop)) {
- return false;
- }
-
memset((void*) &mFunctions, 0, sizeof(mFunctions));
mFunctions.size = sizeof(mFunctions);
mFunctions.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
-
- return true;
}
bool
PluginModuleChild::InitForContent(base::ProcessId aParentPid,
MessageLoop* aIOLoop,
IPC::Channel* aChannel)
{
- if (!CommonInit(aParentPid, aIOLoop, aChannel)) {
+ CommonInit();
+
+ if (!Open(aChannel, aParentPid, aIOLoop)) {
return false;
}
mLibrary = GetChrome()->mLibrary;
mFunctions = GetChrome()->mFunctions;
return true;
}
@@ -272,17 +266,19 @@ PluginModuleChild::InitForChrome(const s
#endif
{
nsresult rv = pluginFile.LoadPlugin(&mLibrary);
if (NS_FAILED(rv))
return false;
}
NS_ASSERTION(mLibrary, "couldn't open shared object");
- if (!CommonInit(aParentPid, aIOLoop, aChannel)) {
+ CommonInit();
+
+ if (!Open(aChannel, aParentPid, aIOLoop)) {
return false;
}
GetIPCChannel()->SetAbortOnError(true);
// TODO: use PluginPRLibrary here
#if defined(OS_LINUX) || defined(OS_BSD)
--- a/dom/plugins/ipc/PluginModuleChild.h
+++ b/dom/plugins/ipc/PluginModuleChild.h
@@ -145,19 +145,17 @@ protected:
virtual mozilla::ipc::IPCResult RecvGatherProfile() override;
virtual mozilla::ipc::IPCResult
AnswerModuleSupportsAsyncRender(bool* aResult) override;
public:
explicit PluginModuleChild(bool aIsChrome);
virtual ~PluginModuleChild();
- bool CommonInit(base::ProcessId aParentPid,
- MessageLoop* aIOLoop,
- IPC::Channel* aChannel);
+ void CommonInit();
// aPluginFilename is UTF8, not native-charset!
bool InitForChrome(const std::string& aPluginFilename,
base::ProcessId aParentPid,
MessageLoop* aIOLoop,
IPC::Channel* aChannel);
bool InitForContent(base::ProcessId aParentPid,