Index: media/mojo/clients/mojo_cdm.cc |
diff --git a/media/mojo/clients/mojo_cdm.cc b/media/mojo/clients/mojo_cdm.cc |
index 042ef15f58b835a094b41ceecfe67bd106005994..500b234d2d987091ca1fb7befcbb3e86667120b0 100644 |
--- a/media/mojo/clients/mojo_cdm.cc |
+++ b/media/mojo/clients/mojo_cdm.cc |
@@ -112,6 +112,7 @@ void MojoCdm::InitializeCdm(const std::string& key_system, |
} |
// Otherwise, set an error handler to catch the connection error. |
+ DCHECK(remote_cdm_.is_bound()); |
remote_cdm_.set_connection_error_with_reason_handler( |
base::Bind(&MojoCdm::OnConnectionError, base::Unretained(this))); |
@@ -122,14 +123,15 @@ void MojoCdm::InitializeCdm(const std::string& key_system, |
base::Bind(&MojoCdm::OnCdmInitialized, base::Unretained(this))); |
} |
-// TODO(xhwang): Properly handle CDM calls after connection error. |
-// See http://crbug.com/671362 |
void MojoCdm::OnConnectionError(uint32_t custom_reason, |
const std::string& description) { |
LOG(ERROR) << "Remote CDM connection error: custom_reason=" << custom_reason |
<< ", description=\"" << description << "\""; |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ remote_cdm_.reset(); |
+ DCHECK(!remote_cdm_.is_bound()); |
+ |
// Handle initial connection error. |
if (pending_init_promise_) { |
DCHECK(!cdm_session_tracker_.HasRemainingSessions()); |
@@ -148,6 +150,12 @@ void MojoCdm::SetServerCertificate(const std::vector<uint8_t>& certificate, |
DVLOG(2) << __func__; |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ if (!remote_cdm_.is_bound()) { |
xhwang
2016/12/09 06:13:30
will this work?
if (!remote_cdm_) {
...
}
jrummell
2016/12/13 20:57:34
Done.
|
+ promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
+ "CDM has failed."); |
xhwang
2016/12/09 06:13:30
This message will be received by JS app, so it'd b
jrummell
2016/12/13 20:57:34
Done.
|
+ return; |
+ } |
+ |
remote_cdm_->SetServerCertificate( |
certificate, base::Bind(&MojoCdm::OnSimpleCdmPromiseResult, |
base::Unretained(this), base::Passed(&promise))); |
@@ -161,6 +169,12 @@ void MojoCdm::CreateSessionAndGenerateRequest( |
DVLOG(2) << __func__; |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ if (!remote_cdm_.is_bound()) { |
+ promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
+ "CDM has failed."); |
+ return; |
+ } |
+ |
remote_cdm_->CreateSessionAndGenerateRequest( |
session_type, init_data_type, init_data, |
base::Bind(&MojoCdm::OnNewSessionCdmPromiseResult, base::Unretained(this), |
@@ -173,6 +187,12 @@ void MojoCdm::LoadSession(SessionType session_type, |
DVLOG(2) << __func__; |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ if (!remote_cdm_.is_bound()) { |
+ promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
+ "CDM has failed."); |
+ return; |
+ } |
+ |
remote_cdm_->LoadSession( |
session_type, session_id, |
base::Bind(&MojoCdm::OnNewSessionCdmPromiseResult, base::Unretained(this), |
@@ -185,6 +205,12 @@ void MojoCdm::UpdateSession(const std::string& session_id, |
DVLOG(2) << __func__; |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ if (!remote_cdm_.is_bound()) { |
+ promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
+ "CDM has failed."); |
+ return; |
+ } |
+ |
remote_cdm_->UpdateSession( |
session_id, response, |
base::Bind(&MojoCdm::OnSimpleCdmPromiseResult, base::Unretained(this), |
@@ -196,6 +222,12 @@ void MojoCdm::CloseSession(const std::string& session_id, |
DVLOG(2) << __func__; |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ if (!remote_cdm_.is_bound()) { |
+ promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
+ "CDM has failed."); |
+ return; |
+ } |
+ |
remote_cdm_->CloseSession( |
session_id, base::Bind(&MojoCdm::OnSimpleCdmPromiseResult, |
base::Unretained(this), base::Passed(&promise))); |
@@ -206,6 +238,12 @@ void MojoCdm::RemoveSession(const std::string& session_id, |
DVLOG(2) << __func__; |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ if (!remote_cdm_.is_bound()) { |
+ promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
+ "CDM has failed."); |
+ return; |
+ } |
+ |
remote_cdm_->RemoveSession( |
session_id, base::Bind(&MojoCdm::OnSimpleCdmPromiseResult, |
base::Unretained(this), base::Passed(&promise))); |