summaryrefslogtreecommitdiffstats
path: root/content/browser/gpu/shader_disk_cache.cc
diff options
context:
space:
mode:
authordsinclair@chromium.org <dsinclair@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-10 17:39:09 +0000
committerdsinclair@chromium.org <dsinclair@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-10 17:39:09 +0000
commit5a8cbcea3123acc43140ad36dbea02100fecb472 (patch)
tree79649045c50e8cbe72ac5a2c6381aa2cb09937d8 /content/browser/gpu/shader_disk_cache.cc
parent7b7afe5c0f1440339c1afd3c52fd999a5b82b4fe (diff)
downloadchromium_src-5a8cbcea3123acc43140ad36dbea02100fecb472.zip
chromium_src-5a8cbcea3123acc43140ad36dbea02100fecb472.tar.gz
chromium_src-5a8cbcea3123acc43140ad36dbea02100fecb472.tar.bz2
Delay signaling Shader cache is available until loading is complete.
If we send the available callback before we've finished loading the current cached shaders off disk there is a potential race condition where we do a cache clear while reading. This causes an issue with the iterators and the cache does not get cleared. This patch delays the signaling of the available cache until after we have finished iterating over the cache and loading the old shaders. BUG=176289 Review URL: https://chromiumcodereview.appspot.com/13730005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193411 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/gpu/shader_disk_cache.cc')
-rw-r--r--content/browser/gpu/shader_disk_cache.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/content/browser/gpu/shader_disk_cache.cc b/content/browser/gpu/shader_disk_cache.cc
index d1ceef4..621d7d53 100644
--- a/content/browser/gpu/shader_disk_cache.cc
+++ b/content/browser/gpu/shader_disk_cache.cc
@@ -573,15 +573,8 @@ void ShaderDiskCache::CacheCreatedCallback(int rv) {
LOG(ERROR) << "Shader Cache Creation failed: " << rv;
return;
}
- cache_available_ = true;
-
helper_ = new ShaderDiskReadHelper(AsWeakPtr(), host_id_);
helper_->LoadCache();
-
- if (!available_callback_.is_null()) {
- available_callback_.Run(net::OK);
- available_callback_.Reset();
- }
}
void ShaderDiskCache::EntryComplete(void* entry) {
@@ -593,6 +586,15 @@ void ShaderDiskCache::EntryComplete(void* entry) {
void ShaderDiskCache::ReadComplete() {
helper_ = NULL;
+
+ // The cache is considered available after we have finished reading any
+ // of the old cache values off disk. This prevents a potential race where we
+ // are reading from disk and execute a cache clear at the same time.
+ cache_available_ = true;
+ if (!available_callback_.is_null()) {
+ available_callback_.Run(net::OK);
+ available_callback_.Reset();
+ }
}
int ShaderDiskCache::SetCacheCompleteCallback(