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

Unified Diff: content/common/service_manager/service_manager_connection_impl.cc

Issue 2820883002: Eliminate ChildThread InterfaceRegistry. (Closed)
Patch Set: . Created 3 years, 8 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
Index: content/common/service_manager/service_manager_connection_impl.cc
diff --git a/content/common/service_manager/service_manager_connection_impl.cc b/content/common/service_manager/service_manager_connection_impl.cc
index 9e81238aa0a4a53a53cbf5928388dcc0a9d1c9ec..4e95f69aa9549a309c663f8196ffe7da7ab67195 100644
--- a/content/common/service_manager/service_manager_connection_impl.cc
+++ b/content/common/service_manager/service_manager_connection_impl.cc
@@ -19,9 +19,9 @@
#include "content/common/child.mojom.h"
#include "content/common/service_manager/embedded_service_runner.h"
#include "content/public/common/connection_filter.h"
+#include "content/public/common/service_names.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/system/message_pipe.h"
-#include "services/service_manager/public/cpp/interface_registry.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_context.h"
#include "services/service_manager/public/interfaces/constants.mojom.h"
@@ -112,15 +112,6 @@ class ServiceManagerConnectionImpl::IOThreadContext
filter_id));
}
- // Safe to call any time before Start() is called.
- void SetDefaultBinderForBrowserConnection(
- const service_manager::InterfaceRegistry::Binder& binder) {
- DCHECK(!started_);
- default_browser_binder_ = base::Bind(
- &IOThreadContext::CallBinderOnTaskRunner,
- base::ThreadTaskRunnerHandle::Get(), binder);
- }
-
void AddEmbeddedService(const std::string& name, const ServiceInfo& info) {
io_task_runner_->PostTask(
FROM_HERE, base::Bind(&ServiceManagerConnectionImpl::IOThreadContext::
@@ -232,11 +223,6 @@ class ServiceManagerConnectionImpl::IOThreadContext
connection_filters_.erase(it);
}
- void OnBrowserConnectionLost() {
- DCHECK(io_thread_checker_.CalledOnValidThread());
- has_browser_connection_ = false;
- }
-
void AddEmbeddedServiceRequestHandlerOnIoThread(const std::string& name,
const ServiceInfo& info) {
DCHECK(io_thread_checker_.CalledOnValidThread());
@@ -276,18 +262,25 @@ class ServiceManagerConnectionImpl::IOThreadContext
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) override {
DCHECK(io_thread_checker_.CalledOnValidThread());
+ last_source_info_ = source_info;
- std::string remote_service = source_info.identity.name();
- // Only expose the ServiceFactory interface to the Service Manager.
- if (remote_service == service_manager::mojom::kServiceName &&
+ if (source_info.identity.name() == service_manager::mojom::kServiceName &&
interface_name == service_manager::mojom::ServiceFactory::Name_) {
factory_bindings_.AddBinding(
this, mojo::MakeRequest<service_manager::mojom::ServiceFactory>(
std::move(interface_pipe)));
- return;
- }
-
- {
+ } else if (source_info.identity.name() == mojom::kBrowserServiceName &&
+ interface_name == mojom::Child::Name_) {
+ DCHECK(!child_binding_.is_bound());
+ child_binding_.Bind(
+ mojo::MakeRequest<mojom::Child>(std::move(interface_pipe)));
+
+ InitializeCallback handler =
+ base::ResetAndReturn(&browser_info_available_callback_);
+ // TODO(beng): change |source_identity| parameter to |source_info|.
+ callback_task_runner_->PostTask(FROM_HERE,
+ base::Bind(handler, last_source_info_));
+ } else {
base::AutoLock lock(lock_);
for (auto& entry : connection_filters_) {
entry.second->OnBindInterface(source_info, interface_name,
@@ -298,32 +291,10 @@ class ServiceManagerConnectionImpl::IOThreadContext
return;
}
}
-
- if (remote_service == "content_browser") {
- if (interface_name == mojom::Child::Name_ && !has_browser_connection_) {
- has_browser_connection_ = true;
- InitializeCallback handler =
- base::ResetAndReturn(&browser_info_available_callback_);
- callback_task_runner_->PostTask(FROM_HERE,
- base::Bind(handler, source_info));
-
- child_binding_.Bind(std::move(interface_pipe));
- child_binding_.set_connection_error_handler(
- base::Bind(&IOThreadContext::OnBrowserConnectionLost, this));
- } else {
- default_browser_binder_.Run(interface_name, std::move(interface_pipe));
- }
- }
- }
-
- bool OnServiceManagerConnectionLost() override {
- ClearConnectionFiltersOnIOThread();
- callback_task_runner_->PostTask(FROM_HERE, stop_callback_);
- return true;
}
/////////////////////////////////////////////////////////////////////////////
- // service_manager::mojom::ServiceFactory implementation
+ // service_manager::mojom::ServiceFactory:
void CreateService(service_manager::mojom::ServiceRequest request,
const std::string& name) override {
@@ -334,15 +305,6 @@ class ServiceManagerConnectionImpl::IOThreadContext
it->second.Run(std::move(request));
}
- static void CallBinderOnTaskRunner(
- scoped_refptr<base::SequencedTaskRunner> task_runner,
- const service_manager::InterfaceRegistry::Binder& binder,
- const std::string& interface_name,
- mojo::ScopedMessagePipeHandle request_handle) {
- task_runner->PostTask(FROM_HERE, base::Bind(binder, interface_name,
- base::Passed(&request_handle)));
- }
-
base::ThreadChecker io_thread_checker_;
bool started_ = false;
@@ -364,18 +326,8 @@ class ServiceManagerConnectionImpl::IOThreadContext
// Callback to run if the service is stopped by the service manager.
base::Closure stop_callback_;
- // Called once a connection has been received from the browser process & the
- // default binder (below) has been set up.
- bool has_browser_connection_ = false;
-
service_manager::ServiceInfo local_info_;
-
- // Default binder callback used for the browser connection's
- // InterfaceRegistry.
- //
- // TODO(rockot): Remove this once all interfaces exposed to the browser are
- // exposed via a ConnectionFilter.
- service_manager::InterfaceRegistry::Binder default_browser_binder_;
+ service_manager::ServiceInfo last_source_info_;
Ken Rockot(use gerrit already) 2017/04/24 22:36:31 This member variable doesn't seem to be necessary?
std::unique_ptr<service_manager::ServiceContext> service_context_;
mojo::BindingSet<service_manager::mojom::ServiceFactory> factory_bindings_;
@@ -491,18 +443,6 @@ void ServiceManagerConnectionImpl::SetConnectionLostClosure(
connection_lost_handler_ = closure;
}
-void ServiceManagerConnectionImpl::SetupInterfaceRequestProxies(
- service_manager::InterfaceRegistry* registry,
- service_manager::InterfaceProvider* provider) {
- // It's safe to bind |registry| as a raw pointer because the caller must
- // guarantee that it outlives |this|, and |this| is bound as a weak ptr here.
- context_->SetDefaultBinderForBrowserConnection(
- base::Bind(&ServiceManagerConnectionImpl::GetInterface,
- weak_factory_.GetWeakPtr(), registry));
-
- // TODO(beng): remove provider parameter.
-}
-
int ServiceManagerConnectionImpl::AddConnectionFilter(
std::unique_ptr<ConnectionFilter> filter) {
return context_->AddConnectionFilter(std::move(filter));

Powered by Google App Engine
This is Rietveld 408576698