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

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

Issue 13730005: Delay signaling Shader cache is available until loading is complete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/shader_disk_cache.h" 5 #include "content/browser/gpu/shader_disk_cache.h"
6 6
7 #include "base/threading/thread_checker.h" 7 #include "base/threading/thread_checker.h"
8 #include "content/browser/gpu/gpu_process_host.h" 8 #include "content/browser/gpu/gpu_process_host.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 return net::OK; 566 return net::OK;
567 available_callback_ = callback; 567 available_callback_ = callback;
568 return net::ERR_IO_PENDING; 568 return net::ERR_IO_PENDING;
569 } 569 }
570 570
571 void ShaderDiskCache::CacheCreatedCallback(int rv) { 571 void ShaderDiskCache::CacheCreatedCallback(int rv) {
572 if (rv != net::OK) { 572 if (rv != net::OK) {
573 LOG(ERROR) << "Shader Cache Creation failed: " << rv; 573 LOG(ERROR) << "Shader Cache Creation failed: " << rv;
574 return; 574 return;
575 } 575 }
576 cache_available_ = true;
577
578 helper_ = new ShaderDiskReadHelper(AsWeakPtr(), host_id_); 576 helper_ = new ShaderDiskReadHelper(AsWeakPtr(), host_id_);
579 helper_->LoadCache(); 577 helper_->LoadCache();
580
581 if (!available_callback_.is_null()) {
582 available_callback_.Run(net::OK);
583 available_callback_.Reset();
584 }
585 } 578 }
586 579
587 void ShaderDiskCache::EntryComplete(void* entry) { 580 void ShaderDiskCache::EntryComplete(void* entry) {
588 entry_map_.erase(entry); 581 entry_map_.erase(entry);
589 582
590 if (entry_map_.empty() && !cache_complete_callback_.is_null()) 583 if (entry_map_.empty() && !cache_complete_callback_.is_null())
591 cache_complete_callback_.Run(net::OK); 584 cache_complete_callback_.Run(net::OK);
592 } 585 }
593 586
594 void ShaderDiskCache::ReadComplete() { 587 void ShaderDiskCache::ReadComplete() {
595 helper_ = NULL; 588 helper_ = NULL;
589
590 // The cache is considered available after we have finished reading any
591 // of the old cache values off disk. This prevents a potential race where we
592 // are reading from disk and execute a cache clear at the same time.
593 cache_available_ = true;
594 if (!available_callback_.is_null()) {
595 available_callback_.Run(net::OK);
596 available_callback_.Reset();
597 }
596 } 598 }
597 599
598 int ShaderDiskCache::SetCacheCompleteCallback( 600 int ShaderDiskCache::SetCacheCompleteCallback(
599 const net::CompletionCallback& callback) { 601 const net::CompletionCallback& callback) {
600 if (entry_map_.empty()) { 602 if (entry_map_.empty()) {
601 return net::OK; 603 return net::OK;
602 } 604 }
603 cache_complete_callback_ = callback; 605 cache_complete_callback_ = callback;
604 return net::ERR_IO_PENDING; 606 return net::ERR_IO_PENDING;
605 } 607 }
606 608
607 } // namespace content 609 } // namespace content
608 610
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698