OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/browser_child_process_host_impl.h" | 5 #include "content/browser/browser_child_process_host_impl.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void NotifyProcessCrashed(const ChildProcessData& data, int exit_code) { | 83 void NotifyProcessCrashed(const ChildProcessData& data, int exit_code) { |
84 for (auto& observer : g_observers.Get()) | 84 for (auto& observer : g_observers.Get()) |
85 observer.BrowserChildProcessCrashed(data, exit_code); | 85 observer.BrowserChildProcessCrashed(data, exit_code); |
86 } | 86 } |
87 | 87 |
88 void NotifyProcessKilled(const ChildProcessData& data, int exit_code) { | 88 void NotifyProcessKilled(const ChildProcessData& data, int exit_code) { |
89 for (auto& observer : g_observers.Get()) | 89 for (auto& observer : g_observers.Get()) |
90 observer.BrowserChildProcessKilled(data, exit_code); | 90 observer.BrowserChildProcessKilled(data, exit_code); |
91 } | 91 } |
92 | 92 |
93 class ConnectionFilterImpl : public ConnectionFilter { | |
94 public: | |
95 ConnectionFilterImpl() {} | |
96 | |
97 private: | |
98 // ConnectionFilter: | |
99 bool OnConnect(const service_manager::Identity& remote_identity, | |
100 service_manager::InterfaceRegistry* registry, | |
101 service_manager::Connector* connector) override { | |
102 return true; | |
103 } | |
104 | |
105 DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl); | |
106 }; | |
107 | |
108 } // namespace | 93 } // namespace |
109 | 94 |
110 BrowserChildProcessHost* BrowserChildProcessHost::Create( | 95 BrowserChildProcessHost* BrowserChildProcessHost::Create( |
111 content::ProcessType process_type, | 96 content::ProcessType process_type, |
112 BrowserChildProcessHostDelegate* delegate) { | 97 BrowserChildProcessHostDelegate* delegate) { |
113 return Create(process_type, delegate, std::string()); | 98 return Create(process_type, delegate, std::string()); |
114 } | 99 } |
115 | 100 |
116 BrowserChildProcessHost* BrowserChildProcessHost::Create( | 101 BrowserChildProcessHost* BrowserChildProcessHost::Create( |
117 content::ProcessType process_type, | 102 content::ProcessType process_type, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 166 |
182 if (!service_name.empty()) { | 167 if (!service_name.empty()) { |
183 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 168 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
184 child_connection_.reset( | 169 child_connection_.reset( |
185 new ChildConnection(service_name, base::StringPrintf("%d", data_.id), | 170 new ChildConnection(service_name, base::StringPrintf("%d", data_.id), |
186 pending_connection_.get(), | 171 pending_connection_.get(), |
187 ServiceManagerContext::GetConnectorForIOThread(), | 172 ServiceManagerContext::GetConnectorForIOThread(), |
188 base::ThreadTaskRunnerHandle::Get())); | 173 base::ThreadTaskRunnerHandle::Get())); |
189 } | 174 } |
190 | 175 |
191 // May be null during test execution. | |
192 if (ServiceManagerConnection::GetForProcess()) { | |
193 ServiceManagerConnection::GetForProcess()->AddConnectionFilter( | |
194 base::MakeUnique<ConnectionFilterImpl>()); | |
195 } | |
196 | |
197 // Create a persistent memory segment for subprocess histograms. | 176 // Create a persistent memory segment for subprocess histograms. |
198 CreateMetricsAllocator(); | 177 CreateMetricsAllocator(); |
199 } | 178 } |
200 | 179 |
201 BrowserChildProcessHostImpl::~BrowserChildProcessHostImpl() { | 180 BrowserChildProcessHostImpl::~BrowserChildProcessHostImpl() { |
202 g_child_process_list.Get().remove(this); | 181 g_child_process_list.Get().remove(this); |
203 | 182 |
204 if (notify_child_disconnected_) { | 183 if (notify_child_disconnected_) { |
205 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 184 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
206 base::Bind(&NotifyProcessHostDisconnected, data_)); | 185 base::Bind(&NotifyProcessHostDisconnected, data_)); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 void BrowserChildProcessHostImpl::ForceShutdown() { | 287 void BrowserChildProcessHostImpl::ForceShutdown() { |
309 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 288 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
310 g_child_process_list.Get().remove(this); | 289 g_child_process_list.Get().remove(this); |
311 child_process_host_->ForceShutdown(); | 290 child_process_host_->ForceShutdown(); |
312 } | 291 } |
313 | 292 |
314 void BrowserChildProcessHostImpl::AddFilter(BrowserMessageFilter* filter) { | 293 void BrowserChildProcessHostImpl::AddFilter(BrowserMessageFilter* filter) { |
315 child_process_host_->AddFilter(filter->GetFilter()); | 294 child_process_host_->AddFilter(filter->GetFilter()); |
316 } | 295 } |
317 | 296 |
318 service_manager::InterfaceProvider* | 297 void BrowserChildProcessHostImpl::BindInterface( |
319 BrowserChildProcessHostImpl::GetRemoteInterfaces() { | 298 const std::string& interface_name, |
| 299 mojo::ScopedMessagePipeHandle interface_pipe) { |
320 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 300 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
321 if (!child_connection_) | 301 if (!child_connection_) |
322 return nullptr; | 302 return; |
323 | 303 |
324 return child_connection_->GetRemoteInterfaces(); | 304 child_connection_->BindInterface(interface_name, std::move(interface_pipe)); |
325 } | 305 } |
326 | 306 |
327 void BrowserChildProcessHostImpl::HistogramBadMessageTerminated( | 307 void BrowserChildProcessHostImpl::HistogramBadMessageTerminated( |
328 int process_type) { | 308 int process_type) { |
329 UMA_HISTOGRAM_ENUMERATION("ChildProcess.BadMessgeTerminated", process_type, | 309 UMA_HISTOGRAM_ENUMERATION("ChildProcess.BadMessgeTerminated", process_type, |
330 PROCESS_TYPE_MAX); | 310 PROCESS_TYPE_MAX); |
331 } | 311 } |
332 | 312 |
333 base::TerminationStatus BrowserChildProcessHostImpl::GetTerminationStatus( | 313 base::TerminationStatus BrowserChildProcessHostImpl::GetTerminationStatus( |
334 bool known_dead, int* exit_code) { | 314 bool known_dead, int* exit_code) { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 591 |
612 #if defined(OS_WIN) | 592 #if defined(OS_WIN) |
613 | 593 |
614 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { | 594 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { |
615 OnChildDisconnected(); | 595 OnChildDisconnected(); |
616 } | 596 } |
617 | 597 |
618 #endif | 598 #endif |
619 | 599 |
620 } // namespace content | 600 } // namespace content |
OLD | NEW |