Bug 1407523 - Add more detailed message when GetCDM failed. r=cpearce

MozReview-Commit-ID: qEpvjyc6bY

--HG--
extra : rebase_source : 09e0579a76362d409749daf9b53e6a21da3818e3
This commit is contained in:
James Cheng 2017-10-11 14:04:16 +08:00
Родитель a075851606
Коммит 019e9610a0
5 изменённых файлов: 22 добавлений и 8 удалений

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

@ -49,6 +49,8 @@ ChromiumCDMParent::Init(ChromiumCDMCallback* aCDMCallback,
{
GMP_LOG("ChromiumCDMParent::Init(this=%p)", this);
if (!aCDMCallback || !aMainThread) {
GMP_LOG("ChromiumCDMParent::Init(this=%p) failure since aCDMCallback(%p) or"
" aMainThread(%p) is nullptr", this, aCDMCallback, aMainThread);
return false;
}
mCDMCallback = aCDMCallback;

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

@ -6,6 +6,7 @@
#include "ChromiumCDMProxy.h"
#include "ChromiumCDMCallbackProxy.h"
#include "MediaResult.h"
#include "mozilla/dom/MediaKeySession.h"
#include "GMPUtils.h"
#include "nsPrintfCString.h"
@ -106,7 +107,7 @@ ChromiumCDMProxy::Init(PromiseId aPromiseId,
self->mMainThread)) {
self->RejectPromise(aPromiseId,
NS_ERROR_FAILURE,
NS_LITERAL_CSTRING("GetCDM failed."));
NS_LITERAL_CSTRING("GetCDM failed due to CDM initialization failure."));
return;
}
{
@ -115,9 +116,9 @@ ChromiumCDMProxy::Init(PromiseId aPromiseId,
}
self->OnCDMCreated(aPromiseId);
},
[self, aPromiseId](nsresult rv) {
[self, aPromiseId](MediaResult rv) {
self->RejectPromise(
aPromiseId, NS_ERROR_FAILURE, NS_LITERAL_CSTRING("GetCDM failed."));
aPromiseId, rv.Code(), rv.Description());
});
}));

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

@ -36,6 +36,7 @@
#include "nsThreadUtils.h"
#include "GMPCrashHelper.h"
#include "MediaResult.h"
#include "mozilla/dom/PluginCrashedEvent.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/Attributes.h"
@ -237,7 +238,9 @@ GeckoMediaPluginService::GetCDM(const NodeId& aNodeId,
MOZ_ASSERT(mGMPThread->EventTarget()->IsOnCurrentThread());
if (mShuttingDownOnGMPThread || aTags.IsEmpty()) {
return GetCDMParentPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
nsPrintfCString reason("%s::%s failed, aTags.IsEmpty() = %d, mShuttingDownOnGMPThread = %d.",
__CLASS__, __FUNCTION__, aTags.IsEmpty(), mShuttingDownOnGMPThread);
return GetCDMParentPromise::CreateAndReject(MediaResult(NS_ERROR_FAILURE, reason.get()), __func__);
}
typedef MozPromiseHolder<GetCDMParentPromise> PromiseHolder;
@ -254,7 +257,10 @@ GeckoMediaPluginService::GetCDM(const NodeId& aNodeId,
UniquePtr<PromiseHolder> holder(rawHolder);
RefPtr<ChromiumCDMParent> cdm = parent->GetChromiumCDM();
if (!parent) {
holder->Reject(NS_ERROR_FAILURE, __func__);
nsPrintfCString reason(
"%s::%s failed since GetChromiumCDM returns nullptr.",
__CLASS__, __FUNCTION__);
holder->Reject(MediaResult(NS_ERROR_FAILURE, reason.get()), __func__);
return;
}
if (helper) {
@ -263,8 +269,11 @@ GeckoMediaPluginService::GetCDM(const NodeId& aNodeId,
holder->Resolve(cdm, __func__);
},
[rawHolder] {
nsPrintfCString reason(
"%s::%s failed since GetContentParent rejects the promise.",
__CLASS__, __FUNCTION__);
UniquePtr<PromiseHolder> holder(rawHolder);
holder->Reject(NS_ERROR_FAILURE, __func__);
holder->Reject(MediaResult(NS_ERROR_FAILURE, reason.get()), __func__);
});
return promise;

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

@ -25,6 +25,7 @@
#include "GMPContentParent.h"
#include "GMPCrashHelper.h"
#include "ChromiumCDMParent.h"
#include "MediaResult.h"
template <class> struct already_AddRefed;
@ -56,7 +57,7 @@ typedef MozPromise<RefPtr<GMPContentParent::CloseBlocker>,
/* IsExclusive = */ true>
GetGMPContentParentPromise;
typedef MozPromise<RefPtr<ChromiumCDMParent>,
nsresult,
MediaResult,
/* IsExclusive = */ true>
GetCDMParentPromise;

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

@ -11,6 +11,7 @@
#include "ChromiumCDMCallback.h"
#include "GMPTestMonitor.h"
#include "GMPServiceParent.h"
#include "MediaResult.h"
#include "nsIFile.h"
#include "nsISimpleEnumerator.h"
#include "nsNSSComponent.h" //For EnsureNSSInitializedChromeOrContent
@ -470,7 +471,7 @@ class CDMStorageTest
self->Update(update);
}
},
[](nsresult rv) { EXPECT_TRUE(false); });
[](MediaResult rv) { EXPECT_TRUE(false); });
}
void TestBasicStorage() {