Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Unified Diff: media/mojo/clients/mojo_cdm.cc

Issue 2551333002: media: Avoid access violation in MojoCdm after connection error (Closed)
Patch Set: comments addressed Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/mojo/clients/mojo_cdm.h ('k') | media/mojo/clients/mojo_cdm_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/clients/mojo_cdm.cc
diff --git a/media/mojo/clients/mojo_cdm.cc b/media/mojo/clients/mojo_cdm.cc
index 31f15752e7b028a695f25365d544a1c9f4526126..042ef15f58b835a094b41ceecfe67bd106005994 100644
--- a/media/mojo/clients/mojo_cdm.cc
+++ b/media/mojo/clients/mojo_cdm.cc
@@ -112,7 +112,7 @@ void MojoCdm::InitializeCdm(const std::string& key_system,
}
// Otherwise, set an error handler to catch the connection error.
- remote_cdm_.set_connection_error_handler(
+ remote_cdm_.set_connection_error_with_reason_handler(
base::Bind(&MojoCdm::OnConnectionError, base::Unretained(this)));
pending_init_promise_ = std::move(promise);
@@ -122,15 +122,22 @@ void MojoCdm::InitializeCdm(const std::string& key_system,
base::Bind(&MojoCdm::OnCdmInitialized, base::Unretained(this)));
}
-void MojoCdm::OnConnectionError() {
- LOG(ERROR) << "Remote CDM connection error.";
+// 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());
// Handle initial connection error.
if (pending_init_promise_) {
+ DCHECK(!cdm_session_tracker_.HasRemainingSessions());
pending_init_promise_->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0,
"Mojo CDM creation failed.");
+ // Dropping the promise could cause |this| to be destructed.
pending_init_promise_.reset();
+ return;
}
cdm_session_tracker_.CloseRemainingSessions(session_closed_cb_);
« no previous file with comments | « media/mojo/clients/mojo_cdm.h ('k') | media/mojo/clients/mojo_cdm_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698