Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(834)

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.cc

Issue 2686243002: content/ui[Android]: Remove ContextProviderFactory. (Closed)
Patch Set: .. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 FROM_HERE, 244 FROM_HERE,
245 base::Bind( 245 base::Bind(
246 &BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO, 246 &BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO,
247 gpu_client_id_, cache_dir)); 247 gpu_client_id_, cache_dir));
248 } 248 }
249 } 249 }
250 } 250 }
251 251
252 BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() { 252 BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() {
253 DCHECK(IsMainThread()); 253 DCHECK(IsMainThread());
254 DCHECK(!in_shutdown_);
255
256 in_shutdown_ = true;
254 if (pending_request_.get()) 257 if (pending_request_.get())
255 pending_request_->Cancel(); 258 pending_request_->Cancel();
256 for (size_t n = 0; n < established_callbacks_.size(); n++) 259 for (size_t n = 0; n < established_callbacks_.size(); n++)
257 established_callbacks_[n].Run(nullptr); 260 established_callbacks_[n].Run(nullptr);
258 shutdown_event_->Signal(); 261 shutdown_event_->Signal();
259 if (gpu_channel_) { 262 if (gpu_channel_) {
260 gpu_channel_->DestroyChannel(); 263 gpu_channel_->DestroyChannel();
261 gpu_channel_ = NULL; 264 gpu_channel_ = NULL;
262 } 265 }
263 } 266 }
(...skipping 11 matching lines...) Expand all
275 BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) { 278 BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) {
276 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); 279 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory());
277 if (!shm->CreateAnonymous(size)) 280 if (!shm->CreateAnonymous(size))
278 return std::unique_ptr<base::SharedMemory>(); 281 return std::unique_ptr<base::SharedMemory>();
279 return shm; 282 return shm;
280 } 283 }
281 284
282 void BrowserGpuChannelHostFactory::EstablishGpuChannel( 285 void BrowserGpuChannelHostFactory::EstablishGpuChannel(
283 const gpu::GpuChannelEstablishedCallback& callback) { 286 const gpu::GpuChannelEstablishedCallback& callback) {
284 DCHECK(!service_manager::ServiceManagerIsRemote()); 287 DCHECK(!service_manager::ServiceManagerIsRemote());
288
289 // Don't queue any more requests if the factory is shutting down.
290 if (in_shutdown_)
boliu 2017/02/10 22:23:02 Hmm, I guess this is ok. But how hard is it to jus
Khushal 2017/02/10 22:42:39 Another thought was to set |instance_| to null in
boliu 2017/02/10 22:45:18 I'm actually worried about accidental infinite loo
Khushal 2017/02/10 22:51:30 Maye be we should always post to the message loop
boliu 2017/02/10 23:05:22 All depends on what happens in those callbacks tod
Khushal 2017/02/10 23:24:30 I had actually looked around when thinking about p
Khushal 2017/02/11 02:10:22 So I think the simplest solution would be to just
Khushal 2017/02/13 21:07:13 Done.
291 return;
292
285 if (gpu_channel_.get() && gpu_channel_->IsLost()) { 293 if (gpu_channel_.get() && gpu_channel_->IsLost()) {
286 DCHECK(!pending_request_.get()); 294 DCHECK(!pending_request_.get());
287 // Recreate the channel if it has been lost. 295 // Recreate the channel if it has been lost.
288 gpu_channel_->DestroyChannel(); 296 gpu_channel_->DestroyChannel();
289 gpu_channel_ = NULL; 297 gpu_channel_ = NULL;
290 } 298 }
291 299
292 if (!gpu_channel_.get() && !pending_request_.get()) { 300 if (!gpu_channel_.get() && !pending_request_.get()) {
293 // We should only get here if the context was lost. 301 // We should only get here if the context was lost.
294 pending_request_ = EstablishRequest::Create( 302 pending_request_ = EstablishRequest::Create(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 384 }
377 385
378 // static 386 // static
379 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( 387 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO(
380 int gpu_client_id, 388 int gpu_client_id,
381 const base::FilePath& cache_dir) { 389 const base::FilePath& cache_dir) {
382 GetShaderCacheFactorySingleton()->SetCacheInfo(gpu_client_id, cache_dir); 390 GetShaderCacheFactorySingleton()->SetCacheInfo(gpu_client_id, cache_dir);
383 } 391 }
384 392
385 } // namespace content 393 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698