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 "base/allocator/allocator_extension.h" | 7 #include "base/allocator/allocator_extension.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/process/kill.h" | 12 #include "base/process/kill.h" |
13 #include "base/process/process_handle.h" | 13 #include "base/process/process_handle.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/threading/thread_local.h" | 15 #include "base/threading/thread_local.h" |
16 #include "base/tracked_objects.h" | 16 #include "base/tracked_objects.h" |
17 #include "components/tracing/child_trace_message_filter.h" | 17 #include "components/tracing/child_trace_message_filter.h" |
18 #include "content/child/child_histogram_message_filter.h" | 18 #include "content/child/child_histogram_message_filter.h" |
19 #include "content/child/child_process.h" | 19 #include "content/child/child_process.h" |
20 #include "content/child/child_resource_message_filter.h" | 20 #include "content/child/child_resource_message_filter.h" |
21 #include "content/child/fileapi/file_system_dispatcher.h" | 21 #include "content/child/fileapi/file_system_dispatcher.h" |
22 #include "content/child/power_monitor_broadcast_source.h" | |
22 #include "content/child/quota_dispatcher.h" | 23 #include "content/child/quota_dispatcher.h" |
23 #include "content/child/quota_message_filter.h" | 24 #include "content/child/quota_message_filter.h" |
24 #include "content/child/resource_dispatcher.h" | 25 #include "content/child/resource_dispatcher.h" |
25 #include "content/child/socket_stream_dispatcher.h" | 26 #include "content/child/socket_stream_dispatcher.h" |
26 #include "content/child/thread_safe_sender.h" | 27 #include "content/child/thread_safe_sender.h" |
27 #include "content/common/child_process_messages.h" | 28 #include "content/common/child_process_messages.h" |
28 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
29 #include "ipc/ipc_logging.h" | 30 #include "ipc/ipc_logging.h" |
30 #include "ipc/ipc_switches.h" | 31 #include "ipc/ipc_switches.h" |
31 #include "ipc/ipc_sync_channel.h" | 32 #include "ipc/ipc_sync_channel.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), | 149 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), |
149 quota_message_filter_.get())); | 150 quota_message_filter_.get())); |
150 | 151 |
151 channel_->AddFilter(histogram_message_filter_.get()); | 152 channel_->AddFilter(histogram_message_filter_.get()); |
152 channel_->AddFilter(sync_message_filter_.get()); | 153 channel_->AddFilter(sync_message_filter_.get()); |
153 channel_->AddFilter(new tracing::ChildTraceMessageFilter( | 154 channel_->AddFilter(new tracing::ChildTraceMessageFilter( |
154 ChildProcess::current()->io_message_loop_proxy())); | 155 ChildProcess::current()->io_message_loop_proxy())); |
155 channel_->AddFilter(resource_message_filter_.get()); | 156 channel_->AddFilter(resource_message_filter_.get()); |
156 channel_->AddFilter(quota_message_filter_.get()); | 157 channel_->AddFilter(quota_message_filter_.get()); |
157 | 158 |
159 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source( | |
160 new PowerMonitorBroadcastSource(message_loop_->message_loop_proxy())); | |
jam
2013/07/31 17:27:17
nit: no need to pass message_loop_ here, PowerMoni
| |
161 channel_->AddFilter(power_monitor_source->GetMessageFilter()); | |
162 | |
163 power_monitor_.reset(new base::PowerMonitor( | |
164 power_monitor_source.PassAs<base::PowerMonitorSource>())); | |
165 | |
166 hi_res_timer_manager_.reset(new base::HighResolutionTimerManager); | |
167 | |
158 #if defined(OS_POSIX) | 168 #if defined(OS_POSIX) |
159 // Check that --process-type is specified so we don't do this in unit tests | 169 // Check that --process-type is specified so we don't do this in unit tests |
160 // and single-process mode. | 170 // and single-process mode. |
161 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) | 171 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) |
162 channel_->AddFilter(new SuicideOnChannelErrorFilter()); | 172 channel_->AddFilter(new SuicideOnChannelErrorFilter()); |
163 #endif | 173 #endif |
164 | 174 |
165 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTraceToConsole)) { | 175 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTraceToConsole)) { |
166 std::string category_string = | 176 std::string category_string = |
167 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 177 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 // inflight that would addref it. | 422 // inflight that would addref it. |
413 Send(new ChildProcessHostMsg_ShutdownRequest); | 423 Send(new ChildProcessHostMsg_ShutdownRequest); |
414 } | 424 } |
415 | 425 |
416 void ChildThread::EnsureConnected() { | 426 void ChildThread::EnsureConnected() { |
417 LOG(INFO) << "ChildThread::EnsureConnected()"; | 427 LOG(INFO) << "ChildThread::EnsureConnected()"; |
418 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 428 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
419 } | 429 } |
420 | 430 |
421 } // namespace content | 431 } // namespace content |
OLD | NEW |