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

Unified Diff: media/mojo/services/mojo_renderer_service.cc

Issue 2539703002: media: Add |bad_message_cb_| to MojoRendererService (Closed)
Patch Set: add TODO and ref to bug Created 4 years, 1 month 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/services/mojo_renderer_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/services/mojo_renderer_service.cc
diff --git a/media/mojo/services/mojo_renderer_service.cc b/media/mojo/services/mojo_renderer_service.cc
index 22c9a833377e2c420ca172243b351f1f9eb849af..5cd986ef3eac7cc1b885c21ae7a71bf1366fd16e 100644
--- a/media/mojo/services/mojo_renderer_service.cc
+++ b/media/mojo/services/mojo_renderer_service.cc
@@ -18,6 +18,16 @@
namespace media {
+namespace {
+
+void CloseBindingOnBadMessage(mojo::StrongBindingPtr<mojom::Renderer> binding) {
+ LOG(ERROR) << __func__;
+ DCHECK(binding);
+ binding->Close();
+}
+
+} // namespace
+
// Time interval to update media time.
const int kTimeUpdateIntervalMs = 50;
@@ -37,7 +47,7 @@ mojo::StrongBindingPtr<mojom::Renderer> MojoRendererService::Create(
mojo::MakeStrongBinding<mojom::Renderer>(base::WrapUnique(service),
std::move(request));
- service->binding_ = binding;
+ service->set_bad_message_cb(base::Bind(&CloseBindingOnBadMessage, binding));
return binding;
}
@@ -271,7 +281,10 @@ void MojoRendererService::InitiateScopedSurfaceRequest(
// |renderer_| is likely not of type MediaPlayerRenderer.
// This is an unexpected call, and the connection should be closed.
mojo::ReportBadMessage("Unexpected call to InitiateScopedSurfaceRequest.");
- binding_->Close();
+
+ // This may cause |this| to be destructed.
+ DCHECK(!bad_message_cb_.is_null());
+ bad_message_cb_.Run();
return;
}
« no previous file with comments | « media/mojo/services/mojo_renderer_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698