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
parent 7b7afe5c
......@@ -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(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment