Bug 1038961: Patch 1 - Send GMP plugin crashes to observer, and implement PluginID system r=cpearce,jib

This commit is contained in:
Randell Jesup 2014-07-21 03:50:09 -04:00
parent b0645f3f41
commit 4ac7943b4f
6 changed files with 45 additions and 7 deletions

View File

@ -14,6 +14,8 @@
#include "nsIRunnable.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/unused.h"
#include "nsIObserverService.h"
#include "mtransport/runnable_utils.h"
#include "mozilla/dom/CrashReporterParent.h"
using mozilla::dom::CrashReporterParent;
@ -321,16 +323,37 @@ GMPParent::GetCrashID(nsString& aResult)
}
#endif
static void
GMPNotifyObservers(nsAString& aData)
{
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
nsString temp(aData);
obs->NotifyObservers(nullptr, "gmp-plugin-crash", temp.get());
}
}
void
GMPParent::ActorDestroy(ActorDestroyReason aWhy)
{
#ifdef MOZ_CRASHREPORTER
if (AbnormalShutdown == aWhy) {
nsString dumpID;
#ifdef MOZ_CRASHREPORTER
GetCrashID(dumpID);
#endif
// now do something with the crash ID, bug 1038961
nsString id;
// use the parent address to identify it
// We could use any unique-to-the-parent value
id.AppendInt(reinterpret_cast<uint64_t>(this));
id.Append(NS_LITERAL_STRING(" "));
AppendUTF8toUTF16(mDisplayName, id);
id.Append(NS_LITERAL_STRING(" "));
id.Append(dumpID);
// NotifyObservers is mainthread-only
NS_DispatchToMainThread(WrapRunnableNM(&GMPNotifyObservers, id),
NS_DISPATCH_NORMAL);
}
#endif
// warn us off trying to close again
mState = GMPStateClosing;
CloseActive();

View File

@ -42,6 +42,7 @@ public:
virtual nsresult Reset() MOZ_OVERRIDE;
virtual nsresult Drain() MOZ_OVERRIDE;
virtual nsresult DecodingComplete() MOZ_OVERRIDE;
virtual const uint64_t ParentID() MOZ_OVERRIDE { return reinterpret_cast<uint64_t>(mPlugin.get()); }
// GMPSharedMemManager
virtual void CheckThread();

View File

@ -28,6 +28,7 @@ public:
virtual nsresult Reset() = 0;
virtual nsresult Drain() = 0;
virtual nsresult DecodingComplete() = 0;
virtual const uint64_t ParentID() = 0;
};
#endif

View File

@ -43,6 +43,7 @@ public:
virtual GMPErr SetRates(uint32_t aNewBitRate, uint32_t aFrameRate) MOZ_OVERRIDE;
virtual GMPErr SetPeriodicKeyFrames(bool aEnable) MOZ_OVERRIDE;
virtual void EncodingComplete() MOZ_OVERRIDE;
virtual const uint64_t ParentID() MOZ_OVERRIDE { return reinterpret_cast<uint64_t>(mPlugin.get()); }
// GMPSharedMemManager
virtual void CheckThread();

View File

@ -35,6 +35,7 @@ public:
virtual GMPErr SetRates(uint32_t aNewBitRate, uint32_t aFrameRate) = 0;
virtual GMPErr SetPeriodicKeyFrames(bool aEnable) = 0;
virtual void EncodingComplete() = 0;
virtual const uint64_t ParentID() = 0;
};
#endif // GMPVideoEncoderProxy_h_

View File

@ -33,17 +33,24 @@
#include "GMPVideoDecoderProxy.h"
#include "GMPVideoEncoderProxy.h"
#include "WebrtcGmpVideoCodec.h"
namespace mozilla {
class WebrtcGmpCrashReporter {
public:
virtual const uint64_t CrashID() = 0;
};
class WebrtcGmpVideoEncoder : public WebrtcVideoEncoder,
public GMPVideoEncoderCallbackProxy
public GMPVideoEncoderCallbackProxy,
public WebrtcGmpCrashReporter
{
public:
WebrtcGmpVideoEncoder();
virtual ~WebrtcGmpVideoEncoder() {}
// Implement CrashReporter
virtual const uint64_t CrashID() { return mGMP ? mGMP->ParentID() : 0; }
// Implement VideoEncoder interface.
virtual int32_t InitEncode(const webrtc::VideoCodec* aCodecSettings,
int32_t aNumberOfCores,
@ -90,12 +97,16 @@ private:
class WebrtcGmpVideoDecoder : public WebrtcVideoDecoder,
public GMPVideoDecoderCallback
public GMPVideoDecoderCallback,
public WebrtcGmpCrashReporter
{
public:
WebrtcGmpVideoDecoder();
virtual ~WebrtcGmpVideoDecoder() {}
// Implement CrashReporter
virtual const uint64_t CrashID() { return mGMP ? mGMP->ParentID() : 0; }
// Implement VideoDecoder interface.
virtual int32_t InitDecode(const webrtc::VideoCodec* aCodecSettings,
int32_t aNumberOfCores);