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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 void BrowserGpuChannelHostFactory::Initialize(bool establish_gpu_channel) { | 205 void BrowserGpuChannelHostFactory::Initialize(bool establish_gpu_channel) { |
206 DCHECK(!instance_); | 206 DCHECK(!instance_); |
207 instance_ = new BrowserGpuChannelHostFactory(); | 207 instance_ = new BrowserGpuChannelHostFactory(); |
208 if (establish_gpu_channel) { | 208 if (establish_gpu_channel) { |
209 instance_->EstablishGpuChannel(gpu::GpuChannelEstablishedCallback()); | 209 instance_->EstablishGpuChannel(gpu::GpuChannelEstablishedCallback()); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 void BrowserGpuChannelHostFactory::Terminate() { | 213 void BrowserGpuChannelHostFactory::Terminate() { |
214 DCHECK(instance_); | 214 DCHECK(instance_); |
215 | |
216 // Reset the |instance_| first so we don't receive any more Gpu Channel | |
217 // initialization requests as we run the existing callbacks. | |
218 instance_ = NULL; | |
219 | |
215 delete instance_; | 220 delete instance_; |
piman
2016/08/16 22:04:52
This would delete nullptr, i.e. leak - did you mea
Khushal
2016/08/16 22:11:58
Umm, yes. :l Done.
| |
216 instance_ = NULL; | |
217 } | 221 } |
218 | 222 |
219 BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() | 223 BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() |
220 : gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 224 : gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
221 gpu_client_tracing_id_(ChildProcessHost::kBrowserTracingProcessId), | 225 gpu_client_tracing_id_(ChildProcessHost::kBrowserTracingProcessId), |
222 shutdown_event_(new base::WaitableEvent( | 226 shutdown_event_(new base::WaitableEvent( |
223 base::WaitableEvent::ResetPolicy::MANUAL, | 227 base::WaitableEvent::ResetPolicy::MANUAL, |
224 base::WaitableEvent::InitialState::NOT_SIGNALED)), | 228 base::WaitableEvent::InitialState::NOT_SIGNALED)), |
225 gpu_memory_buffer_manager_( | 229 gpu_memory_buffer_manager_( |
226 new BrowserGpuMemoryBufferManager(gpu_client_id_, | 230 new BrowserGpuMemoryBufferManager(gpu_client_id_, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 } | 367 } |
364 | 368 |
365 // static | 369 // static |
366 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( | 370 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( |
367 int gpu_client_id, | 371 int gpu_client_id, |
368 const base::FilePath& cache_dir) { | 372 const base::FilePath& cache_dir) { |
369 ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir); | 373 ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir); |
370 } | 374 } |
371 | 375 |
372 } // namespace content | 376 } // namespace content |
OLD | NEW |