| Index: content/browser/browser_child_process_host_impl.cc
|
| diff --git a/content/browser/browser_child_process_host_impl.cc b/content/browser/browser_child_process_host_impl.cc
|
| index 60adf7b60e194a214fa6403d048f81eed99586b1..10451bdcfe6fcf43bd4fc902f806cfddbd38aa4f 100644
|
| --- a/content/browser/browser_child_process_host_impl.cc
|
| +++ b/content/browser/browser_child_process_host_impl.cc
|
| @@ -27,6 +27,7 @@
|
| #include "content/browser/histogram_message_filter.h"
|
| #include "content/browser/loader/resource_message_filter.h"
|
| #include "content/browser/memory/memory_message_filter.h"
|
| +#include "content/browser/power_monitor_message_broadcaster.h"
|
| #include "content/browser/profiler_message_filter.h"
|
| #include "content/browser/service_manager/service_manager_context.h"
|
| #include "content/browser/tracing/trace_message_filter.h"
|
| @@ -38,14 +39,17 @@
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/child_process_data.h"
|
| #include "content/public/browser/content_browser_client.h"
|
| +#include "content/public/common/connection_filter.h"
|
| #include "content/public/common/content_features.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/common/mojo_channel_switches.h"
|
| #include "content/public/common/process_type.h"
|
| #include "content/public/common/result_codes.h"
|
| +#include "content/public/common/service_manager_connection.h"
|
| #include "ipc/attachment_broker.h"
|
| #include "ipc/attachment_broker_privileged.h"
|
| #include "mojo/edk/embedder/embedder.h"
|
| +#include "services/service_manager/public/cpp/interface_registry.h"
|
|
|
| #if defined(OS_MACOSX)
|
| #include "content/browser/mach_broker_mac.h"
|
| @@ -117,6 +121,22 @@ base::PortProvider* BrowserChildProcessHost::GetPortProvider() {
|
| }
|
| #endif
|
|
|
| +class BrowserChildProcessHost::ConnectionFilterImpl : public ConnectionFilter {
|
| + public:
|
| + ConnectionFilterImpl() {}
|
| +
|
| + private:
|
| + // ConnectionFilter:
|
| + bool OnConnect(const service_manager::Identity& remote_identity,
|
| + service_manager::InterfaceRegistry* registry,
|
| + service_manager::Connector* connector) override {
|
| + registry->AddInterface(base::Bind(&PowerMonitorMessageBroadcaster::Create));
|
| + return true;
|
| + }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl);
|
| +};
|
| +
|
| // static
|
| BrowserChildProcessHostImpl::BrowserChildProcessList*
|
| BrowserChildProcessHostImpl::GetIterator() {
|
| @@ -144,7 +164,6 @@ BrowserChildProcessHostImpl::BrowserChildProcessHostImpl(
|
| : data_(process_type),
|
| delegate_(delegate),
|
| child_token_(mojo::edk::GenerateRandomToken()),
|
| - power_monitor_message_broadcaster_(this),
|
| is_channel_connected_(false),
|
| notify_child_disconnected_(false),
|
| weak_factory_(this) {
|
| @@ -172,8 +191,6 @@ BrowserChildProcessHostImpl::BrowserChildProcessHostImpl(
|
| g_child_process_list.Get().push_back(this);
|
| GetContentClient()->browser()->BrowserChildProcessHostCreated(this);
|
|
|
| - power_monitor_message_broadcaster_.Init();
|
| -
|
| if (!service_name.empty()) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| child_connection_.reset(new ChildConnection(
|
| @@ -182,6 +199,12 @@ BrowserChildProcessHostImpl::BrowserChildProcessHostImpl(
|
| base::ThreadTaskRunnerHandle::Get()));
|
| }
|
|
|
| + // May be null during test execution.
|
| + if (ServiceManagerConnection::GetForProcess()) {
|
| + ServiceManagerConnection::GetForProcess()->AddConnectionFilter(
|
| + base::MakeUnique<ConnectionFilterImpl>());
|
| + }
|
| +
|
| // Create a persistent memory segment for subprocess histograms.
|
| CreateMetricsAllocator();
|
| }
|
|
|