| Index: content/browser/utility_process_host_impl.cc
|
| diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc
|
| index a2c181a3cab541ad1ff2340f059448440430a0e8..04a97b58f6a9006090c5389d11061c556fd1ba37 100644
|
| --- a/content/browser/utility_process_host_impl.cc
|
| +++ b/content/browser/utility_process_host_impl.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "content/browser/utility_process_host_impl.h"
|
|
|
| +#include <memory>
|
| #include <utility>
|
|
|
| #include "base/base_switches.h"
|
| @@ -22,7 +23,9 @@
|
| #include "base/synchronization/lock.h"
|
| #include "base/synchronization/waitable_event.h"
|
| #include "build/build_config.h"
|
| +#include "components/discardable_memory/service/discardable_shared_memory_manager.h"
|
| #include "content/browser/browser_child_process_host_impl.h"
|
| +#include "content/browser/browser_main_loop.h"
|
| #include "content/browser/renderer_host/render_process_host_impl.h"
|
| #include "content/browser/service_manager/service_manager_context.h"
|
| #include "content/common/child_process_host_impl.h"
|
| @@ -32,6 +35,7 @@
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/content_browser_client.h"
|
| #include "content/public/browser/utility_process_host_client.h"
|
| +#include "content/public/common/connection_filter.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/common/mojo_channel_switches.h"
|
| #include "content/public/common/process_type.h"
|
| @@ -40,6 +44,7 @@
|
| #include "content/public/common/service_manager_connection.h"
|
| #include "content/public/common/service_names.mojom.h"
|
| #include "mojo/edk/embedder/embedder.h"
|
| +#include "services/service_manager/public/cpp/binder_registry.h"
|
| #include "services/service_manager/public/cpp/interface_provider.h"
|
| #include "ui/base/ui_base_switches.h"
|
|
|
| @@ -134,6 +139,29 @@ class UtilitySandboxedProcessLauncherDelegate
|
|
|
| UtilityMainThreadFactoryFunction g_utility_main_thread_factory = NULL;
|
|
|
| +class UtilityProcessHost::ConnectionFilterImpl : public ConnectionFilter {
|
| + public:
|
| + ConnectionFilterImpl(
|
| + std::unique_ptr<service_manager::BinderRegistry> registry)
|
| + : registry_(std::move(registry)) {}
|
| +
|
| + private:
|
| + // ConnectionFilter:
|
| + void OnBindInterface(const service_manager::ServiceInfo& source_info,
|
| + const std::string& interface_name,
|
| + mojo::ScopedMessagePipeHandle* interface_pipe,
|
| + service_manager::Connector* connector) override {
|
| + if (registry_->CanBindInterface(interface_name)) {
|
| + registry_->BindInterface(source_info.identity, interface_name,
|
| + std::move(*interface_pipe));
|
| + }
|
| + }
|
| +
|
| + std::unique_ptr<service_manager::BinderRegistry> registry_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl);
|
| +};
|
| +
|
| UtilityProcessHost* UtilityProcessHost::Create(
|
| const scoped_refptr<UtilityProcessHostClient>& client,
|
| const scoped_refptr<base::SequencedTaskRunner>& client_task_runner) {
|
| @@ -233,6 +261,29 @@ void UtilityProcessHostImpl::BindInterface(
|
| std::move(interface_pipe));
|
| }
|
|
|
| +void UtilityProcessHostImpl::RegisterMojoServices() {
|
| + auto registry = base::MakeUnique<service_manager::BinderRegistry>();
|
| + // May be null during test execution.
|
| + if (ServiceManagerConnection::GetForProcess()) {
|
| + registry->AddInterface(
|
| + base::Bind(
|
| + &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest,
|
| + base::Unretained(
|
| + memory_instrumentation::CoordinatorImpl::GetInstance())),
|
| + BrowserThread::GetTaskRunnerForThread(BrowserThread::UI));
|
| +
|
| + discardable_memory::DiscardableSharedMemoryManager* manager =
|
| + BrowserMainLoop::GetInstance()->discardable_shared_memory_manager();
|
| + registry->AddInterface(
|
| + base::Bind(&discardable_memory::DiscardableSharedMemoryManager::Bind,
|
| + base::Unretained(manager)),
|
| + BrowserThread::GetTaskRunnerForThread(BrowserThread::UI));
|
| +
|
| + ServiceManagerConnection::GetForProcess()->AddConnectionFilter(
|
| + base::MakeUnique<ConnectionFilterImpl>(std::move(registry)));
|
| + }
|
| +}
|
| +
|
| void UtilityProcessHostImpl::SetName(const base::string16& name) {
|
| name_ = name;
|
| }
|
|
|