Bug 1127374 - Make ContentParent::RecvLoadPlugin less failure prone. r=billm

This commit is contained in:
Jim Mathies 2015-01-30 10:37:03 -06:00
parent a1ee08cca3
commit 12ee8a591d
6 changed files with 23 additions and 15 deletions

View File

@ -2484,7 +2484,10 @@ ContentChild::RecvGetProfile(nsCString* aProfile)
bool
ContentChild::RecvLoadPluginResult(const uint32_t& aPluginId, const bool& aResult)
{
bool finalResult = aResult && SendConnectPluginBridge(aPluginId);
nsresult rv;
bool finalResult = aResult &&
SendConnectPluginBridge(aPluginId, &rv) &&
NS_SUCCEEDED(rv);
plugins::PluginModuleContentParent::OnLoadPluginResult(aPluginId,
finalResult);
return true;

View File

@ -975,15 +975,17 @@ static nsIDocShell* GetOpenerDocShellHelper(Element* aFrameElement)
}
bool
ContentParent::RecvLoadPlugin(const uint32_t& aPluginId)
ContentParent::RecvLoadPlugin(const uint32_t& aPluginId, nsresult* aRv)
{
return mozilla::plugins::SetupBridge(aPluginId, this);
*aRv = NS_OK;
return mozilla::plugins::SetupBridge(aPluginId, this, false, aRv);
}
bool
ContentParent::RecvConnectPluginBridge(const uint32_t& aPluginId)
ContentParent::RecvConnectPluginBridge(const uint32_t& aPluginId, nsresult* aRv)
{
return mozilla::plugins::SetupBridge(aPluginId, this, true);
*aRv = NS_OK;
return mozilla::plugins::SetupBridge(aPluginId, this, true, aRv);
}
bool

View File

@ -153,8 +153,8 @@ public:
TabId* aTabId) MOZ_OVERRIDE;
virtual bool RecvBridgeToChildProcess(const ContentParentId& aCpId) MOZ_OVERRIDE;
virtual bool RecvLoadPlugin(const uint32_t& aPluginId) MOZ_OVERRIDE;
virtual bool RecvConnectPluginBridge(const uint32_t& aPluginId) MOZ_OVERRIDE;
virtual bool RecvLoadPlugin(const uint32_t& aPluginId, nsresult* aRv) MOZ_OVERRIDE;
virtual bool RecvConnectPluginBridge(const uint32_t& aPluginId, nsresult* aRv) MOZ_OVERRIDE;
virtual bool RecvFindPlugins(const uint32_t& aPluginEpoch,
nsTArray<PluginTag>* aPlugins,
uint32_t* aNewPluginEpoch) MOZ_OVERRIDE;

View File

@ -592,7 +592,7 @@ parent:
* process. We use intr semantics here to ensure that the PluginModuleParent
* allocation message is dispatched before LoadPlugin returns.
*/
sync LoadPlugin(uint32_t pluginId);
sync LoadPlugin(uint32_t pluginId) returns (nsresult rv);
/**
* This call is used by asynchronous plugin instantiation to notify the
@ -600,7 +600,7 @@ parent:
* the specified plugin id. When this call returns, the requested bridge
* connection has been made.
*/
sync ConnectPluginBridge(uint32_t aPluginId);
sync ConnectPluginBridge(uint32_t aPluginId) returns (nsresult rv);
/**
* This call returns the set of plugins loaded in the chrome

View File

@ -17,7 +17,7 @@ namespace plugins {
bool
SetupBridge(uint32_t aPluginId, dom::ContentParent* aContentParent,
bool aForceBridgeNow = false);
bool aForceBridgeNow, nsresult* rv);
bool
FindPluginsForContent(uint32_t aPluginEpoch,

View File

@ -94,13 +94,14 @@ struct RunnableMethodTraits<mozilla::plugins::PluginModuleParent>
bool
mozilla::plugins::SetupBridge(uint32_t aPluginId,
dom::ContentParent* aContentParent,
bool aForceBridgeNow)
bool aForceBridgeNow,
nsresult* rv)
{
nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
nsRefPtr<nsNPAPIPlugin> plugin;
nsresult rv = host->GetPluginForContentProcess(aPluginId, getter_AddRefs(plugin));
if (NS_FAILED(rv)) {
return false;
*rv = host->GetPluginForContentProcess(aPluginId, getter_AddRefs(plugin));
if (NS_FAILED(*rv)) {
return true;
}
PluginModuleChromeParent* chromeParent = static_cast<PluginModuleChromeParent*>(plugin->GetLibrary());
chromeParent->SetContentParent(aContentParent);
@ -293,7 +294,9 @@ PluginModuleContentParent::LoadModule(uint32_t aPluginId)
* its module mapping. We fetch it from there after LoadPlugin finishes.
*/
dom::ContentChild* cp = dom::ContentChild::GetSingleton();
if (!cp->SendLoadPlugin(aPluginId)) {
nsresult rv;
if (!cp->SendLoadPlugin(aPluginId, &rv) ||
NS_FAILED(rv)) {
return nullptr;
}