| 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 fd057ba52a843d9bc6b27335dee2700e1bd3814a..aa68aac5e21b9d1706f0d1c068397bd714eae21c 100644
|
| --- a/content/browser/utility_process_host_impl.cc
|
| +++ b/content/browser/utility_process_host_impl.cc
|
| @@ -22,7 +22,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 +34,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"
|
| @@ -135,6 +138,28 @@ class UtilitySandboxedProcessLauncherDelegate
|
|
|
| UtilityMainThreadFactoryFunction g_utility_main_thread_factory = NULL;
|
|
|
| +class UtilityProcessHost::ConnectionFilterImpl : public ConnectionFilter {
|
| + public:
|
| + ConnectionFilterImpl() {}
|
| +
|
| + private:
|
| + // ConnectionFilter:
|
| + bool OnConnect(const service_manager::Identity& remote_identity,
|
| + service_manager::InterfaceRegistry* registry,
|
| + service_manager::Connector* connector) override {
|
| + if (BrowserMainLoop::GetInstance()) {
|
| + discardable_memory::DiscardableSharedMemoryManager* manager =
|
| + BrowserMainLoop::GetInstance()->discardable_shared_memory_manager();
|
| + registry->AddInterface(
|
| + base::Bind(&discardable_memory::DiscardableSharedMemoryManager::Bind,
|
| + base::Unretained(manager)));
|
| + }
|
| + return true;
|
| + }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl);
|
| +};
|
| +
|
| UtilityProcessHost* UtilityProcessHost::Create(
|
| const scoped_refptr<UtilityProcessHostClient>& client,
|
| const scoped_refptr<base::SequencedTaskRunner>& client_task_runner) {
|
| @@ -232,6 +257,14 @@ UtilityProcessHostImpl::GetRemoteInterfaces() {
|
| return process_->child_connection()->GetRemoteInterfaces();
|
| }
|
|
|
| +void UtilityProcessHostImpl::RegisterMojoServices() {
|
| + // May be null during test execution.
|
| + if (ServiceManagerConnection::GetForProcess()) {
|
| + ServiceManagerConnection::GetForProcess()->AddConnectionFilter(
|
| + base::MakeUnique<ConnectionFilterImpl>());
|
| + }
|
| +}
|
| +
|
| void UtilityProcessHostImpl::SetName(const base::string16& name) {
|
| name_ = name;
|
| }
|
|
|