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

Side by Side Diff: content/gpu/gpu_main.cc

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 5 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
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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/power_monitor/power_monitor.h"
14 #include "base/rand_util.h" 15 #include "base/rand_util.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/threading/platform_thread.h" 18 #include "base/threading/platform_thread.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "content/child/child_process.h" 20 #include "content/child/child_process.h"
20 #include "content/common/gpu/gpu_config.h" 21 #include "content/common/gpu/gpu_config.h"
21 #include "content/common/gpu/gpu_messages.h" 22 #include "content/common/gpu/gpu_messages.h"
23 #include "content/common/power_monitor_broadcast_source.h"
22 #include "content/common/sandbox_linux.h" 24 #include "content/common/sandbox_linux.h"
23 #include "content/gpu/gpu_child_thread.h" 25 #include "content/gpu/gpu_child_thread.h"
24 #include "content/gpu/gpu_process.h" 26 #include "content/gpu/gpu_process.h"
25 #include "content/gpu/gpu_watchdog_thread.h" 27 #include "content/gpu/gpu_watchdog_thread.h"
26 #include "content/public/common/content_client.h" 28 #include "content/public/common/content_client.h"
27 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
28 #include "content/public/common/main_function_params.h" 30 #include "content/public/common/main_function_params.h"
29 #include "crypto/hmac.h" 31 #include "crypto/hmac.h"
30 #include "gpu/config/gpu_info_collector.h" 32 #include "gpu/config/gpu_info_collector.h"
31 #include "ui/gl/gl_implementation.h" 33 #include "ui/gl/gl_implementation.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 #endif 164 #endif
163 165
164 bool delayed_watchdog_enable = false; 166 bool delayed_watchdog_enable = false;
165 167
166 #if defined(OS_CHROMEOS) 168 #if defined(OS_CHROMEOS)
167 // Don't start watchdog immediately, to allow developers to switch to VT2 on 169 // Don't start watchdog immediately, to allow developers to switch to VT2 on
168 // startup. 170 // startup.
169 delayed_watchdog_enable = true; 171 delayed_watchdog_enable = true;
170 #endif 172 #endif
171 173
174 PowerMonitorBroadcastSource* power_monitor_source =
175 new PowerMonitorBroadcastSource();
176 base::PowerMonitor power_monitor(power_monitor_source);
vandebo (ex-Chrome) 2013/07/02 22:53:12 nit: base::PowerMonitor power_monitor(new PowerMon
bajones 2013/07/03 20:32:27 See line 292. The power_monitor_source is referenc
172 scoped_refptr<GpuWatchdogThread> watchdog_thread; 177 scoped_refptr<GpuWatchdogThread> watchdog_thread;
173 178
174 // Start the GPU watchdog only after anything that is expected to be time 179 // Start the GPU watchdog only after anything that is expected to be time
175 // consuming has completed, otherwise the process is liable to be aborted. 180 // consuming has completed, otherwise the process is liable to be aborted.
176 if (enable_watchdog && !delayed_watchdog_enable) { 181 if (enable_watchdog && !delayed_watchdog_enable) {
177 watchdog_thread = new GpuWatchdogThread(kGpuTimeout); 182 watchdog_thread = new GpuWatchdogThread(kGpuTimeout);
178 watchdog_thread->Start(); 183 watchdog_thread->Start();
179 } 184 }
180 185
181 gpu::GPUInfo gpu_info; 186 gpu::GPUInfo gpu_info;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 281 }
277 282
278 logging::SetLogMessageHandler(NULL); 283 logging::SetLogMessageHandler(NULL);
279 284
280 GpuProcess gpu_process; 285 GpuProcess gpu_process;
281 286
282 GpuChildThread* child_thread = new GpuChildThread(watchdog_thread.get(), 287 GpuChildThread* child_thread = new GpuChildThread(watchdog_thread.get(),
283 dead_on_arrival, 288 dead_on_arrival,
284 gpu_info, 289 gpu_info,
285 deferred_messages.Get()); 290 deferred_messages.Get());
291
292 child_thread->channel()->AddFilter(power_monitor_source->MessageFilter());
293
286 while (!deferred_messages.Get().empty()) 294 while (!deferred_messages.Get().empty())
287 deferred_messages.Get().pop(); 295 deferred_messages.Get().pop();
288 296
289 child_thread->Init(start_time); 297 child_thread->Init(start_time);
290 298
291 gpu_process.set_main_thread(child_thread); 299 gpu_process.set_main_thread(child_thread);
292 300
293 { 301 {
294 TRACE_EVENT0("gpu", "Run Message Loop"); 302 TRACE_EVENT0("gpu", "Run Message Loop");
295 main_message_loop.Run(); 303 main_message_loop.Run();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 return true; 431 return true;
424 } 432 }
425 433
426 return false; 434 return false;
427 } 435 }
428 #endif // defined(OS_WIN) 436 #endif // defined(OS_WIN)
429 437
430 } // namespace. 438 } // namespace.
431 439
432 } // namespace content 440 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698