Backed out 2 changesets (bug 1397123) for Android build bustage

Backed out changeset 803c2d6f4be4 (bug 1397123)
Backed out changeset 2d41a6eb4df4 (bug 1397123)

MozReview-Commit-ID: A45nVCrhbQA
This commit is contained in:
Phil Ringnalda 2017-09-11 20:23:22 -07:00
Родитель 7f896e1985
Коммит 2387b87164
9 изменённых файлов: 176 добавлений и 374 удалений

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

@ -175,7 +175,7 @@ public:
// Main thread only.
virtual void OnSessionMessage(const nsAString& aSessionId,
dom::MediaKeyMessageType aMessageType,
const nsTArray<uint8_t>& aMessage) = 0;
nsTArray<uint8_t>& aMessage) = 0;
// Main thread only.
virtual void OnExpirationChange(const nsAString& aSessionId,

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

@ -1,52 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef ChromiumCDMCallback_h_
#define ChromiumCDMCallback_h_
#include "mozilla/CDMProxy.h"
#include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus
#include "mozilla/dom/MediaKeyMessageEventBinding.h" // For MediaKeyMessageType
#include "mozilla/gmp/GMPTypes.h" // For CDMKeyInformation
class ChromiumCDMCallback {
public:
virtual ~ChromiumCDMCallback() {}
virtual void SetSessionId(uint32_t aPromiseId,
const nsCString& aSessionId) = 0;
virtual void ResolveLoadSessionPromise(uint32_t aPromiseId,
bool aSuccessful) = 0;
virtual void ResolvePromise(uint32_t aPromiseId) = 0;
virtual void RejectPromise(uint32_t aPromiseId,
nsresult aError,
const nsCString& aErrorMessage) = 0;
virtual void SessionMessage(const nsACString& aSessionId,
uint32_t aMessageType,
nsTArray<uint8_t>&& aMessage) = 0;
virtual void SessionKeysChange(const nsCString& aSessionId,
nsTArray<mozilla::gmp::CDMKeyInformation>&& aKeysInfo) = 0;
virtual void ExpirationChange(const nsCString& aSessionId,
double aSecondsSinceEpoch) = 0;
virtual void SessionClosed(const nsCString& aSessionId) = 0;
virtual void LegacySessionError(const nsCString& aSessionId,
nsresult aError,
uint32_t aSystemCode,
const nsCString& aMessage) = 0;
virtual void Terminated() = 0;
virtual void Shutdown() = 0;
};
#endif

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

@ -1,188 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ChromiumCDMCallbackProxy.h"
#include "ChromiumCDMProxy.h"
#include "content_decryption_module.h"
namespace mozilla {
template<class Func, class... Args>
void ChromiumCDMCallbackProxy::DispatchToMainThread(const char* const aLabel,
Func aFunc,
Args&&... aArgs)
{
mMainThread->Dispatch(
// Use Decay to ensure all the types are passed by value not by reference.
NewRunnableMethod<typename Decay<Args>::Type...>(
aLabel,
mProxy,
aFunc,
Forward<Args>(aArgs)...),
NS_DISPATCH_NORMAL);
}
void
ChromiumCDMCallbackProxy::SetSessionId(uint32_t aPromiseId,
const nsCString& aSessionId)
{
DispatchToMainThread("ChromiumCDMProxy::OnSetSessionId",
&ChromiumCDMProxy::OnSetSessionId,
aPromiseId,
NS_ConvertUTF8toUTF16(aSessionId));
}
void
ChromiumCDMCallbackProxy::ResolveLoadSessionPromise(uint32_t aPromiseId,
bool aSuccessful)
{
DispatchToMainThread("ChromiumCDMProxy::OnResolveLoadSessionPromise",
&ChromiumCDMProxy::OnResolveLoadSessionPromise,
aPromiseId,
aSuccessful);
}
void
ChromiumCDMCallbackProxy::ResolvePromise(uint32_t aPromiseId)
{
DispatchToMainThread("ChromiumCDMProxy::ResolvePromise",
&ChromiumCDMProxy::ResolvePromise,
aPromiseId);
}
void
ChromiumCDMCallbackProxy::RejectPromise(uint32_t aPromiseId,
nsresult aError,
const nsCString& aErrorMessage)
{
DispatchToMainThread("ChromiumCDMProxy::RejectPromise",
&ChromiumCDMProxy::RejectPromise,
aPromiseId,
aError,
aErrorMessage);
}
static dom::MediaKeyMessageType
ToDOMMessageType(uint32_t aMessageType)
{
switch (static_cast<cdm::MessageType>(aMessageType)) {
case cdm::kLicenseRequest:
return dom::MediaKeyMessageType::License_request;
case cdm::kLicenseRenewal:
return dom::MediaKeyMessageType::License_renewal;
case cdm::kLicenseRelease:
return dom::MediaKeyMessageType::License_release;
}
MOZ_ASSERT_UNREACHABLE("Invalid cdm::MessageType enum value.");
return dom::MediaKeyMessageType::License_request;
}
void
ChromiumCDMCallbackProxy::SessionMessage(const nsACString& aSessionId,
uint32_t aMessageType,
nsTArray<uint8_t>&& aMessage)
{
DispatchToMainThread("ChromiumCDMProxy::OnSessionMessage",
&ChromiumCDMProxy::OnSessionMessage,
NS_ConvertUTF8toUTF16(aSessionId),
ToDOMMessageType(aMessageType),
Move(aMessage));
}
static dom::MediaKeyStatus
ToDOMMediaKeyStatus(uint32_t aStatus)
{
switch (static_cast<cdm::KeyStatus>(aStatus)) {
case cdm::kUsable:
return dom::MediaKeyStatus::Usable;
case cdm::kInternalError:
return dom::MediaKeyStatus::Internal_error;
case cdm::kExpired:
return dom::MediaKeyStatus::Expired;
case cdm::kOutputRestricted:
return dom::MediaKeyStatus::Output_restricted;
case cdm::kOutputDownscaled:
return dom::MediaKeyStatus::Output_downscaled;
case cdm::kStatusPending:
return dom::MediaKeyStatus::Status_pending;
case cdm::kReleased:
return dom::MediaKeyStatus::Released;
}
MOZ_ASSERT_UNREACHABLE("Invalid cdm::KeyStatus enum value.");
return dom::MediaKeyStatus::Internal_error;
}
void
ChromiumCDMCallbackProxy::SessionKeysChange(const nsCString& aSessionId,
nsTArray<mozilla::gmp::CDMKeyInformation> && aKeysInfo)
{
bool keyStatusesChange = false;
{
CDMCaps::AutoLock caps(mProxy->Capabilites());
for (const auto& keyInfo : aKeysInfo) {
keyStatusesChange |=
caps.SetKeyStatus(keyInfo.mKeyId(),
NS_ConvertUTF8toUTF16(aSessionId),
dom::Optional<dom::MediaKeyStatus>(
ToDOMMediaKeyStatus(keyInfo.mStatus())));
}
}
if (keyStatusesChange) {
DispatchToMainThread("ChromiumCDMProxy::OnKeyStatusesChange",
&ChromiumCDMProxy::OnKeyStatusesChange,
NS_ConvertUTF8toUTF16(aSessionId));
}
}
void
ChromiumCDMCallbackProxy::ExpirationChange(const nsCString& aSessionId,
double aSecondsSinceEpoch)
{
DispatchToMainThread("ChromiumCDMProxy::OnExpirationChange",
&ChromiumCDMProxy::OnExpirationChange,
NS_ConvertUTF8toUTF16(aSessionId),
UnixTime(aSecondsSinceEpoch * 1000));
}
void
ChromiumCDMCallbackProxy::SessionClosed(const nsCString& aSessionId)
{
DispatchToMainThread("ChromiumCDMProxy::OnSessionClosed",
&ChromiumCDMProxy::OnSessionClosed ,
NS_ConvertUTF8toUTF16(aSessionId));
}
void
ChromiumCDMCallbackProxy::LegacySessionError(const nsCString& aSessionId,
nsresult aError,
uint32_t aSystemCode,
const nsCString& aMessage)
{
DispatchToMainThread("ChromiumCDMProxy::OnSessionError",
&ChromiumCDMProxy::OnSessionError ,
NS_ConvertUTF8toUTF16(aSessionId),
aError,
aSystemCode,
NS_ConvertUTF8toUTF16(aMessage));
}
void
ChromiumCDMCallbackProxy::Terminated()
{
DispatchToMainThread("ChromiumCDMProxy::Terminated",
&ChromiumCDMProxy::Terminated);
}
void
ChromiumCDMCallbackProxy::Shutdown()
{
DispatchToMainThread("ChromiumCDMProxy::Shutdown",
&ChromiumCDMProxy::Shutdown);
}
} //namespace mozilla

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

@ -1,68 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef ChromiumCDMCallbackProxy_h_
#define ChromiumCDMCallbackProxy_h_
#include "ChromiumCDMCallback.h"
#include "ChromiumCDMProxy.h"
#include "nsThreadUtils.h"
namespace mozilla {
class ChromiumCDMCallbackProxy : public ChromiumCDMCallback {
public:
ChromiumCDMCallbackProxy(ChromiumCDMProxy* aProxy,
nsIEventTarget* aMainThread)
: mProxy(aProxy), mMainThread(aMainThread)
{
}
void SetSessionId(uint32_t aPromiseId,
const nsCString& aSessionId) override;
void ResolveLoadSessionPromise(uint32_t aPromiseId,
bool aSuccessful) override;
void ResolvePromise(uint32_t aPromiseId) override;
void RejectPromise(uint32_t aPromiseId,
nsresult aError,
const nsCString& aErrorMessage) override;
void SessionMessage(const nsACString& aSessionId,
uint32_t aMessageType,
nsTArray<uint8_t>&& aMessage) override;
void SessionKeysChange(const nsCString& aSessionId,
nsTArray<mozilla::gmp::CDMKeyInformation>&& aKeysInfo) override;
void ExpirationChange(const nsCString& aSessionId,
double aSecondsSinceEpoch) override;
void SessionClosed(const nsCString& aSessionId) override;
void LegacySessionError(const nsCString& aSessionId,
nsresult aError,
uint32_t aSystemCode,
const nsCString& aMessage) override;
void Terminated() override;
void Shutdown() override;
private:
template<class Func, class... Args>
void DispatchToMainThread(const char* const aLabel,
Func aFunc,
Args&&... aArgs);
// Warning: Weak ref.
ChromiumCDMProxy* mProxy;
const nsCOMPtr<nsIEventTarget> mMainThread;
};
} //namespace mozilla
#endif

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

@ -5,8 +5,6 @@
#include "ChromiumCDMParent.h"
#include "ChromiumCDMCallback.h"
#include "ChromiumCDMCallbackProxy.h"
#include "ChromiumCDMProxy.h"
#include "content_decryption_module.h"
#include "GMPContentChild.h"
@ -42,16 +40,16 @@ ChromiumCDMParent::ChromiumCDMParent(GMPContentParent* aContentParent,
}
bool
ChromiumCDMParent::Init(ChromiumCDMCallback* aCDMCallback,
ChromiumCDMParent::Init(ChromiumCDMProxy* aProxy,
bool aAllowDistinctiveIdentifier,
bool aAllowPersistentState,
nsIEventTarget* aMainThread)
{
GMP_LOG("ChromiumCDMParent::Init(this=%p)", this);
if (!aCDMCallback || !aMainThread) {
if (!aProxy || !aMainThread) {
return false;
}
mCDMCallback = aCDMCallback;
mProxy = aProxy;
mMainThread = aMainThread;
return SendInit(aAllowDistinctiveIdentifier, aAllowPersistentState);
}
@ -281,7 +279,7 @@ ChromiumCDMParent::RecvOnResolveNewSessionPromise(const uint32_t& aPromiseId,
this,
aPromiseId,
aSessionId.get());
if (!mCDMCallback || mIsShutdown) {
if (!mProxy || mIsShutdown) {
return IPC_OK();
}
@ -293,7 +291,13 @@ ChromiumCDMParent::RecvOnResolveNewSessionPromise(const uint32_t& aPromiseId,
return IPC_OK();
}
mCDMCallback->SetSessionId(token.value(), aSessionId);
mMainThread->Dispatch(
NewRunnableMethod<uint32_t, nsString>("ChromiumCDMProxy::OnSetSessionId",
mProxy,
&ChromiumCDMProxy::OnSetSessionId,
token.value(),
NS_ConvertUTF8toUTF16(aSessionId)),
NS_DISPATCH_NORMAL);
ResolvePromise(aPromiseId);
@ -309,15 +313,21 @@ ChromiumCDMParent::RecvResolveLoadSessionPromise(const uint32_t& aPromiseId,
this,
aPromiseId,
aSuccessful);
if (!mCDMCallback || mIsShutdown) {
if (!mProxy || mIsShutdown) {
return IPC_OK();
}
mCDMCallback->ResolveLoadSessionPromise(aPromiseId, aSuccessful);
mMainThread->Dispatch(
NewRunnableMethod<uint32_t, bool>(
"ChromiumCDMProxy::OnResolveLoadSessionPromise",
mProxy,
&ChromiumCDMProxy::OnResolveLoadSessionPromise,
aPromiseId,
aSuccessful),
NS_DISPATCH_NORMAL);
return IPC_OK();
}
void
ChromiumCDMParent::ResolvePromise(uint32_t aPromiseId)
{
@ -326,11 +336,16 @@ ChromiumCDMParent::ResolvePromise(uint32_t aPromiseId)
// Note: The MediaKeys rejects all pending DOM promises when it
// initiates shutdown.
if (!mCDMCallback || mIsShutdown) {
if (!mProxy || mIsShutdown) {
return;
}
mCDMCallback->ResolvePromise(aPromiseId);
mMainThread->Dispatch(
NewRunnableMethod<uint32_t>("ChromiumCDMProxy::ResolvePromise",
mProxy,
&ChromiumCDMProxy::ResolvePromise,
aPromiseId),
NS_DISPATCH_NORMAL);
}
ipc::IPCResult
@ -340,22 +355,6 @@ ChromiumCDMParent::RecvOnResolvePromise(const uint32_t& aPromiseId)
return IPC_OK();
}
void
ChromiumCDMParent::RejectPromise(uint32_t aPromiseId,
nsresult aError,
const nsCString& aErrorMessage)
{
GMP_LOG(
"ChromiumCDMParent::RejectPromise(this=%p, pid=%u)", this, aPromiseId);
// Note: The MediaKeys rejects all pending DOM promises when it
// initiates shutdown.
if (!mCDMCallback || mIsShutdown) {
return;
}
mCDMCallback->RejectPromise(aPromiseId, aError, aErrorMessage);
}
static nsresult
ToNsresult(uint32_t aError)
{
@ -383,6 +382,30 @@ ToNsresult(uint32_t aError)
return NS_ERROR_DOM_TIMEOUT_ERR; // Note: Unique placeholder.
}
void
ChromiumCDMParent::RejectPromise(uint32_t aPromiseId,
nsresult aError,
const nsCString& aErrorMessage)
{
GMP_LOG(
"ChromiumCDMParent::RejectPromise(this=%p, pid=%u)", this, aPromiseId);
// Note: The MediaKeys rejects all pending DOM promises when it
// initiates shutdown.
if (!mProxy || mIsShutdown) {
return;
}
mMainThread->Dispatch(
NewRunnableMethod<uint32_t, nsresult, nsCString>(
"ChromiumCDMProxy::RejectPromise",
mProxy,
&ChromiumCDMProxy::RejectPromise,
aPromiseId,
aError,
aErrorMessage),
NS_DISPATCH_NORMAL);
}
ipc::IPCResult
ChromiumCDMParent::RecvOnRejectPromise(const uint32_t& aPromiseId,
const uint32_t& aError,
@ -393,6 +416,21 @@ ChromiumCDMParent::RecvOnRejectPromise(const uint32_t& aPromiseId,
return IPC_OK();
}
static dom::MediaKeyMessageType
ToDOMMessageType(uint32_t aMessageType)
{
switch (static_cast<cdm::MessageType>(aMessageType)) {
case cdm::kLicenseRequest:
return dom::MediaKeyMessageType::License_request;
case cdm::kLicenseRenewal:
return dom::MediaKeyMessageType::License_renewal;
case cdm::kLicenseRelease:
return dom::MediaKeyMessageType::License_release;
}
MOZ_ASSERT_UNREACHABLE("Invalid cdm::MessageType enum value.");
return dom::MediaKeyMessageType::License_request;
}
ipc::IPCResult
ChromiumCDMParent::RecvOnSessionMessage(const nsCString& aSessionId,
const uint32_t& aMessageType,
@ -401,25 +439,74 @@ ChromiumCDMParent::RecvOnSessionMessage(const nsCString& aSessionId,
GMP_LOG("ChromiumCDMParent::RecvOnSessionMessage(this=%p, sid=%s)",
this,
aSessionId.get());
if (!mCDMCallback || mIsShutdown) {
if (!mProxy || mIsShutdown) {
return IPC_OK();
}
RefPtr<CDMProxy> proxy = mProxy;
nsString sid = NS_ConvertUTF8toUTF16(aSessionId);
dom::MediaKeyMessageType messageType = ToDOMMessageType(aMessageType);
nsTArray<uint8_t> msg(Move(aMessage));
mCDMCallback->SessionMessage(aSessionId, aMessageType, Move(aMessage));
mMainThread->Dispatch(
NS_NewRunnableFunction("gmp::ChromiumCDMParent::RecvOnSessionMessage",
[proxy, sid, messageType, msg]() mutable {
proxy->OnSessionMessage(sid, messageType, msg);
}),
NS_DISPATCH_NORMAL);
return IPC_OK();
}
static dom::MediaKeyStatus
ToDOMMediaKeyStatus(uint32_t aStatus)
{
switch (static_cast<cdm::KeyStatus>(aStatus)) {
case cdm::kUsable:
return dom::MediaKeyStatus::Usable;
case cdm::kInternalError:
return dom::MediaKeyStatus::Internal_error;
case cdm::kExpired:
return dom::MediaKeyStatus::Expired;
case cdm::kOutputRestricted:
return dom::MediaKeyStatus::Output_restricted;
case cdm::kOutputDownscaled:
return dom::MediaKeyStatus::Output_downscaled;
case cdm::kStatusPending:
return dom::MediaKeyStatus::Status_pending;
case cdm::kReleased:
return dom::MediaKeyStatus::Released;
}
MOZ_ASSERT_UNREACHABLE("Invalid cdm::KeyStatus enum value.");
return dom::MediaKeyStatus::Internal_error;
}
ipc::IPCResult
ChromiumCDMParent::RecvOnSessionKeysChange(
const nsCString& aSessionId,
nsTArray<CDMKeyInformation>&& aKeysInfo)
{
GMP_LOG("ChromiumCDMParent::RecvOnSessionKeysChange(this=%p)", this);
if (!mCDMCallback || mIsShutdown) {
if (!mProxy || mIsShutdown) {
return IPC_OK();
}
mCDMCallback->SessionKeysChange(aSessionId, Move(aKeysInfo));
bool keyStatusesChange = false;
{
CDMCaps::AutoLock caps(mProxy->Capabilites());
for (size_t i = 0; i < aKeysInfo.Length(); i++) {
keyStatusesChange |=
caps.SetKeyStatus(aKeysInfo[i].mKeyId(),
NS_ConvertUTF8toUTF16(aSessionId),
dom::Optional<dom::MediaKeyStatus>(
ToDOMMediaKeyStatus(aKeysInfo[i].mStatus())));
}
}
if (keyStatusesChange) {
mMainThread->Dispatch(
NewRunnableMethod<nsString>("ChromiumCDMProxy::OnKeyStatusesChange",
mProxy,
&ChromiumCDMProxy::OnKeyStatusesChange,
NS_ConvertUTF8toUTF16(aSessionId)),
NS_DISPATCH_NORMAL);
}
return IPC_OK();
}
@ -430,11 +517,18 @@ ChromiumCDMParent::RecvOnExpirationChange(const nsCString& aSessionId,
GMP_LOG("ChromiumCDMParent::RecvOnExpirationChange(this=%p) time=%lf",
this,
aSecondsSinceEpoch);
if (!mCDMCallback || mIsShutdown) {
if (!mProxy || mIsShutdown) {
return IPC_OK();
}
mCDMCallback->ExpirationChange(aSessionId, aSecondsSinceEpoch);
mMainThread->Dispatch(
NewRunnableMethod<nsString, UnixTime>(
"ChromiumCDMProxy::OnExpirationChange",
mProxy,
&ChromiumCDMProxy::OnExpirationChange,
NS_ConvertUTF8toUTF16(aSessionId),
GMPTimestamp(aSecondsSinceEpoch * 1000)),
NS_DISPATCH_NORMAL);
return IPC_OK();
}
@ -442,11 +536,16 @@ ipc::IPCResult
ChromiumCDMParent::RecvOnSessionClosed(const nsCString& aSessionId)
{
GMP_LOG("ChromiumCDMParent::RecvOnSessionClosed(this=%p)", this);
if (!mCDMCallback || mIsShutdown) {
if (!mProxy || mIsShutdown) {
return IPC_OK();
}
mCDMCallback->SessionClosed(aSessionId);
mMainThread->Dispatch(
NewRunnableMethod<nsString>("ChromiumCDMProxy::OnSessionClosed",
mProxy,
&ChromiumCDMProxy::OnSessionClosed,
NS_ConvertUTF8toUTF16(aSessionId)),
NS_DISPATCH_NORMAL);
return IPC_OK();
}
@ -457,12 +556,20 @@ ChromiumCDMParent::RecvOnLegacySessionError(const nsCString& aSessionId,
const nsCString& aMessage)
{
GMP_LOG("ChromiumCDMParent::RecvOnLegacySessionError(this=%p)", this);
if (!mCDMCallback || mIsShutdown) {
if (!mProxy || mIsShutdown) {
return IPC_OK();
}
mCDMCallback->LegacySessionError(
aSessionId, ToNsresult(aError), aSystemCode, aMessage);
mMainThread->Dispatch(
NewRunnableMethod<nsString, nsresult, uint32_t, nsString>(
"ChromiumCDMProxy::OnSessionError",
mProxy,
&ChromiumCDMProxy::OnSessionError,
NS_ConvertUTF8toUTF16(aSessionId),
ToNsresult(aError),
aSystemCode,
NS_ConvertUTF8toUTF16(aMessage)),
NS_DISPATCH_NORMAL);
return IPC_OK();
}
@ -827,8 +934,8 @@ ChromiumCDMParent::ActorDestroy(ActorDestroyReason aWhy)
GMP_LOG("ChromiumCDMParent::ActorDestroy(this=%p, reason=%d)", this, aWhy);
MOZ_ASSERT(!mActorDestroyed);
mActorDestroyed = true;
// Shutdown() will clear mCDMCallback, so let's keep a reference for later use.
auto callback = mCDMCallback;
// Shutdown() will clear mProxy, so let's keep a reference for later use.
RefPtr<ChromiumCDMProxy> proxy = mProxy;
if (!mIsShutdown) {
// Plugin crash.
MOZ_ASSERT(aWhy == AbnormalShutdown);
@ -841,8 +948,13 @@ ChromiumCDMParent::ActorDestroy(ActorDestroyReason aWhy)
mContentParent = nullptr;
}
bool abnormalShutdown = (aWhy == AbnormalShutdown);
if (abnormalShutdown && callback) {
callback->Terminated();
if (abnormalShutdown && proxy) {
mMainThread->Dispatch(
NewRunnableMethod(
"ChromiumCDMProxy::Terminated",
proxy,
&ChromiumCDMProxy::Terminated),
NS_DISPATCH_NORMAL);
}
MaybeDisconnect(abnormalShutdown);
}
@ -1078,14 +1190,19 @@ ChromiumCDMParent::Shutdown()
// proxy will shutdown when the owning MediaKeys is destroyed during cycle
// collection, and that will not shut down cleanly as the GMP thread will be
// shutdown by then.
if (mCDMCallback) {
mCDMCallback->Shutdown();
if (mProxy) {
mMainThread->Dispatch(
NewRunnableMethod(
"ChromiumCDMProxy::Shutdown",
mProxy,
&ChromiumCDMProxy::Shutdown),
NS_DISPATCH_NORMAL);
}
// We may be called from a task holding the last reference to the CDM callback, so
// We may be called from a task holding the last reference to the proxy, so
// let's clear our local weak pointer to ensure it will not be used afterward
// (including from an already-queued task, e.g.: ActorDestroy).
mCDMCallback = nullptr;
mProxy = nullptr;
mReorderQueue.Clear();

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

@ -18,8 +18,6 @@
#include "mozilla/Span.h"
#include "ReorderQueue.h"
class ChromiumCDMCallback;
namespace mozilla {
class MediaRawData;
@ -40,7 +38,7 @@ public:
uint32_t PluginId() const { return mPluginId; }
bool Init(ChromiumCDMCallback* aCDMCallback,
bool Init(ChromiumCDMProxy* aProxy,
bool aAllowDistinctiveIdentifier,
bool aAllowPersistentState,
nsIEventTarget* aMainThread);
@ -150,9 +148,10 @@ protected:
const uint32_t mPluginId;
GMPContentParent* mContentParent;
// Note: this pointer is a weak reference as ChromiumCDMProxy has a strong reference to the
// ChromiumCDMCallback.
ChromiumCDMCallback* mCDMCallback = nullptr;
// Note: this pointer is a weak reference because otherwise it would cause
// a cycle, as ChromiumCDMProxy has a strong reference to the
// ChromiumCDMParent.
ChromiumCDMProxy* mProxy = nullptr;
nsDataHashtable<nsUint32HashKey, uint32_t> mPromiseToCreateSessionToken;
nsTArray<RefPtr<DecryptJob>> mDecrypts;
@ -189,7 +188,7 @@ protected:
ReorderQueue mReorderQueue;
// The main thread associated with the root document. Must be set in Init().
nsCOMPtr<nsIEventTarget> mMainThread;
nsCOMPtr<nsIEventTarget> mMainThread;
};
} // namespace gmp

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

@ -5,7 +5,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ChromiumCDMProxy.h"
#include "ChromiumCDMCallbackProxy.h"
#include "mozilla/dom/MediaKeySession.h"
#include "GMPUtils.h"
#include "nsPrintfCString.h"
@ -98,9 +97,7 @@ ChromiumCDMProxy::Init(PromiseId aPromiseId,
thread,
__func__,
[self, aPromiseId](RefPtr<gmp::ChromiumCDMParent> cdm) {
self->mCallback =
MakeUnique<ChromiumCDMCallbackProxy>(self, self->mMainThread);
if (!cdm->Init(self->mCallback.get(),
if (!cdm->Init(self,
self->mDistinctiveIdentifierRequired,
self->mPersistentStateRequired,
self->mMainThread)) {
@ -467,7 +464,7 @@ ChromiumCDMProxy::OnResolveLoadSessionPromise(uint32_t aPromiseId,
void
ChromiumCDMProxy::OnSessionMessage(const nsAString& aSessionId,
dom::MediaKeyMessageType aMessageType,
const nsTArray<uint8_t>& aMessage)
nsTArray<uint8_t>& aMessage)
{
MOZ_ASSERT(NS_IsMainThread());
if (mKeys.IsNull()) {

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

@ -15,7 +15,7 @@ namespace mozilla {
class MediaRawData;
class DecryptJob;
class ChromiumCDMCallbackProxy;
class ChromiumCDMProxy : public CDMProxy
{
public:
@ -68,7 +68,7 @@ public:
void OnSessionMessage(const nsAString& aSessionId,
dom::MediaKeyMessageType aMessageType,
const nsTArray<uint8_t>& aMessage) override;
nsTArray<uint8_t>& aMessage) override;
void OnExpirationChange(const nsAString& aSessionId,
GMPTimestamp aExpiryTime) override;
@ -125,7 +125,6 @@ private:
Mutex mCDMMutex;
RefPtr<gmp::ChromiumCDMParent> mCDM;
RefPtr<AbstractThread> mGMPThread;
UniquePtr<ChromiumCDMCallbackProxy> mCallback;
};
} // namespace mozilla

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

@ -12,7 +12,6 @@ XPIDL_SOURCES += [
]
EXPORTS += [
'ChromiumCDMCallback.h',
'ChromiumCDMParent.h',
'ChromiumCDMProxy.h',
'DecryptJob.h',
@ -73,7 +72,6 @@ EXPORTS += [
UNIFIED_SOURCES += [
'ChromiumCDMAdapter.cpp',
'ChromiumCDMCallbackProxy.cpp',
'ChromiumCDMChild.cpp',
'ChromiumCDMParent.cpp',
'ChromiumCDMProxy.cpp',