Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #if defined(OS_WIN) | |
| 6 #include <windows.h> | |
| 7 #endif | |
| 8 | |
| 5 #include "chrome/browser/gpu_process_host.h" | 9 #include "chrome/browser/gpu_process_host.h" |
| 6 | 10 |
| 7 #include "app/app_switches.h" | 11 #include "app/app_switches.h" |
| 8 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 9 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 10 #include "base/string_piece.h" | 14 #include "base/string_piece.h" |
| 11 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 12 #include "chrome/browser/browser_thread.h" | 16 #include "chrome/browser/browser_thread.h" |
| 13 #include "chrome/browser/gpu_process_host_ui_shim.h" | 17 #include "chrome/browser/gpu_process_host_ui_shim.h" |
| 14 #include "chrome/browser/renderer_host/render_widget_host.h" | 18 #include "chrome/browser/renderer_host/render_widget_host.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 170 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 167 DCHECK(CalledOnValidThread()); | 171 DCHECK(CalledOnValidThread()); |
| 168 RouteOnUIThread(message); | 172 RouteOnUIThread(message); |
| 169 return true; | 173 return true; |
| 170 } | 174 } |
| 171 | 175 |
| 172 bool GpuProcessHost::CanShutdown() { | 176 bool GpuProcessHost::CanShutdown() { |
| 173 return true; | 177 return true; |
| 174 } | 178 } |
| 175 | 179 |
| 180 void GpuProcessHost::OnProcessLaunched() { | |
| 181 // Send the GPU process handle to the UI thread before it has to any | |
|
Ken Russell (switch to Gerrit)
2011/02/24 19:48:47
Remove "any" at end of line.
| |
| 182 // respond to any requests to establish a GPU channel. The response | |
| 183 // to such requests require that the GPU process handle be known. | |
| 184 base::ProcessHandle child_handle; | |
| 185 #if defined(OS_WIN) | |
| 186 DuplicateHandle(base::GetCurrentProcessHandle(), | |
| 187 handle(), | |
| 188 base::GetCurrentProcessHandle(), | |
| 189 &child_handle, | |
| 190 PROCESS_DUP_HANDLE, | |
| 191 FALSE, | |
| 192 0); | |
| 193 #else | |
| 194 child_handle = handle(); | |
| 195 #endif | |
| 196 | |
| 197 BrowserThread::PostTask( | |
| 198 BrowserThread::UI, | |
| 199 FROM_HERE, | |
| 200 NewRunnableFunction(&GpuProcessHostUIShim::NotifyGpuProcessLaunched, | |
| 201 host_id_, | |
| 202 child_handle)); | |
| 203 } | |
| 204 | |
| 176 namespace { | 205 namespace { |
| 177 | 206 |
| 178 void SendOutstandingRepliesDispatcher(int host_id) { | 207 void SendOutstandingRepliesDispatcher(int host_id) { |
| 179 GpuProcessHostUIShim *ui_shim = GpuProcessHostUIShim::FromID(host_id); | 208 GpuProcessHostUIShim *ui_shim = GpuProcessHostUIShim::FromID(host_id); |
| 180 DCHECK(ui_shim); | 209 DCHECK(ui_shim); |
| 181 ui_shim->SendOutstandingReplies(); | 210 ui_shim->SendOutstandingReplies(); |
| 182 } | 211 } |
| 183 | 212 |
| 184 void SendOutstandingReplies(int host_id) { | 213 void SendOutstandingReplies(int host_id) { |
| 185 BrowserThread::PostTask( | 214 BrowserThread::PostTask( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 base::Thread::Options options; | 255 base::Thread::Options options; |
| 227 #if defined(OS_LINUX) | 256 #if defined(OS_LINUX) |
| 228 options.message_loop_type = MessageLoop::TYPE_IO; | 257 options.message_loop_type = MessageLoop::TYPE_IO; |
| 229 #else | 258 #else |
| 230 options.message_loop_type = MessageLoop::TYPE_UI; | 259 options.message_loop_type = MessageLoop::TYPE_UI; |
| 231 #endif | 260 #endif |
| 232 | 261 |
| 233 if (!thread->StartWithOptions(options)) | 262 if (!thread->StartWithOptions(options)) |
| 234 return false; | 263 return false; |
| 235 | 264 |
| 265 set_handle(base::GetCurrentProcessHandle()); | |
| 266 OnProcessLaunched(); | |
| 267 | |
| 236 return true; | 268 return true; |
| 237 } | 269 } |
| 238 | 270 |
| 239 CommandLine::StringType gpu_launcher = | 271 CommandLine::StringType gpu_launcher = |
| 240 browser_command_line.GetSwitchValueNative(switches::kGpuLauncher); | 272 browser_command_line.GetSwitchValueNative(switches::kGpuLauncher); |
| 241 | 273 |
| 242 FilePath exe_path = ChildProcessHost::GetChildPath(gpu_launcher.empty()); | 274 FilePath exe_path = ChildProcessHost::GetChildPath(gpu_launcher.empty()); |
| 243 if (exe_path.empty()) | 275 if (exe_path.empty()) |
| 244 return false; | 276 return false; |
| 245 | 277 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 #elif defined(OS_POSIX) | 310 #elif defined(OS_POSIX) |
| 279 false, // Never use the zygote (GPU plugin can't be sandboxed). | 311 false, // Never use the zygote (GPU plugin can't be sandboxed). |
| 280 base::environment_vector(), | 312 base::environment_vector(), |
| 281 #endif | 313 #endif |
| 282 cmd_line); | 314 cmd_line); |
| 283 | 315 |
| 284 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", | 316 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", |
| 285 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); | 317 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); |
| 286 return true; | 318 return true; |
| 287 } | 319 } |
| OLD | NEW |