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/child/child_thread.h" | 5 #include "content/child/child_thread.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 channel_->AddFilter(histogram_message_filter_.get()); | 253 channel_->AddFilter(histogram_message_filter_.get()); |
254 channel_->AddFilter(sync_message_filter_.get()); | 254 channel_->AddFilter(sync_message_filter_.get()); |
255 channel_->AddFilter(new tracing::ChildTraceMessageFilter( | 255 channel_->AddFilter(new tracing::ChildTraceMessageFilter( |
256 ChildProcess::current()->io_message_loop_proxy())); | 256 ChildProcess::current()->io_message_loop_proxy())); |
257 channel_->AddFilter(resource_message_filter_.get()); | 257 channel_->AddFilter(resource_message_filter_.get()); |
258 channel_->AddFilter(quota_message_filter_->GetFilter()); | 258 channel_->AddFilter(quota_message_filter_->GetFilter()); |
259 channel_->AddFilter(service_worker_message_filter_->GetFilter()); | 259 channel_->AddFilter(service_worker_message_filter_->GetFilter()); |
260 | 260 |
261 // In single process mode we may already have a power monitor | 261 // In single process mode we may already have a power monitor |
262 if (!base::PowerMonitor::Get()) { | 262 if (!base::PowerMonitor::IsInitialized()) { |
263 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source( | 263 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source( |
264 new PowerMonitorBroadcastSource()); | 264 new PowerMonitorBroadcastSource()); |
265 channel_->AddFilter(power_monitor_source->GetMessageFilter()); | 265 channel_->AddFilter(power_monitor_source->GetMessageFilter()); |
266 | 266 |
267 power_monitor_.reset(new base::PowerMonitor( | 267 base::PowerMonitor::Initialize( |
268 power_monitor_source.PassAs<base::PowerMonitorSource>())); | 268 power_monitor_source.PassAs<base::PowerMonitorSource>()); |
269 } | 269 } |
270 | 270 |
271 #if defined(OS_POSIX) | 271 #if defined(OS_POSIX) |
272 // Check that --process-type is specified so we don't do this in unit tests | 272 // Check that --process-type is specified so we don't do this in unit tests |
273 // and single-process mode. | 273 // and single-process mode. |
274 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) | 274 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) |
275 channel_->AddFilter(new SuicideOnChannelErrorFilter()); | 275 channel_->AddFilter(new SuicideOnChannelErrorFilter()); |
276 #endif | 276 #endif |
277 | 277 |
278 base::MessageLoop::current()->PostDelayedTask( | 278 base::MessageLoop::current()->PostDelayedTask( |
(...skipping 22 matching lines...) Expand all Loading... |
301 } | 301 } |
302 | 302 |
303 ChildThread::~ChildThread() { | 303 ChildThread::~ChildThread() { |
304 #ifdef IPC_MESSAGE_LOG_ENABLED | 304 #ifdef IPC_MESSAGE_LOG_ENABLED |
305 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 305 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
306 #endif | 306 #endif |
307 | 307 |
308 channel_->RemoveFilter(histogram_message_filter_.get()); | 308 channel_->RemoveFilter(histogram_message_filter_.get()); |
309 channel_->RemoveFilter(sync_message_filter_.get()); | 309 channel_->RemoveFilter(sync_message_filter_.get()); |
310 | 310 |
| 311 base::PowerMonitor::Shutdown(); |
| 312 |
311 // The ChannelProxy object caches a pointer to the IPC thread, so need to | 313 // The ChannelProxy object caches a pointer to the IPC thread, so need to |
312 // reset it as it's not guaranteed to outlive this object. | 314 // reset it as it's not guaranteed to outlive this object. |
313 // NOTE: this also has the side-effect of not closing the main IPC channel to | 315 // NOTE: this also has the side-effect of not closing the main IPC channel to |
314 // the browser process. This is needed because this is the signal that the | 316 // the browser process. This is needed because this is the signal that the |
315 // browser uses to know that this process has died, so we need it to be alive | 317 // browser uses to know that this process has died, so we need it to be alive |
316 // until this process is shut down, and the OS closes the handle | 318 // until this process is shut down, and the OS closes the handle |
317 // automatically. We used to watch the object handle on Windows to do this, | 319 // automatically. We used to watch the object handle on Windows to do this, |
318 // but it wasn't possible to do so on POSIX. | 320 // but it wasn't possible to do so on POSIX. |
319 channel_->ClearIPCTaskRunner(); | 321 channel_->ClearIPCTaskRunner(); |
320 g_lazy_tls.Pointer()->Set(NULL); | 322 g_lazy_tls.Pointer()->Set(NULL); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 // inflight that would addref it. | 531 // inflight that would addref it. |
530 Send(new ChildProcessHostMsg_ShutdownRequest); | 532 Send(new ChildProcessHostMsg_ShutdownRequest); |
531 } | 533 } |
532 | 534 |
533 void ChildThread::EnsureConnected() { | 535 void ChildThread::EnsureConnected() { |
534 VLOG(0) << "ChildThread::EnsureConnected()"; | 536 VLOG(0) << "ChildThread::EnsureConnected()"; |
535 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 537 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
536 } | 538 } |
537 | 539 |
538 } // namespace content | 540 } // namespace content |
OLD | NEW |