summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjrummell <jrummell@chromium.org>2015-05-07 12:07:51 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-07 19:08:24 +0000
commitbb47c91f4bf41c61f122b9aa0567678fed2f4e73 (patch)
tree9bce4307d9640a3d250380057f052fb6193ab8a1
parent8a6989b532d692f319d617745de0651d67c6c990 (diff)
downloadchromium_src-bb47c91f4bf41c61f122b9aa0567678fed2f4e73.zip
chromium_src-bb47c91f4bf41c61f122b9aa0567678fed2f4e73.tar.gz
chromium_src-bb47c91f4bf41c61f122b9aa0567678fed2f4e73.tar.bz2
Provide error message if creating the CDM fails
Rather than using a generic error message when initialization of a CDM fails, provide a specific error message. BUG=407435 TEST=EME tests pass Review URL: https://codereview.chromium.org/1128113004 Cr-Commit-Position: refs/heads/master@{#328809}
-rw-r--r--content/renderer/media/crypto/cdm_initialized_promise.cc4
-rw-r--r--content/renderer/media/crypto/ppapi_decryptor.cc3
-rw-r--r--content/renderer/media/crypto/render_cdm_factory.cc7
-rw-r--r--media/base/cdm_factory.h5
-rw-r--r--media/blink/cdm_session_adapter.cc7
-rw-r--r--media/blink/cdm_session_adapter.h3
-rw-r--r--media/cdm/default_cdm_factory.cc12
-rw-r--r--media/cdm/proxy_decryptor.cc3
-rw-r--r--media/cdm/proxy_decryptor.h3
9 files changed, 31 insertions, 16 deletions
diff --git a/content/renderer/media/crypto/cdm_initialized_promise.cc b/content/renderer/media/crypto/cdm_initialized_promise.cc
index 5a72c6d..8d9b7af 100644
--- a/content/renderer/media/crypto/cdm_initialized_promise.cc
+++ b/content/renderer/media/crypto/cdm_initialized_promise.cc
@@ -17,14 +17,14 @@ CdmInitializedPromise::~CdmInitializedPromise() {
void CdmInitializedPromise::resolve() {
MarkPromiseSettled();
- cdm_created_cb_.Run(cdm_.Pass());
+ cdm_created_cb_.Run(cdm_.Pass(), "");
}
void CdmInitializedPromise::reject(media::MediaKeys::Exception exception_code,
uint32 system_code,
const std::string& error_message) {
MarkPromiseSettled();
- cdm_created_cb_.Run(nullptr);
+ cdm_created_cb_.Run(nullptr, error_message);
}
} // namespace content
diff --git a/content/renderer/media/crypto/ppapi_decryptor.cc b/content/renderer/media/crypto/ppapi_decryptor.cc
index 8fa799f..4e7a87f 100644
--- a/content/renderer/media/crypto/ppapi_decryptor.cc
+++ b/content/renderer/media/crypto/ppapi_decryptor.cc
@@ -42,7 +42,8 @@ void PpapiDecryptor::Create(
if (!pepper_cdm_wrapper) {
DLOG(ERROR) << "Plugin instance creation failed.";
base::MessageLoopProxy::current()->PostTask(
- FROM_HERE, base::Bind(cdm_created_cb, nullptr));
+ FROM_HERE, base::Bind(cdm_created_cb, nullptr,
+ "Plugin instance creation failed."));
}
scoped_ptr<PpapiDecryptor> ppapi_decryptor(
diff --git a/content/renderer/media/crypto/render_cdm_factory.cc b/content/renderer/media/crypto/render_cdm_factory.cc
index 6e81163..0bd15f3 100644
--- a/content/renderer/media/crypto/render_cdm_factory.cc
+++ b/content/renderer/media/crypto/render_cdm_factory.cc
@@ -57,7 +57,7 @@ void RenderCdmFactory::Create(
if (!security_origin.is_valid()) {
base::MessageLoopProxy::current()->PostTask(
- FROM_HERE, base::Bind(cdm_created_cb, nullptr));
+ FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Invalid origin."));
return;
}
@@ -70,7 +70,7 @@ void RenderCdmFactory::Create(
new media::AesDecryptor(security_origin, session_message_cb,
session_closed_cb, session_keys_change_cb));
base::MessageLoopProxy::current()->PostTask(
- FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm)));
+ FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm), ""));
return;
}
@@ -90,7 +90,8 @@ void RenderCdmFactory::Create(
#else
// No possible CDM to create, so fail the request.
base::MessageLoopProxy::current()->PostTask(
- FROM_HERE, base::Bind(cdm_created_cb, nullptr));
+ FROM_HERE,
+ base::Bind(cdm_created_cb, nullptr, "Key system not supported."));
#endif // defined(ENABLE_PEPPER_CDMS)
}
diff --git a/media/base/cdm_factory.h b/media/base/cdm_factory.h
index 8e0328a..0c9145d 100644
--- a/media/base/cdm_factory.h
+++ b/media/base/cdm_factory.h
@@ -15,7 +15,10 @@ class GURL;
namespace media {
-using CdmCreatedCB = base::Callback<void(scoped_ptr<MediaKeys>)>;
+// Callback used when CDM is created. |error_message| only used if
+// MediaKeys is null (i.e. CDM can't be created).
+using CdmCreatedCB = base::Callback<void(scoped_ptr<MediaKeys>,
+ const std::string& error_message)>;
class MEDIA_EXPORT CdmFactory {
public:
diff --git a/media/blink/cdm_session_adapter.cc b/media/blink/cdm_session_adapter.cc
index 692eecc..f4f3906 100644
--- a/media/blink/cdm_session_adapter.cc
+++ b/media/blink/cdm_session_adapter.cc
@@ -36,7 +36,7 @@ void CdmSessionAdapter::CreateCdm(
blink::WebContentDecryptionModuleResult result) {
// Note: WebContentDecryptionModuleImpl::Create() calls this method without
// holding a reference to the CdmSessionAdapter. Bind OnCdmCreated() with
- // |this| instead of |weak_this| to prevent |this| from being desctructed.
+ // |this| instead of |weak_this| to prevent |this| from being destructed.
base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr();
cdm_factory->Create(
key_system, allow_distinctive_identifier, allow_persistent_state,
@@ -121,12 +121,13 @@ const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const {
void CdmSessionAdapter::OnCdmCreated(
const std::string& key_system,
blink::WebContentDecryptionModuleResult result,
- scoped_ptr<MediaKeys> cdm) {
+ scoped_ptr<MediaKeys> cdm,
+ const std::string& error_message) {
DVLOG(2) << __FUNCTION__;
if (!cdm) {
result.completeWithError(
blink::WebContentDecryptionModuleExceptionNotSupportedError, 0,
- "Failed to create the CDM instance.");
+ blink::WebString::fromUTF8(error_message));
return;
}
diff --git a/media/blink/cdm_session_adapter.h b/media/blink/cdm_session_adapter.h
index cc60143..28d26bb 100644
--- a/media/blink/cdm_session_adapter.h
+++ b/media/blink/cdm_session_adapter.h
@@ -111,7 +111,8 @@ class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> {
// Callback for CreateCdm().
void OnCdmCreated(const std::string& key_system,
blink::WebContentDecryptionModuleResult result,
- scoped_ptr<MediaKeys> cdm);
+ scoped_ptr<MediaKeys> cdm,
+ const std::string& error_message);
// Callbacks for firing session events.
void OnSessionMessage(const std::string& session_id,
diff --git a/media/cdm/default_cdm_factory.cc b/media/cdm/default_cdm_factory.cc
index 4132a24..6b9714a 100644
--- a/media/cdm/default_cdm_factory.cc
+++ b/media/cdm/default_cdm_factory.cc
@@ -32,9 +32,15 @@ void DefaultCdmFactory::Create(
const SessionKeysChangeCB& session_keys_change_cb,
const SessionExpirationUpdateCB& session_expiration_update_cb,
const CdmCreatedCB& cdm_created_cb) {
- if (!security_origin.is_valid() || !CanUseAesDecryptor(key_system)) {
+ if (!security_origin.is_valid()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(cdm_created_cb, nullptr));
+ FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Invalid origin."));
+ return;
+ }
+ if (!CanUseAesDecryptor(key_system)) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(cdm_created_cb, nullptr, "Unsupported key system."));
return;
}
@@ -42,7 +48,7 @@ void DefaultCdmFactory::Create(
new AesDecryptor(security_origin, session_message_cb, session_closed_cb,
session_keys_change_cb));
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm)));
+ FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm), ""));
}
} // namespace media
diff --git a/media/cdm/proxy_decryptor.cc b/media/cdm/proxy_decryptor.cc
index b8ba19c..d8dcd5a 100644
--- a/media/cdm/proxy_decryptor.cc
+++ b/media/cdm/proxy_decryptor.cc
@@ -89,7 +89,8 @@ void ProxyDecryptor::CreateCdm(CdmFactory* cdm_factory,
void ProxyDecryptor::OnCdmCreated(const std::string& key_system,
const GURL& security_origin,
const CdmContextReadyCB& cdm_context_ready_cb,
- scoped_ptr<MediaKeys> cdm) {
+ scoped_ptr<MediaKeys> cdm,
+ const std::string& /* error_message */) {
is_creating_cdm_ = false;
if (!cdm) {
diff --git a/media/cdm/proxy_decryptor.h b/media/cdm/proxy_decryptor.h
index 9a17a98..09a94e3 100644
--- a/media/cdm/proxy_decryptor.h
+++ b/media/cdm/proxy_decryptor.h
@@ -76,7 +76,8 @@ class MEDIA_EXPORT ProxyDecryptor {
void OnCdmCreated(const std::string& key_system,
const GURL& security_origin,
const CdmContextReadyCB& cdm_context_ready_cb,
- scoped_ptr<MediaKeys> cdm);
+ scoped_ptr<MediaKeys> cdm,
+ const std::string& error_message);
void GenerateKeyRequestInternal(EmeInitDataType init_data_type,
const std::vector<uint8>& init_data);