Bug 998863: Asynchronous Plugin Initialization, Part 9: PluginModuleParent changes; r=jimm

This commit is contained in:
Aaron Klotz 2014-12-29 16:13:54 -07:00
parent d9fc63ab86
commit 66e006ee8b
9 changed files with 816 additions and 178 deletions

View File

@ -951,7 +951,7 @@ mozilla::plugins::PPluginModuleParent*
ContentChild::AllocPPluginModuleParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess)
{
return plugins::PluginModuleContentParent::Create(aTransport, aOtherProcess);
return plugins::PluginModuleContentParent::Initialize(aTransport, aOtherProcess);
}
PContentBridgeChild*
@ -2474,6 +2474,21 @@ ContentChild::RecvGetProfile(nsCString* aProfile)
return true;
}
bool
ContentChild::RecvLoadPluginResult(const uint32_t& aPluginId, const bool& aResult)
{
plugins::PluginModuleContentParent::OnLoadPluginResult(aPluginId, aResult);
return true;
}
bool
ContentChild::RecvAssociatePluginId(const uint32_t& aPluginId,
const base::ProcessId& aProcessId)
{
plugins::PluginModuleContentParent::AssociatePluginId(aPluginId, aProcessId);
return true;
}
PBrowserOrId
ContentChild::GetBrowserOrId(TabChild* aTabChild)
{

View File

@ -362,6 +362,11 @@ public:
virtual bool RecvOnAppThemeChanged() MOZ_OVERRIDE;
virtual bool RecvAssociatePluginId(const uint32_t& aPluginId,
const base::ProcessId& aProcessId) MOZ_OVERRIDE;
virtual bool RecvLoadPluginResult(const uint32_t& aPluginId,
const bool& aResult) MOZ_OVERRIDE;
virtual bool RecvStartProfiler(const uint32_t& aEntries,
const double& aInterval,
const nsTArray<nsCString>& aFeatures,

View File

@ -59,6 +59,7 @@ using struct ChromePackage from "mozilla/chrome/RegistryMessageUtils.h";
using struct ResourceMapping from "mozilla/chrome/RegistryMessageUtils.h";
using struct OverrideMapping from "mozilla/chrome/RegistryMessageUtils.h";
using base::ChildPrivileges from "base/process_util.h";
using base::ProcessId from "base/process.h";
using struct IPC::Permission from "mozilla/net/NeckoMessageUtils.h";
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
@ -518,6 +519,19 @@ child:
*/
OnAppThemeChanged();
/**
* Called during plugin initialization to map a plugin id to a child process
* id.
*/
async AssociatePluginId(uint32_t aPluginId, ProcessId aProcessId);
/**
* This call is used by async plugin initialization to notify the
* PluginModuleContentParent that the PluginModuleChromeParent's async
* init has completed.
*/
async LoadPluginResult(uint32_t aPluginId, bool aResult);
/**
* Control the Gecko Profiler in the child process.
*/

View File

@ -167,11 +167,7 @@ PluginInstanceParent::AllocPBrowserStreamParent(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyParent* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t *stype)
const nsCString& headers)
{
NS_RUNTIMEABORT("Not reachable");
return nullptr;

View File

@ -74,11 +74,8 @@ public:
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyParent* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t *stype) MOZ_OVERRIDE;
const nsCString& headers)
MOZ_OVERRIDE;
virtual bool
DeallocPBrowserStreamParent(PBrowserStreamParent* stream) MOZ_OVERRIDE;

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,7 @@ namespace plugins {
//-----------------------------------------------------------------------------
class BrowserStreamParent;
class PluginAsyncSurrogate;
class PluginInstanceParent;
#ifdef XP_WIN
@ -79,8 +80,8 @@ protected:
AllocPPluginInstanceParent(const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues,
NPError* rv) MOZ_OVERRIDE;
const InfallibleTArray<nsCString>& aValues)
MOZ_OVERRIDE;
virtual bool
DeallocPPluginInstanceParent(PPluginInstanceParent* aActor) MOZ_OVERRIDE;
@ -89,6 +90,13 @@ public:
explicit PluginModuleParent(bool aIsChrome);
virtual ~PluginModuleParent();
bool RemovePendingSurrogate(const nsRefPtr<PluginAsyncSurrogate>& aSurrogate);
/** @return the state of the pref that controls async plugin init */
bool IsStartingAsync() const { return mIsStartingAsync; }
/** @return whether this modules NP_Initialize has successfully completed
executing */
bool IsInitialized() const { return mNPInitialized; }
bool IsChrome() const { return mIsChrome; }
virtual void SetPlugin(nsNPAPIPlugin* plugin) MOZ_OVERRIDE
@ -108,6 +116,8 @@ public:
void ProcessRemoteNativeEventsInInterruptCall();
virtual bool WaitForIPCConnection() { return true; }
nsCString GetHistogramKey() const {
return mPluginName + mPluginVersion;
}
@ -159,8 +169,11 @@ protected:
virtual bool
RecvNPN_ReloadPlugins(const bool& aReloadPages) MOZ_OVERRIDE;
static PluginInstanceParent* InstCast(NPP instance);
static BrowserStreamParent* StreamCast(NPP instance, NPStream* s);
virtual bool
RecvNP_InitializeResult(const NPError& aError) MOZ_OVERRIDE;
static BrowserStreamParent* StreamCast(NPP instance, NPStream* s,
PluginAsyncSurrogate** aSurrogate = nullptr);
protected:
virtual void UpdatePluginTimeout() {}
@ -169,6 +182,11 @@ protected:
void SetPluginFuncs(NPPluginFuncs* aFuncs);
nsresult NPP_NewInternal(NPMIMEType pluginType, NPP instance, uint16_t mode,
InfallibleTArray<nsCString>& names,
InfallibleTArray<nsCString>& values,
NPSavedData* saved, NPError* error);
// NPP-like API that Gecko calls are trampolined into. These
// messages then get forwarded along to the plugin instance,
// and then eventually the child process.
@ -235,8 +253,11 @@ protected:
virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor);
#endif
void InitAsyncSurrogates();
protected:
void NotifyPluginCrashed();
void OnInitFailure();
bool GetSetting(NPNVariable aVariable);
void GetSettings(PluginSettings* aSettings);
@ -245,7 +266,7 @@ protected:
bool mShutdown;
bool mClearSiteDataSupported;
bool mGetSitesWithDataSupported;
const NPNetscapeFuncs* mNPNIface;
NPNetscapeFuncs* mNPNIface;
nsNPAPIPlugin* mPlugin;
ScopedMethodFactory<PluginModuleParent> mTaskFactory;
nsString mPluginDumpID;
@ -266,18 +287,29 @@ protected:
GetPluginDetails(nsACString& aPluginName, nsACString& aPluginVersion);
friend class mozilla::dom::CrashReporterParent;
friend class mozilla::plugins::PluginAsyncSurrogate;
bool mIsStartingAsync;
bool mNPInitialized;
nsTArray<nsRefPtr<PluginAsyncSurrogate>> mSurrogateInstances;
nsresult mAsyncNewRv;
NPPluginFuncs* mAsyncInitPluginFuncs;
};
class PluginModuleContentParent : public PluginModuleParent
{
public:
explicit PluginModuleContentParent();
static PluginLibrary* LoadModule(uint32_t aPluginId);
static PluginModuleContentParent* Create(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess);
static PluginModuleContentParent* Initialize(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess);
static void OnLoadPluginResult(const uint32_t& aPluginId, const bool& aResult);
static void AssociatePluginId(uint32_t aPluginId, base::ProcessId aProcessId);
private:
explicit PluginModuleContentParent();
#ifdef MOZ_CRASHREPORTER_INJECTOR
void OnCrash(DWORD processID) MOZ_OVERRIDE {}
@ -313,6 +345,17 @@ class PluginModuleChromeParent
OnHangUIContinue();
#endif // XP_WIN
virtual bool WaitForIPCConnection() MOZ_OVERRIDE;
virtual bool
RecvNP_InitializeResult(const NPError& aError) MOZ_OVERRIDE;
void
SetContentParent(dom::ContentParent* aContentParent);
bool
SendAssociatePluginId();
void CachedSettingChanged();
private:
@ -341,8 +384,14 @@ private:
PluginProcessParent* Process() const { return mSubprocess; }
base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
#if !defined(XP_UNIX) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GONK)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error);
#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) MOZ_OVERRIDE;
#else
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) MOZ_OVERRIDE;
#endif
#if defined(XP_WIN) || defined(XP_MACOSX)
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) MOZ_OVERRIDE;
#endif
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
@ -421,17 +470,45 @@ private:
#endif
friend class mozilla::dom::CrashReporterParent;
friend class mozilla::plugins::PluginAsyncSurrogate;
#ifdef MOZ_CRASHREPORTER_INJECTOR
void InitializeInjector();
void OnCrash(DWORD processID) MOZ_OVERRIDE;
DWORD mFlashProcess1;
DWORD mFlashProcess2;
#endif
void OnProcessLaunched(const bool aSucceeded);
class LaunchedTask : public LaunchCompleteTask
{
public:
explicit LaunchedTask(PluginModuleChromeParent* aModule)
: mModule(aModule)
{
MOZ_ASSERT(aModule);
}
void Run() MOZ_OVERRIDE
{
mModule->OnProcessLaunched(mLaunchSucceeded);
}
private:
PluginModuleChromeParent* mModule;
};
friend class LaunchedTask;
bool mInitOnAsyncConnect;
nsresult mAsyncInitRv;
NPError mAsyncInitError;
dom::ContentParent* mContentParent;
nsCOMPtr<nsIObserver> mOfflineObserver;
bool mIsFlashPlugin;
};
} // namespace plugins

View File

@ -129,6 +129,7 @@ PluginProcessParent::OnChannelConnected(int32_t peer_pid)
{
GeckoChildProcessHost::OnChannelConnected(peer_pid);
if (mLaunchCompleteTask && !mRunCompleteTaskImmediately) {
mLaunchCompleteTask->SetLaunchSucceeded();
mMainMsgLoop->PostTask(FROM_HERE, mLaunchCompleteTask.release());
}
}

View File

@ -2367,6 +2367,8 @@ pref("dom.ipc.plugins.reportCrashURL", true);
// Defaults to 30 seconds.
pref("dom.ipc.plugins.unloadTimeoutSecs", 30);
pref("dom.ipc.plugins.asyncInit", false);
pref("dom.ipc.processCount", 1);
// Enable caching of Moz2D Path objects for SVG geometry elements