diff options
author | jrummell <jrummell@chromium.org> | 2015-05-07 12:07:51 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-07 19:08:24 +0000 |
commit | bb47c91f4bf41c61f122b9aa0567678fed2f4e73 (patch) | |
tree | 9bce4307d9640a3d250380057f052fb6193ab8a1 /media | |
parent | 8a6989b532d692f319d617745de0651d67c6c990 (diff) | |
download | chromium_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}
Diffstat (limited to 'media')
-rw-r--r-- | media/base/cdm_factory.h | 5 | ||||
-rw-r--r-- | media/blink/cdm_session_adapter.cc | 7 | ||||
-rw-r--r-- | media/blink/cdm_session_adapter.h | 3 | ||||
-rw-r--r-- | media/cdm/default_cdm_factory.cc | 12 | ||||
-rw-r--r-- | media/cdm/proxy_decryptor.cc | 3 | ||||
-rw-r--r-- | media/cdm/proxy_decryptor.h | 3 |
6 files changed, 23 insertions, 10 deletions
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); |