Bug 1352924 - Block creation of new GMPs once parent process begins shutdown. r=gerald

This ensures that when we've started shutdown we don't try to start up new
GMPs. Doing so would create more connections from the content process to the
main process, and the main process can't shutdown until all such connections
are shut down.

MozReview-Commit-ID: KE8nCoLXjdd

--HG--
extra : rebase_source : 674f3c4ddcb5bb93dd775a861b425d25510871e9
This commit is contained in:
Chris Pearce 2017-04-03 11:08:06 +12:00
Родитель f1b6111764
Коммит f41e5c06d9
4 изменённых файлов: 44 добавлений и 0 удалений

Просмотреть файл

@ -293,6 +293,13 @@ GeckoMediaPluginServiceChild::UpdateGMPCapabilities(nsTArray<GMPCapabilityData>&
}
}
void
GeckoMediaPluginServiceChild::BeginShutdown()
{
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
mShuttingDownOnGMPThread = true;
}
NS_IMETHODIMP
GeckoMediaPluginServiceChild::HasPluginForAPI(const nsACString& aAPI,
nsTArray<nsCString>* aTags,
@ -374,6 +381,13 @@ GeckoMediaPluginServiceChild::GetServiceChild()
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
if (!mServiceChild) {
if (mShuttingDownOnGMPThread) {
// We have begun shutdown. Don't allow a new connection to the main
// process to be instantiated. This also prevents new plugins being
// instantiated.
return GetServiceChildPromise::CreateAndReject(NS_ERROR_FAILURE,
__func__);
}
dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
if (!contentChild) {
return GetServiceChildPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
@ -515,5 +529,23 @@ GMPServiceChild::Create(Endpoint<PGMPServiceChild>&& aGMPService)
return NS_SUCCEEDED(rv);
}
ipc::IPCResult
GMPServiceChild::RecvBeginShutdown()
{
RefPtr<GeckoMediaPluginServiceChild> service =
GeckoMediaPluginServiceChild::GetSingleton();
MOZ_ASSERT(service && service->mServiceChild.get() == this);
if (service) {
service->BeginShutdown();
}
return IPC_OK();
}
bool
GMPServiceChild::HaveContentParents() const
{
return mContentParents.Count() > 0;
}
} // namespace gmp
} // namespace mozilla

Просмотреть файл

@ -42,6 +42,8 @@ public:
static void UpdateGMPCapabilities(nsTArray<mozilla::dom::GMPCapabilityData>&& aCapabilities);
void BeginShutdown();
protected:
void InitializePlugins(AbstractThread*) override
{
@ -85,6 +87,10 @@ public:
static bool Create(Endpoint<PGMPServiceChild>&& aGMPService);
ipc::IPCResult RecvBeginShutdown() override;
bool HaveContentParents() const;
private:
nsRefPtrHashtable<nsUint64HashKey, GMPContentParent> mContentParents;
};

Просмотреть файл

@ -468,6 +468,10 @@ GeckoMediaPluginServiceParent::UnloadPlugins()
// Move all plugins references to a local array. This way mMutex won't be
// locked when calling CloseActive (to avoid inter-locking).
Swap(plugins, mPlugins);
for (GMPServiceParent* parent : mServiceParents) {
Unused << parent->SendBeginShutdown();
}
}
LOGD(("%s::%s plugins:%" PRIuSIZE, __CLASS__, __FUNCTION__,

Просмотреть файл

@ -36,6 +36,8 @@ parent:
sync GetGMPNodeId(nsString origin, nsString topLevelOrigin, nsString gmpName)
returns (nsCString id);
child:
async BeginShutdown();
};
} // namespace gmp