OLD | NEW |
1 // Copyright (c) 2011 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/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "content/common/child_process.h" | 14 #include "content/common/child_process.h" |
15 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
16 #include "content/public/common/content_client.h" | |
17 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
18 #include "content/gpu/gpu_info_collector.h" | 17 #include "content/gpu/gpu_info_collector.h" |
19 #include "content/gpu/gpu_watchdog_thread.h" | 18 #include "content/gpu/gpu_watchdog_thread.h" |
20 #include "ipc/ipc_channel_handle.h" | 19 #include "ipc/ipc_channel_handle.h" |
21 #include "ui/gfx/gl/gl_implementation.h" | 20 #include "ui/gfx/gl/gl_implementation.h" |
22 | 21 |
23 const int kGpuTimeout = 10000; | 22 const int kGpuTimeout = 10000; |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 bool GpuProcessLogMessageHandler(int severity, | 26 bool GpuProcessLogMessageHandler(int severity, |
28 const char* file, int line, | 27 const char* file, int line, |
29 size_t message_start, | 28 size_t message_start, |
30 const std::string& str) { | 29 const std::string& str) { |
31 std::string header = str.substr(0, message_start); | 30 std::string header = str.substr(0, message_start); |
32 std::string message = str.substr(message_start); | 31 std::string message = str.substr(message_start); |
33 ChildThread::current()->Send( | 32 ChildThread::current()->Send( |
34 new GpuHostMsg_OnLogMessage(severity, header, message)); | 33 new GpuHostMsg_OnLogMessage(severity, header, message)); |
35 return false; | 34 return false; |
36 } | 35 } |
37 | 36 |
38 } // namespace | 37 } // namespace |
39 | 38 |
40 GpuChildThread::GpuChildThread(bool dead_on_arrival) | 39 GpuChildThread::GpuChildThread(bool dead_on_arrival, |
41 : dead_on_arrival_(dead_on_arrival) { | 40 const content::GPUInfo& gpu_info) |
| 41 : dead_on_arrival_(dead_on_arrival), |
| 42 gpu_info_(gpu_info) { |
42 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
43 target_services_ = NULL; | 44 target_services_ = NULL; |
44 collecting_dx_diagnostics_ = false; | 45 collecting_dx_diagnostics_ = false; |
45 #endif | 46 #endif |
46 } | 47 } |
47 | 48 |
48 GpuChildThread::GpuChildThread(const std::string& channel_id) | 49 GpuChildThread::GpuChildThread(const std::string& channel_id) |
49 : ChildThread(channel_id), | 50 : ChildThread(channel_id), |
50 dead_on_arrival_(false) { | 51 dead_on_arrival_(false) { |
51 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
52 target_services_ = NULL; | 53 target_services_ = NULL; |
53 collecting_dx_diagnostics_ = false; | 54 collecting_dx_diagnostics_ = false; |
54 #endif | 55 #endif |
| 56 if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info_)) { |
| 57 LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo failed"; |
| 58 } |
55 } | 59 } |
56 | 60 |
57 | 61 |
58 GpuChildThread::~GpuChildThread() { | 62 GpuChildThread::~GpuChildThread() { |
59 logging::SetLogMessageHandler(NULL); | 63 logging::SetLogMessageHandler(NULL); |
60 } | 64 } |
61 | 65 |
62 void GpuChildThread::Init(const base::Time& process_start_time) { | 66 void GpuChildThread::Init(const base::Time& process_start_time) { |
63 process_start_time_ = process_start_time; | 67 process_start_time_ = process_start_time; |
64 } | 68 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 MessageLoop::current()->Quit(); | 100 MessageLoop::current()->Quit(); |
97 return; | 101 return; |
98 } | 102 } |
99 | 103 |
100 // We don't need to pipe log messages if we are running the GPU thread in | 104 // We don't need to pipe log messages if we are running the GPU thread in |
101 // the browser process. | 105 // the browser process. |
102 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) && | 106 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) && |
103 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) | 107 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) |
104 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 108 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
105 | 109 |
106 // Always set gpu info and send it back, even if there's an error and it's | |
107 // impartially collected. | |
108 bool succeeded = gpu_info_collector::CollectGraphicsInfo(&gpu_info_); | |
109 content::GetContentClient()->SetGpuInfo(gpu_info_); | |
110 LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo complete. success = " << | |
111 succeeded; | |
112 | |
113 // Record initialization only after collecting the GPU info because that can | 110 // Record initialization only after collecting the GPU info because that can |
114 // take a significant amount of time. | 111 // take a significant amount of time. |
115 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 112 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
116 | 113 |
117 // In addition to disabling the watchdog if the command line switch is | 114 // In addition to disabling the watchdog if the command line switch is |
118 // present, disable it in two other cases. OSMesa is expected to run very | 115 // present, disable it in two other cases. OSMesa is expected to run very |
119 // slowly. Also disable the watchdog on valgrind because the code is expected | 116 // slowly. Also disable the watchdog on valgrind because the code is expected |
120 // to run slowly in that case. | 117 // to run slowly in that case. |
121 bool enable_watchdog = | 118 bool enable_watchdog = |
122 !CommandLine::ForCurrentProcess()->HasSwitch( | 119 !CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // Runs on the main thread. | 226 // Runs on the main thread. |
230 void GpuChildThread::SetDxDiagnostics(GpuChildThread* thread, | 227 void GpuChildThread::SetDxDiagnostics(GpuChildThread* thread, |
231 const content::DxDiagNode& node) { | 228 const content::DxDiagNode& node) { |
232 thread->gpu_info_.dx_diagnostics = node; | 229 thread->gpu_info_.dx_diagnostics = node; |
233 thread->gpu_info_.finalized = true; | 230 thread->gpu_info_.finalized = true; |
234 thread->collecting_dx_diagnostics_ = false; | 231 thread->collecting_dx_diagnostics_ = false; |
235 thread->Send(new GpuHostMsg_GraphicsInfoCollected(thread->gpu_info_)); | 232 thread->Send(new GpuHostMsg_GraphicsInfoCollected(thread->gpu_info_)); |
236 } | 233 } |
237 | 234 |
238 #endif | 235 #endif |
OLD | NEW |