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/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // Don't grant further access to GPU if it is not allowed. | 194 // Don't grant further access to GPU if it is not allowed. |
195 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); | 195 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); |
196 if (gpu_data_manager != NULL && !gpu_data_manager->GpuAccessAllowed()) | 196 if (gpu_data_manager != NULL && !gpu_data_manager->GpuAccessAllowed()) |
197 return NULL; | 197 return NULL; |
198 | 198 |
199 // The current policy is to ignore the renderer ID and use a single GPU | 199 // The current policy is to ignore the renderer ID and use a single GPU |
200 // process (the first valid host in the host-id map) for all renderers. Later | 200 // process (the first valid host in the host-id map) for all renderers. Later |
201 // this will be extended to allow the use of multiple GPU processes. | 201 // this will be extended to allow the use of multiple GPU processes. |
202 for (IDMap<GpuProcessHost>::iterator it(g_hosts_by_id.Pointer()); | 202 for (IDMap<GpuProcessHost>::iterator it(g_hosts_by_id.Pointer()); |
203 !it.IsAtEnd(); it.Advance()) { | 203 !it.IsAtEnd(); it.Advance()) { |
204 GpuProcessHost *host = it.GetCurrentValue(); | 204 GpuProcessHost* host = it.GetCurrentValue(); |
205 | 205 |
206 if (host->sandboxed() != (client_id != 0)) | 206 if (host->sandboxed() != (client_id != 0)) |
207 continue; | 207 continue; |
208 | 208 |
209 if (HostIsValid(host)) | 209 if (HostIsValid(host)) |
210 return host; | 210 return host; |
211 } | 211 } |
212 | 212 |
213 if (cause == content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH) | 213 if (cause == content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH) |
214 return NULL; | 214 return NULL; |
(...skipping 23 matching lines...) Expand all Loading... |
238 &SendGpuProcessMessage, client_id, cause, message)); | 238 &SendGpuProcessMessage, client_id, cause, message)); |
239 } | 239 } |
240 | 240 |
241 // static | 241 // static |
242 GpuProcessHost* GpuProcessHost::FromID(int host_id) { | 242 GpuProcessHost* GpuProcessHost::FromID(int host_id) { |
243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
244 | 244 |
245 if (host_id == 0) | 245 if (host_id == 0) |
246 return NULL; | 246 return NULL; |
247 | 247 |
248 GpuProcessHost *host = g_hosts_by_id.Pointer()->Lookup(host_id); | 248 GpuProcessHost* host = g_hosts_by_id.Pointer()->Lookup(host_id); |
249 if (HostIsValid(host)) | 249 if (HostIsValid(host)) |
250 return host; | 250 return host; |
251 | 251 |
252 return NULL; | 252 return NULL; |
253 } | 253 } |
254 | 254 |
255 GpuProcessHost::GpuProcessHost(int host_id, bool sandboxed) | 255 GpuProcessHost::GpuProcessHost(int host_id, bool sandboxed) |
256 : host_id_(host_id), | 256 : host_id_(host_id), |
257 gpu_process_(base::kNullProcessHandle), | 257 gpu_process_(base::kNullProcessHandle), |
258 in_process_(false), | 258 in_process_(false), |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // of this child window. Unfortunately it might always be necessary for | 359 // of this child window. Unfortunately it might always be necessary for |
360 // Windows XP because we cannot share the backing store textures between | 360 // Windows XP because we cannot share the backing store textures between |
361 // processes. | 361 // processes. |
362 options.message_loop_type = MessageLoop::TYPE_UI; | 362 options.message_loop_type = MessageLoop::TYPE_UI; |
363 #else | 363 #else |
364 options.message_loop_type = MessageLoop::TYPE_IO; | 364 options.message_loop_type = MessageLoop::TYPE_IO; |
365 #endif | 365 #endif |
366 in_process_gpu_thread_->StartWithOptions(options); | 366 in_process_gpu_thread_->StartWithOptions(options); |
367 | 367 |
368 OnProcessLaunched(); // Fake a callback that the process is ready. | 368 OnProcessLaunched(); // Fake a callback that the process is ready. |
369 } else if (!LaunchGpuProcess(channel_id)) | 369 } else if (!LaunchGpuProcess(channel_id)) { |
370 return false; | 370 return false; |
| 371 } |
371 | 372 |
372 return Send(new GpuMsg_Initialize()); | 373 return Send(new GpuMsg_Initialize()); |
373 } | 374 } |
374 | 375 |
375 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { | 376 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { |
376 BrowserThread::PostTask( | 377 BrowserThread::PostTask( |
377 BrowserThread::UI, | 378 BrowserThread::UI, |
378 FROM_HERE, | 379 FROM_HERE, |
379 base::Bind(&RouteToGpuProcessHostUIShimTask, host_id_, message)); | 380 base::Bind(&RouteToGpuProcessHostUIShimTask, host_id_, message)); |
380 } | 381 } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 | 656 |
656 // If specified, prepend a launcher program to the command line. | 657 // If specified, prepend a launcher program to the command line. |
657 if (!gpu_launcher.empty()) | 658 if (!gpu_launcher.empty()) |
658 cmd_line->PrependWrapper(gpu_launcher); | 659 cmd_line->PrependWrapper(gpu_launcher); |
659 | 660 |
660 process_->Launch( | 661 process_->Launch( |
661 #if defined(OS_WIN) | 662 #if defined(OS_WIN) |
662 FilePath(), | 663 FilePath(), |
663 #elif defined(OS_POSIX) | 664 #elif defined(OS_POSIX) |
664 false, // Never use the zygote (GPU plugin can't be sandboxed). | 665 false, // Never use the zygote (GPU plugin can't be sandboxed). |
665 base::environment_vector(), | 666 base::EnvironmentVector(), |
666 #endif | 667 #endif |
667 cmd_line); | 668 cmd_line); |
668 process_launched_ = true; | 669 process_launched_ = true; |
669 | 670 |
670 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", | 671 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", |
671 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); | 672 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); |
672 return true; | 673 return true; |
673 } | 674 } |
674 | 675 |
675 void GpuProcessHost::SendOutstandingReplies() { | 676 void GpuProcessHost::SendOutstandingReplies() { |
(...skipping 13 matching lines...) Expand all Loading... |
689 const IPC::ChannelHandle& channel_handle, | 690 const IPC::ChannelHandle& channel_handle, |
690 base::ProcessHandle renderer_process_for_gpu, | 691 base::ProcessHandle renderer_process_for_gpu, |
691 const content::GPUInfo& gpu_info) { | 692 const content::GPUInfo& gpu_info) { |
692 callback.Run(channel_handle, renderer_process_for_gpu, gpu_info); | 693 callback.Run(channel_handle, renderer_process_for_gpu, gpu_info); |
693 } | 694 } |
694 | 695 |
695 void GpuProcessHost::CreateCommandBufferError( | 696 void GpuProcessHost::CreateCommandBufferError( |
696 const CreateCommandBufferCallback& callback, int32 route_id) { | 697 const CreateCommandBufferCallback& callback, int32 route_id) { |
697 callback.Run(route_id); | 698 callback.Run(route_id); |
698 } | 699 } |
OLD | NEW |