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/browser_gpu_channel_host_factory.h" | 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 base::Bind(&BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO, | 88 base::Bind(&BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO, |
89 establish_request)); | 89 establish_request)); |
90 return establish_request; | 90 return establish_request; |
91 } | 91 } |
92 | 92 |
93 BrowserGpuChannelHostFactory::EstablishRequest::EstablishRequest( | 93 BrowserGpuChannelHostFactory::EstablishRequest::EstablishRequest( |
94 CauseForGpuLaunch cause, | 94 CauseForGpuLaunch cause, |
95 int gpu_client_id, | 95 int gpu_client_id, |
96 uint64_t gpu_client_tracing_id, | 96 uint64_t gpu_client_tracing_id, |
97 int gpu_host_id) | 97 int gpu_host_id) |
98 : event_(false, false), | 98 : event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 99 base::WaitableEvent::InitialState::NOT_SIGNALED), |
99 cause_for_gpu_launch_(cause), | 100 cause_for_gpu_launch_(cause), |
100 gpu_client_id_(gpu_client_id), | 101 gpu_client_id_(gpu_client_id), |
101 gpu_client_tracing_id_(gpu_client_tracing_id), | 102 gpu_client_tracing_id_(gpu_client_tracing_id), |
102 gpu_host_id_(gpu_host_id), | 103 gpu_host_id_(gpu_host_id), |
103 reused_gpu_process_(false), | 104 reused_gpu_process_(false), |
104 finished_(false), | 105 finished_(false), |
105 main_task_runner_(base::ThreadTaskRunnerHandle::Get()) { | 106 main_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
106 } | |
107 | 107 |
108 void BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO() { | 108 void BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO() { |
109 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. | 109 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
110 tracked_objects::ScopedTracker tracking_profile( | 110 tracked_objects::ScopedTracker tracking_profile( |
111 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 111 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
112 "477117 " | 112 "477117 " |
113 "BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO")); | 113 "BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO")); |
114 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); | 114 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
115 if (!host) { | 115 if (!host) { |
116 host = GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 116 host = GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 void BrowserGpuChannelHostFactory::Terminate() { | 220 void BrowserGpuChannelHostFactory::Terminate() { |
221 DCHECK(instance_); | 221 DCHECK(instance_); |
222 delete instance_; | 222 delete instance_; |
223 instance_ = NULL; | 223 instance_ = NULL; |
224 } | 224 } |
225 | 225 |
226 BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() | 226 BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() |
227 : gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 227 : gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
228 gpu_client_tracing_id_(ChildProcessHost::kBrowserTracingProcessId), | 228 gpu_client_tracing_id_(ChildProcessHost::kBrowserTracingProcessId), |
229 shutdown_event_(new base::WaitableEvent(true, false)), | 229 shutdown_event_(new base::WaitableEvent( |
| 230 base::WaitableEvent::ResetPolicy::MANUAL, |
| 231 base::WaitableEvent::InitialState::NOT_SIGNALED)), |
230 gpu_memory_buffer_manager_( | 232 gpu_memory_buffer_manager_( |
231 new BrowserGpuMemoryBufferManager(gpu_client_id_, | 233 new BrowserGpuMemoryBufferManager(gpu_client_id_, |
232 gpu_client_tracing_id_)), | 234 gpu_client_tracing_id_)), |
233 gpu_host_id_(0) { | 235 gpu_host_id_(0) { |
234 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 236 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
235 switches::kDisableGpuShaderDiskCache)) { | 237 switches::kDisableGpuShaderDiskCache)) { |
236 DCHECK(GetContentClient()); | 238 DCHECK(GetContentClient()); |
237 base::FilePath cache_dir = | 239 base::FilePath cache_dir = |
238 GetContentClient()->browser()->GetShaderDiskCacheDirectory(); | 240 GetContentClient()->browser()->GetShaderDiskCacheDirectory(); |
239 if (!cache_dir.empty()) { | 241 if (!cache_dir.empty()) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 371 } |
370 | 372 |
371 // static | 373 // static |
372 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( | 374 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( |
373 int gpu_client_id, | 375 int gpu_client_id, |
374 const base::FilePath& cache_dir) { | 376 const base::FilePath& cache_dir) { |
375 ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir); | 377 ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir); |
376 } | 378 } |
377 | 379 |
378 } // namespace content | 380 } // namespace content |
OLD | NEW |