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/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" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || | 67 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || |
68 CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) { | 68 CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) { |
69 // For single process and in-process GPU mode, we need to load and | 69 // For single process and in-process GPU mode, we need to load and |
70 // initialize the GL implementation and locate the GL entry points here. | 70 // initialize the GL implementation and locate the GL entry points here. |
71 if (!gfx::GLSurface::InitializeOneOff()) { | 71 if (!gfx::GLSurface::InitializeOneOff()) { |
72 VLOG(1) << "gfx::GLSurface::InitializeOneOff()"; | 72 VLOG(1) << "gfx::GLSurface::InitializeOneOff()"; |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
| 77 |
77 GpuChildThread::~GpuChildThread() { | 78 GpuChildThread::~GpuChildThread() { |
78 logging::SetLogMessageHandler(NULL); | 79 logging::SetLogMessageHandler(NULL); |
79 } | 80 } |
80 | 81 |
81 void GpuChildThread::Init(const base::Time& process_start_time) { | 82 void GpuChildThread::Init(const base::Time& process_start_time) { |
82 process_start_time_ = process_start_time; | 83 process_start_time_ = process_start_time; |
83 } | 84 } |
84 | 85 |
85 bool GpuChildThread::Send(IPC::Message* msg) { | 86 bool GpuChildThread::Send(IPC::Message* msg) { |
86 // The GPU process must never send a synchronous IPC message to the browser | 87 // The GPU process must never send a synchronous IPC message to the browser |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // We don't need to pipe log messages if we are running the GPU thread in | 127 // We don't need to pipe log messages if we are running the GPU thread in |
127 // the browser process. | 128 // the browser process. |
128 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) && | 129 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) && |
129 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) | 130 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) |
130 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 131 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
131 | 132 |
132 // Record initialization only after collecting the GPU info because that can | 133 // Record initialization only after collecting the GPU info because that can |
133 // take a significant amount of time. | 134 // take a significant amount of time. |
134 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 135 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
135 | 136 |
| 137 |
136 // Defer creation of the render thread. This is to prevent it from handling | 138 // Defer creation of the render thread. This is to prevent it from handling |
137 // IPC messages before the sandbox has been enabled and all other necessary | 139 // IPC messages before the sandbox has been enabled and all other necessary |
138 // initialization has succeeded. | 140 // initialization has succeeded. |
139 gpu_channel_manager_.reset(new GpuChannelManager( | 141 gpu_channel_manager_.reset(new GpuChannelManager( |
140 this, | 142 this, |
141 watchdog_thread_, | 143 watchdog_thread_, |
142 ChildProcess::current()->io_message_loop_proxy(), | 144 ChildProcess::current()->io_message_loop_proxy(), |
143 ChildProcess::current()->GetShutDownEvent())); | 145 ChildProcess::current()->GetShutDownEvent())); |
144 | 146 |
| 147 #if defined(OS_LINUX) |
145 // Ensure the browser process receives the GPU info before a reply to any | 148 // Ensure the browser process receives the GPU info before a reply to any |
146 // subsequent IPC it might send. | 149 // subsequent IPC it might send. |
147 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); | 150 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); |
| 151 #endif |
148 } | 152 } |
149 | 153 |
150 void GpuChildThread::StopWatchdog() { | 154 void GpuChildThread::StopWatchdog() { |
151 if (watchdog_thread_.get()) { | 155 if (watchdog_thread_.get()) { |
152 watchdog_thread_->Stop(); | 156 watchdog_thread_->Stop(); |
153 } | 157 } |
154 } | 158 } |
155 | 159 |
156 void GpuChildThread::OnCollectGraphicsInfo() { | 160 void GpuChildThread::OnCollectGraphicsInfo() { |
157 #if defined(OS_WIN) | 161 #if defined(OS_WIN) |
158 // GPU full info collection should only happen on un-sandboxed GPU process | 162 // GPU full info collection should only happen on un-sandboxed GPU process |
159 // or single process/in-process gpu mode on Windows. | 163 // or single process/in-process gpu mode on Windows. |
160 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 164 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
161 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || | 165 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || |
162 command_line->HasSwitch(switches::kSingleProcess) || | 166 command_line->HasSwitch(switches::kSingleProcess) || |
163 command_line->HasSwitch(switches::kInProcessGPU)); | 167 command_line->HasSwitch(switches::kInProcessGPU)); |
164 #endif // OS_WIN | 168 #endif // OS_WIN |
165 | 169 |
166 if (!gpu_info_collector::CollectContextGraphicsInfo(&gpu_info_)) | 170 // Sandbox state is not part of the gpu info collection. It is determined |
| 171 // in GpuMain() and passed down to GpuChildThread. |
| 172 bool sandboxed = gpu_info_.sandboxed; |
| 173 if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info_)) |
167 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; | 174 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; |
| 175 gpu_info_.sandboxed = sandboxed; |
168 GetContentClient()->SetGpuInfo(gpu_info_); | 176 GetContentClient()->SetGpuInfo(gpu_info_); |
169 | 177 |
170 #if defined(OS_WIN) | 178 #if defined(OS_WIN) |
171 // This is slow, but it's the only thing the unsandboxed GPU process does, | 179 // This is slow, but it's the only thing the unsandboxed GPU process does, |
172 // and GpuDataManager prevents us from sending multiple collecting requests, | 180 // and GpuDataManager prevents us from sending multiple collecting requests, |
173 // so it's OK to be blocking. | 181 // so it's OK to be blocking. |
174 gpu_info_collector::GetDxDiagnostics(&gpu_info_.dx_diagnostics); | 182 gpu_info_collector::GetDxDiagnostics(&gpu_info_.dx_diagnostics); |
175 gpu_info_.finalized = true; | 183 gpu_info_.finalized = true; |
176 #endif // OS_WIN | 184 #endif // OS_WIN |
177 | 185 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // the future posting of tasks to the message loop. | 235 // the future posting of tasks to the message loop. |
228 if (watchdog_thread_->message_loop()) | 236 if (watchdog_thread_->message_loop()) |
229 watchdog_thread_->PostAcknowledge(); | 237 watchdog_thread_->PostAcknowledge(); |
230 // Prevent rearming. | 238 // Prevent rearming. |
231 watchdog_thread_->Stop(); | 239 watchdog_thread_->Stop(); |
232 } | 240 } |
233 } | 241 } |
234 | 242 |
235 } // namespace content | 243 } // namespace content |
236 | 244 |
OLD | NEW |