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

Unified Diff: content/common/mojo/service_registry_impl.cc

Issue 2024363002: Convert MimeRegistry to use mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@message-mojom-magic
Patch Set: Created 4 years, 7 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/common/mojo/service_registry_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mojo/service_registry_impl.cc
diff --git a/content/common/mojo/service_registry_impl.cc b/content/common/mojo/service_registry_impl.cc
index d5e48f1991abc7d2590d4deae94569f65142e092..39e575a70209a0b5d2d4a786fed4effcb4d1b267 100644
--- a/content/common/mojo/service_registry_impl.cc
+++ b/content/common/mojo/service_registry_impl.cc
@@ -42,9 +42,12 @@ void ServiceRegistryImpl::BindRemoteServiceProvider(
}
}
-void ServiceRegistryImpl::AddService(const std::string& service_name,
- const ServiceFactory& service_factory) {
- service_factories_[service_name] = service_factory;
+void ServiceRegistryImpl::AddService(
+ const std::string& service_name,
+ const ServiceFactory& service_factory,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
+ service_factories_[service_name] =
+ std::make_pair(service_factory, task_runner);
}
void ServiceRegistryImpl::RemoveService(const std::string& service_name) {
@@ -103,7 +106,21 @@ void ServiceRegistryImpl::GetInterface(
return;
}
- it->second.Run(std::move(client_handle));
+ if (it->second.second) {
+ it->second.second->PostTask(
+ FROM_HERE,
+ base::Bind(&ServiceRegistryImpl::RunServiceFactoryOnTaskRunner,
+ it->second.first, base::Passed(&client_handle)));
+ return;
+ }
+ it->second.first.Run(std::move(client_handle));
+}
+
+// static
+void ServiceRegistryImpl::RunServiceFactoryOnTaskRunner(
+ const ServiceRegistryImpl::ServiceFactory& factory,
+ mojo::ScopedMessagePipeHandle handle) {
+ factory.Run(std::move(handle));
}
void ServiceRegistryImpl::OnConnectionError() {
« no previous file with comments | « content/common/mojo/service_registry_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698