Bug 1146955 - Make the GMP pluginID a uint32_t, and dispatch it in the PluginCrashed event. r=jesup r=mrbkap

--HG--
extra : rebase_source : ef8893d470e437d93a44b393f595518acb411852
extra : source : ad87e781794d5bb5337feb6e2608730075a7f71e
extra : histedit_source : 91cbbdedc9273982d0eb6b3c58269c73e0f46f63
This commit is contained in:
Mike Conley 2015-05-04 15:40:29 -04:00
parent 91457c2516
commit 97a46ed1e0
19 changed files with 63 additions and 65 deletions

View File

@ -377,22 +377,23 @@ MediaKeys::Init(ErrorResult& aRv)
class CrashHandler : public gmp::GeckoMediaPluginService::PluginCrashCallback
{
public:
CrashHandler(const nsACString& aPluginId,
CrashHandler(const uint32_t aPluginId,
nsPIDOMWindow* aParentWindow,
nsIDocument* aDocument)
: gmp::GeckoMediaPluginService::PluginCrashCallback(aPluginId)
, mPluginId(aPluginId)
, mParentWindowWeakPtr(do_GetWeakReference(aParentWindow))
, mDocumentWeakPtr(do_GetWeakReference(aDocument))
{
}
virtual void Run(const nsACString& aPluginName, const nsAString& aPluginDumpId) override
virtual void Run(const nsACString& aPluginName) override
{
PluginCrashedEventInit init;
init.mPluginID = mPluginId;
init.mBubbles = true;
init.mCancelable = true;
init.mGmpPlugin = true;
init.mPluginDumpID = aPluginDumpId;
CopyUTF8toUTF16(aPluginName, init.mPluginName);
init.mSubmittedCrashReport = false;
@ -445,12 +446,13 @@ private:
return true;
}
uint32_t mPluginId;
nsWeakPtr mParentWindowWeakPtr;
nsWeakPtr mDocumentWeakPtr;
};
void
MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const nsACString& aPluginId)
MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const uint32_t aPluginId)
{
nsRefPtr<Promise> promise(RetrievePromise(aId));
if (!promise) {
@ -468,7 +470,7 @@ MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const nsACStri
mKeySystem,
MediaKeySystemStatus::Cdm_created);
if (!aPluginId.IsEmpty()) {
if (aPluginId) {
// Prepare plugin crash reporter.
nsRefPtr<gmp::GeckoMediaPluginService> service =
gmp::GeckoMediaPluginService::GetGeckoMediaPluginService();
@ -483,8 +485,8 @@ MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const nsACStri
return;
}
service->AddPluginCrashCallback(new CrashHandler(aPluginId, mParent, doc));
EME_LOG("MediaKeys[%p]::OnCDMCreated() registered crash handler for pluginId '%s'",
this, aPluginId.Data());
EME_LOG("MediaKeys[%p]::OnCDMCreated() registered crash handler for pluginId '%i'",
this, aPluginId);
}
}

View File

@ -81,7 +81,7 @@ public:
// Called once a Init() operation succeeds.
void OnCDMCreated(PromiseId aId,
const nsACString& aNodeId, const nsACString& aPluginId);
const nsACString& aNodeId, const uint32_t aPluginId);
// Called once the CDM generates a sessionId while servicing a
// MediaKeySession.generateRequest() or MediaKeySession.load() call,

View File

@ -51,11 +51,11 @@ public:
{
return mDisplayName;
}
void SetPluginId(const nsCString& aPluginId)
void SetPluginId(const uint32_t aPluginId)
{
mPluginId = aPluginId;
}
const nsCString& GetPluginId()
const uint32_t GetPluginId()
{
return mPluginId;
}
@ -92,7 +92,7 @@ private:
nsCOMPtr<nsIThread> mGMPThread;
nsRefPtr<GMPParent> mParent;
nsCString mDisplayName;
nsCString mPluginId;
uint32_t mPluginId;
};
} // namespace gmp

View File

@ -29,7 +29,7 @@ GMPDecryptorParent::~GMPDecryptorParent()
{
}
const nsACString&
const uint32_t
GMPDecryptorParent::GetPluginId() const
{
return mPluginId;

View File

@ -29,7 +29,7 @@ public:
// GMPDecryptorProxy
virtual const nsACString& GetPluginId() const override;
virtual const uint32_t GetPluginId() const override;
virtual nsresult Init(GMPDecryptorProxyCallback* aCallback) override;
@ -113,7 +113,7 @@ private:
bool mShuttingDown;
bool mActorDestroyed;
nsRefPtr<GMPContentParent> mPlugin;
nsCString mPluginId;
uint32_t mPluginId;
GMPDecryptorProxyCallback* mCallback;
#ifdef DEBUG
nsIThread* const mGMPThread;

View File

@ -59,7 +59,7 @@ class GMPDecryptorProxy {
public:
~GMPDecryptorProxy() {}
virtual const nsACString& GetPluginId() const = 0;
virtual const uint32_t GetPluginId() const = 0;
virtual nsresult Init(GMPDecryptorProxyCallback* aCallback) = 0;

View File

@ -13,6 +13,7 @@
#include "nsCharSeparatedTokenizer.h"
#include "nsThreadUtils.h"
#include "nsIRunnable.h"
#include "nsIWritablePropertyBag2.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "mozilla/SyncRunnable.h"
@ -66,7 +67,7 @@ GMPParent::GMPParent()
#endif
{
LOGD("GMPParent ctor");
mPluginId.AppendInt(GeckoChildProcessHost::GetUniqueID());
mPluginId = GeckoChildProcessHost::GetUniqueID();
}
GMPParent::~GMPParent()
@ -499,23 +500,22 @@ GMPParent::GetCrashID(nsString& aResult)
}
static void
GMPNotifyObservers(const nsACString& aPluginId, const nsACString& aPluginName, const nsAString& aPluginDumpId)
GMPNotifyObservers(const uint32_t aPluginID, const nsACString& aPluginName, const nsAString& aPluginDumpID)
{
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
nsString id;
AppendUTF8toUTF16(aPluginId, id);
id.Append(NS_LITERAL_STRING(" "));
AppendUTF8toUTF16(aPluginName, id);
id.Append(NS_LITERAL_STRING(" "));
id.Append(aPluginDumpId);
obs->NotifyObservers(nullptr, "gmp-plugin-crash", id.Data());
nsCOMPtr<nsIWritablePropertyBag2> propbag =
do_CreateInstance("@mozilla.org/hash-property-bag;1");
if (obs && propbag) {
propbag->SetPropertyAsUint32(NS_LITERAL_STRING("pluginID"), aPluginID);
propbag->SetPropertyAsACString(NS_LITERAL_STRING("pluginName"), aPluginName);
propbag->SetPropertyAsAString(NS_LITERAL_STRING("pluginDumpID"), aPluginDumpID);
obs->NotifyObservers(propbag, "gmp-plugin-crash", nullptr);
}
nsRefPtr<gmp::GeckoMediaPluginService> service =
gmp::GeckoMediaPluginService::GetGeckoMediaPluginService();
if (service) {
service->RunPluginCrashCallbacks(aPluginId, aPluginName, aPluginDumpId);
service->RunPluginCrashCallbacks(aPluginID, aPluginName);
}
}
#endif
@ -820,7 +820,7 @@ GMPParent::GetVersion() const
return mVersion;
}
const nsCString&
const uint32_t
GMPParent::GetPluginId() const
{
return mPluginId;

View File

@ -123,7 +123,7 @@ public:
const nsCString& GetDisplayName() const;
const nsCString& GetVersion() const;
const nsCString& GetPluginId() const;
const uint32_t GetPluginId() const;
// Returns true if a plugin can be or is being used across multiple NodeIds.
bool CanBeSharedCrossNodeIds() const;
@ -192,7 +192,7 @@ private:
nsCString mDisplayName; // name of plugin displayed to users
nsCString mDescription; // description of plugin for display to users
nsCString mVersion;
nsCString mPluginId;
uint32_t mPluginId;
nsTArray<nsAutoPtr<GMPCapability>> mCapabilities;
GMPProcessParent* mProcess;
bool mDeleteProcessOnlyOnUnload;

View File

@ -165,9 +165,8 @@ GeckoMediaPluginService::RemoveObsoletePluginCrashCallbacks()
for (size_t i = mPluginCrashCallbacks.Length(); i != 0; --i) {
nsRefPtr<PluginCrashCallback>& callback = mPluginCrashCallbacks[i - 1];
if (!callback->IsStillValid()) {
LOGD(("%s::%s - Removing obsolete callback for pluginId %s",
__CLASS__, __FUNCTION__,
PromiseFlatCString(callback->PluginId()).get()));
LOGD(("%s::%s - Removing obsolete callback for pluginId %i",
__CLASS__, __FUNCTION__, callback->PluginId()));
mPluginCrashCallbacks.RemoveElementAt(i - 1);
}
}
@ -182,7 +181,7 @@ GeckoMediaPluginService::AddPluginCrashCallback(
}
void
GeckoMediaPluginService::RemovePluginCrashCallbacks(const nsACString& aPluginId)
GeckoMediaPluginService::RemovePluginCrashCallbacks(const uint32_t aPluginId)
{
RemoveObsoletePluginCrashCallbacks();
for (size_t i = mPluginCrashCallbacks.Length(); i != 0; --i) {
@ -194,24 +193,22 @@ GeckoMediaPluginService::RemovePluginCrashCallbacks(const nsACString& aPluginId)
}
void
GeckoMediaPluginService::RunPluginCrashCallbacks(const nsACString& aPluginId,
const nsACString& aPluginName,
const nsAString& aPluginDumpId)
GeckoMediaPluginService::RunPluginCrashCallbacks(const uint32_t aPluginId,
const nsACString& aPluginName)
{
MOZ_ASSERT(NS_IsMainThread());
LOGD(("%s::%s(%s)", __CLASS__, __FUNCTION__, aPluginId.Data()));
LOGD(("%s::%s(%i)", __CLASS__, __FUNCTION__, aPluginId));
for (size_t i = mPluginCrashCallbacks.Length(); i != 0; --i) {
nsRefPtr<PluginCrashCallback>& callback = mPluginCrashCallbacks[i - 1];
const nsACString& callbackPluginId = callback->PluginId();
const uint32_t callbackPluginId = callback->PluginId();
if (!callback->IsStillValid()) {
LOGD(("%s::%s(%s) - Removing obsolete callback for pluginId %s",
__CLASS__, __FUNCTION__, aPluginId.Data(),
PromiseFlatCString(callback->PluginId()).get()));
LOGD(("%s::%s(%i) - Removing obsolete callback for pluginId %i",
__CLASS__, __FUNCTION__, aPluginId, callback->PluginId()));
mPluginCrashCallbacks.RemoveElementAt(i - 1);
} else if (callbackPluginId == aPluginId) {
LOGD(("%s::%s(%s) - Running #%u",
__CLASS__, __FUNCTION__, aPluginId.Data(), i - 1));
callback->Run(aPluginName, aPluginDumpId);
LOGD(("%s::%s(%i) - Running #%u",
__CLASS__, __FUNCTION__, aPluginId, i - 1));
callback->Run(aPluginName);
mPluginCrashCallbacks.RemoveElementAt(i - 1);
}
}

View File

@ -66,13 +66,13 @@ public:
public:
NS_INLINE_DECL_REFCOUNTING(PluginCrashCallback)
PluginCrashCallback(const nsACString& aPluginId)
PluginCrashCallback(const uint32_t aPluginId)
: mPluginId(aPluginId)
{
MOZ_ASSERT(NS_IsMainThread());
}
const nsACString& PluginId() const { return mPluginId; }
virtual void Run(const nsACString& aPluginName, const nsAString& aPluginDumpId) = 0;
const uint32_t PluginId() const { return mPluginId; }
virtual void Run(const nsACString& aPluginName) = 0;
virtual bool IsStillValid() = 0; // False if callback has become useless.
protected:
virtual ~PluginCrashCallback()
@ -80,14 +80,13 @@ public:
MOZ_ASSERT(NS_IsMainThread());
}
private:
const nsCString mPluginId;
const uint32_t mPluginId;
};
void RemoveObsoletePluginCrashCallbacks(); // Called from add/remove/run.
void AddPluginCrashCallback(nsRefPtr<PluginCrashCallback> aPluginCrashCallback);
void RemovePluginCrashCallbacks(const nsACString& aPluginId);
void RunPluginCrashCallbacks(const nsACString& aPluginId,
const nsACString& aPluginName,
const nsAString& aPluginDumpId);
void RemovePluginCrashCallbacks(const uint32_t aPluginId);
void RunPluginCrashCallbacks(const uint32_t aPluginId,
const nsACString& aPluginName);
protected:
GeckoMediaPluginService();

View File

@ -82,7 +82,7 @@ public:
base::ProcessId otherProcess;
nsCString displayName;
nsCString pluginId;
uint32_t pluginId;
bool ok = aGMPServiceChild->SendLoadGMP(mNodeId, mAPI, mTags,
alreadyBridgedTo, &otherProcess,
&displayName, &pluginId);

View File

@ -1435,7 +1435,7 @@ GMPServiceParent::RecvLoadGMP(const nsCString& aNodeId,
nsTArray<ProcessId>&& aAlreadyBridgedTo,
ProcessId* aId,
nsCString* aDisplayName,
nsCString* aPluginId)
uint32_t* aPluginId)
{
nsRefPtr<GMPParent> gmp = mService->SelectPluginForAPI(aNodeId, aAPI, aTags);

View File

@ -193,7 +193,7 @@ public:
nsTArray<ProcessId>&& aAlreadyBridgedTo,
base::ProcessId* aID,
nsCString* aDisplayName,
nsCString* aPluginId) override;
uint32_t* aPluginId) override;
virtual bool RecvGetGMPNodeId(const nsString& aOrigin,
const nsString& aTopLevelOrigin,
const bool& aInPrivateBrowsing,

View File

@ -46,7 +46,7 @@ public:
virtual GMPErr SetChannelParameters(uint32_t aPacketLoss, uint32_t aRTT) = 0;
virtual GMPErr SetRates(uint32_t aNewBitRate, uint32_t aFrameRate) = 0;
virtual GMPErr SetPeriodicKeyFrames(bool aEnable) = 0;
virtual const uint64_t ParentID() = 0;
virtual const uint32_t ParentID() = 0;
// Call to tell GMP/plugin the consumer will no longer use this
// interface/codec.

View File

@ -17,7 +17,7 @@ sync protocol PGMPService
parent:
sync LoadGMP(nsCString nodeId, nsCString api, nsCString[] tags,
ProcessId[] alreadyBridgedTo)
returns (ProcessId id, nsCString displayName, nsCString pluginId);
returns (ProcessId id, nsCString displayName, uint32_t pluginId);
sync GetGMPNodeId(nsString origin, nsString topLevelOrigin,
bool inPrivateBrowsing)
returns (nsCString id);

View File

@ -63,7 +63,7 @@ interface PeerConnectionImpl {
void close();
/* Notify DOM window if this plugin crash is ours. */
boolean pluginCrash(unsigned long long pluginId, DOMString name, DOMString pluginDumpID);
boolean pluginCrash(unsigned long long pluginId, DOMString name);
/* Attributes */
[Constant]

View File

@ -7,6 +7,7 @@
[Constructor(DOMString type, optional PluginCrashedEventInit eventInitDict), ChromeOnly]
interface PluginCrashedEvent : Event
{
readonly attribute unsigned long pluginID;
readonly attribute DOMString pluginDumpID;
readonly attribute DOMString pluginName;
readonly attribute DOMString? browserDumpID;
@ -17,6 +18,7 @@ interface PluginCrashedEvent : Event
dictionary PluginCrashedEventInit : EventInit
{
unsigned long pluginID = 0;
DOMString pluginDumpID = "";
DOMString pluginName = "";
DOMString? browserDumpID = null;

View File

@ -2290,9 +2290,8 @@ PeerConnectionImpl::Close()
}
bool
PeerConnectionImpl::PluginCrash(uint64_t aPluginID,
const nsAString& aPluginName,
const nsAString& aPluginDumpID)
PeerConnectionImpl::PluginCrash(uint32_t aPluginID,
const nsAString& aPluginName)
{
// fire an event to the DOM window if this is "ours"
bool result = mMedia ? mMedia->AnyCodecHasPluginID(aPluginID) : false;
@ -2310,7 +2309,7 @@ PeerConnectionImpl::PluginCrash(uint64_t aPluginID,
}
PluginCrashedEventInit init;
init.mPluginDumpID = aPluginDumpID;
init.mPluginID = aPluginID;
init.mPluginName = aPluginName;
init.mSubmittedCrashReport = false;
init.mGmpPlugin = true;

View File

@ -526,9 +526,8 @@ public:
rv = Close();
}
bool PluginCrash(uint64_t aPluginID,
const nsAString& aPluginName,
const nsAString& aPluginDumpID);
bool PluginCrash(uint32_t aPluginID,
const nsAString& aPluginName);
nsresult InitializeDataChannel();