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

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

Issue 1128233004: Fix GpuChannelHost destruction and races (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | content/common/gpu/client/gpu_channel_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 next_create_gpu_memory_buffer_request_id_(0) { 288 next_create_gpu_memory_buffer_request_id_(0) {
289 } 289 }
290 290
291 BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() { 291 BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() {
292 DCHECK(IsMainThread()); 292 DCHECK(IsMainThread());
293 if (pending_request_.get()) 293 if (pending_request_.get())
294 pending_request_->Cancel(); 294 pending_request_->Cancel();
295 for (size_t n = 0; n < established_callbacks_.size(); n++) 295 for (size_t n = 0; n < established_callbacks_.size(); n++)
296 established_callbacks_[n].Run(); 296 established_callbacks_[n].Run();
297 shutdown_event_->Signal(); 297 shutdown_event_->Signal();
298 if (gpu_channel_) {
299 gpu_channel_->DestroyChannel();
300 gpu_channel_ = NULL;
301 }
298 } 302 }
299 303
300 bool BrowserGpuChannelHostFactory::IsMainThread() { 304 bool BrowserGpuChannelHostFactory::IsMainThread() {
301 return BrowserThread::CurrentlyOn(BrowserThread::UI); 305 return BrowserThread::CurrentlyOn(BrowserThread::UI);
302 } 306 }
303 307
304 base::MessageLoop* BrowserGpuChannelHostFactory::GetMainLoop() { 308 base::MessageLoop* BrowserGpuChannelHostFactory::GetMainLoop() {
305 return BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::UI); 309 return BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::UI);
306 } 310 }
307 311
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 return gpu_channel_.get(); 393 return gpu_channel_.get();
390 } 394 }
391 #endif 395 #endif
392 396
393 void BrowserGpuChannelHostFactory::EstablishGpuChannel( 397 void BrowserGpuChannelHostFactory::EstablishGpuChannel(
394 CauseForGpuLaunch cause_for_gpu_launch, 398 CauseForGpuLaunch cause_for_gpu_launch,
395 const base::Closure& callback) { 399 const base::Closure& callback) {
396 if (gpu_channel_.get() && gpu_channel_->IsLost()) { 400 if (gpu_channel_.get() && gpu_channel_->IsLost()) {
397 DCHECK(!pending_request_.get()); 401 DCHECK(!pending_request_.get());
398 // Recreate the channel if it has been lost. 402 // Recreate the channel if it has been lost.
403 gpu_channel_->DestroyChannel();
399 gpu_channel_ = NULL; 404 gpu_channel_ = NULL;
400 } 405 }
401 406
402 if (!gpu_channel_.get() && !pending_request_.get()) { 407 if (!gpu_channel_.get() && !pending_request_.get()) {
403 // We should only get here if the context was lost. 408 // We should only get here if the context was lost.
404 pending_request_ = EstablishRequest::Create( 409 pending_request_ = EstablishRequest::Create(
405 cause_for_gpu_launch, gpu_client_id_, gpu_host_id_); 410 cause_for_gpu_launch, gpu_client_id_, gpu_host_id_);
406 } 411 }
407 412
408 if (!callback.is_null()) { 413 if (!callback.is_null()) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 DCHECK_CURRENTLY_ON(BrowserThread::IO); 564 DCHECK_CURRENTLY_ON(BrowserThread::IO);
560 565
561 CreateGpuMemoryBufferCallbackMap::iterator iter = 566 CreateGpuMemoryBufferCallbackMap::iterator iter =
562 create_gpu_memory_buffer_requests_.find(request_id); 567 create_gpu_memory_buffer_requests_.find(request_id);
563 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); 568 DCHECK(iter != create_gpu_memory_buffer_requests_.end());
564 iter->second.Run(handle); 569 iter->second.Run(handle);
565 create_gpu_memory_buffer_requests_.erase(iter); 570 create_gpu_memory_buffer_requests_.erase(iter);
566 } 571 }
567 572
568 } // namespace content 573 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/client/gpu_channel_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698