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

Unified Diff: content/renderer/media/media_interface_provider.cc

Issue 2771553003: Allow mojo media interfaces to be obtained from other threads. (Closed)
Patch Set: Use base::Passed Created 3 years, 9 months 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 | « content/renderer/media/media_interface_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/media_interface_provider.cc
diff --git a/content/renderer/media/media_interface_provider.cc b/content/renderer/media/media_interface_provider.cc
index 8f779f5bf39dddd7a374c9949ee9788350077769..b542c6c543780eb4f7c02612e48f8babde46f4ae 100644
--- a/content/renderer/media/media_interface_provider.cc
+++ b/content/renderer/media/media_interface_provider.cc
@@ -16,7 +16,9 @@ namespace content {
MediaInterfaceProvider::MediaInterfaceProvider(
service_manager::InterfaceProvider* remote_interfaces)
- : remote_interfaces_(remote_interfaces) {}
+ : remote_interfaces_(remote_interfaces), weak_factory_(this) {
+ task_runner_ = base::ThreadTaskRunnerHandle::Get();
+}
MediaInterfaceProvider::~MediaInterfaceProvider() {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -25,6 +27,13 @@ MediaInterfaceProvider::~MediaInterfaceProvider() {
void MediaInterfaceProvider::GetInterface(const std::string& interface_name,
mojo::ScopedMessagePipeHandle pipe) {
DVLOG(1) << __func__;
+ if (!task_runner_->BelongsToCurrentThread()) {
+ task_runner_->PostTask(
+ FROM_HERE, base::Bind(&MediaInterfaceProvider::GetInterface,
+ weak_factory_.GetWeakPtr(), interface_name,
+ base::Passed(&pipe)));
+ return;
+ }
DCHECK(thread_checker_.CalledOnValidThread());
if (interface_name == media::mojom::ContentDecryptionModule::Name_) {
« no previous file with comments | « content/renderer/media/media_interface_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698