зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1044408: enable crashing all GMP plugins on a pref strobe r=cpearce,ted
This commit is contained in:
Родитель
7eadb0bce0
Коммит
5ac6a9600f
|
@ -271,5 +271,12 @@ GMPChild::RecvPGMPDecryptorConstructor(PGMPDecryptorChild* aActor)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
GMPChild::RecvCrashPluginNow()
|
||||
{
|
||||
abort();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace gmp
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -47,6 +47,8 @@ private:
|
|||
virtual bool DeallocPGMPDecryptorChild(PGMPDecryptorChild* aActor) MOZ_OVERRIDE;
|
||||
virtual bool RecvPGMPDecryptorConstructor(PGMPDecryptorChild* aActor) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool RecvCrashPluginNow() MOZ_OVERRIDE;
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
||||
virtual void ProcessingError(Result aWhat) MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -101,6 +101,14 @@ GMPParent::Init(GeckoMediaPluginService *aService, nsIFile* aPluginDir)
|
|||
return ReadGMPMetaData();
|
||||
}
|
||||
|
||||
void
|
||||
GMPParent::Crash()
|
||||
{
|
||||
if (mState != GMPStateNotLoaded) {
|
||||
unused << SendCrashPluginNow();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
GMPParent::LoadProcess()
|
||||
{
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
nsresult Init(GeckoMediaPluginService *aService, nsIFile* aPluginDir);
|
||||
nsresult CloneFrom(const GMPParent* aOther);
|
||||
|
||||
void Crash();
|
||||
|
||||
nsresult LoadProcess();
|
||||
|
||||
// Called internally to close this if we don't need it
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "GMPVideoDecoderParent.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "GeckoChildProcessHost.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
#include "nsXPCOMPrivate.h"
|
||||
|
@ -145,6 +146,11 @@ GeckoMediaPluginService::Init()
|
|||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false)));
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID, false)));
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
prefs->AddObserver("media.gmp.plugin.crash", this, false);
|
||||
}
|
||||
|
||||
// Kick off scanning for plugins
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
unused << GetThread(getter_AddRefs(thread));
|
||||
|
@ -155,7 +161,26 @@ GeckoMediaPluginService::Observe(nsISupports* aSubject,
|
|||
const char* aTopic,
|
||||
const char16_t* aSomeData)
|
||||
{
|
||||
if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) {
|
||||
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
||||
nsCOMPtr<nsIPrefBranch> branch( do_QueryInterface(aSubject) );
|
||||
if (branch) {
|
||||
bool crashNow = false;
|
||||
if (NS_LITERAL_STRING("media.gmp.plugin.crash").Equals(aSomeData)) {
|
||||
branch->GetBoolPref("media.gmp.plugin.crash", &crashNow);
|
||||
}
|
||||
if (crashNow) {
|
||||
nsCOMPtr<nsIThread> gmpThread;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
gmpThread = mGMPThread;
|
||||
}
|
||||
if (gmpThread) {
|
||||
gmpThread->Dispatch(WrapRunnable(this, &GeckoMediaPluginService::CrashPlugins),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) {
|
||||
nsCOMPtr<nsIThread> gmpThread;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
@ -340,6 +365,17 @@ GeckoMediaPluginService::UnloadPlugins()
|
|||
mPlugins.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
GeckoMediaPluginService::CrashPlugins()
|
||||
{
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
|
||||
|
||||
MutexAutoLock lock(mMutex);
|
||||
for (uint32_t i = 0; i < mPlugins.Length(); i++) {
|
||||
mPlugins[i]->Crash();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GeckoMediaPluginService::LoadFromEnvironment()
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ private:
|
|||
const nsTArray<nsCString>& aTags);
|
||||
|
||||
void UnloadPlugins();
|
||||
void CrashPlugins();
|
||||
|
||||
void LoadFromEnvironment();
|
||||
void ProcessPossiblePlugin(nsIFile* aDir);
|
||||
|
|
|
@ -27,6 +27,8 @@ child:
|
|||
async PGMPDecryptor();
|
||||
async PGMPVideoDecoder();
|
||||
async PGMPVideoEncoder();
|
||||
|
||||
async CrashPluginNow();
|
||||
};
|
||||
|
||||
} // namespace gmp
|
||||
|
|
Загрузка…
Ссылка в новой задаче