Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: content/child/child_thread.cc

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing windows unit test errors Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/child/child_thread.h ('k') | content/child/power_monitor_broadcast_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // In single process mode we may already have a power monitor
160 if (!base::PowerMonitor::Get()) {
161 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source(
162 new PowerMonitorBroadcastSource());
163 channel_->AddFilter(power_monitor_source->GetMessageFilter());
164
165 power_monitor_.reset(new base::PowerMonitor(
166 power_monitor_source.PassAs<base::PowerMonitorSource>()));
167 }
168
158 #if defined(OS_POSIX) 169 #if defined(OS_POSIX)
159 // Check that --process-type is specified so we don't do this in unit tests 170 // Check that --process-type is specified so we don't do this in unit tests
160 // and single-process mode. 171 // and single-process mode.
161 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) 172 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType))
162 channel_->AddFilter(new SuicideOnChannelErrorFilter()); 173 channel_->AddFilter(new SuicideOnChannelErrorFilter());
163 #endif 174 #endif
164 175
165 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTraceToConsole)) { 176 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTraceToConsole)) {
166 std::string category_string = 177 std::string category_string =
167 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 178 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 // inflight that would addref it. 423 // inflight that would addref it.
413 Send(new ChildProcessHostMsg_ShutdownRequest); 424 Send(new ChildProcessHostMsg_ShutdownRequest);
414 } 425 }
415 426
416 void ChildThread::EnsureConnected() { 427 void ChildThread::EnsureConnected() {
417 LOG(INFO) << "ChildThread::EnsureConnected()"; 428 LOG(INFO) << "ChildThread::EnsureConnected()";
418 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); 429 base::KillProcess(base::GetCurrentProcessHandle(), 0, false);
419 } 430 }
420 431
421 } // namespace content 432 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread.h ('k') | content/child/power_monitor_broadcast_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698