diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 22:45:12 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 22:45:12 +0000 |
commit | 63bf70a0bb731dbbac4a43a21f992e56fe7fd5ae (patch) | |
tree | d5e4ac2431950e0870274f30b2166512fb97d0cd /webkit/appcache | |
parent | 8c7f65db00d5994cc430be11934ec564a894ec76 (diff) | |
download | chromium_src-63bf70a0bb731dbbac4a43a21f992e56fe7fd5ae.zip chromium_src-63bf70a0bb731dbbac4a43a21f992e56fe7fd5ae.tar.gz chromium_src-63bf70a0bb731dbbac4a43a21f992e56fe7fd5ae.tar.bz2 |
Fix a race condition between the GroupLoadTask and the CacheLoadTask. Upon completion of either task, check again if the objects being loaded are in the working set to avoid erroneously creating a second in memory representation for those shared object types.
BUG=none
TEST=existing tests pass
Review URL: http://codereview.chromium.org/7484039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93725 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache')
-rw-r--r-- | webkit/appcache/appcache_storage_impl.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index b81f65d..58a3720 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -346,6 +346,15 @@ void AppCacheStorageImpl::StoreOrLoadTask::CreateCacheAndGroupFromRecords( scoped_refptr<AppCache>* cache, scoped_refptr<AppCacheGroup>* group) { DCHECK(storage_ && cache && group); + (*cache) = storage_->working_set_.GetCache(cache_record_.cache_id); + if (cache->get()) { + (*group) = cache->get()->owning_group(); + DCHECK(group->get()); + DCHECK_EQ(group_record_.group_id, group->get()->group_id()); + storage_->NotifyStorageAccessed(group_record_.origin); + return; + } + (*cache) = new AppCache(storage_->service_, cache_record_.cache_id); cache->get()->InitializeWithDatabaseRecords( cache_record_, entry_records_, fallback_namespace_records_, @@ -413,7 +422,6 @@ void AppCacheStorageImpl::CacheLoadTask::RunCompleted() { scoped_refptr<AppCacheGroup> group; if (success_ && !storage_->is_disabled()) { DCHECK(cache_record_.cache_id == cache_id_); - DCHECK(!storage_->working_set_.GetCache(cache_record_.cache_id)); CreateCacheAndGroupFromRecords(&cache, &group); } FOR_EACH_DELEGATE(delegates_, OnCacheLoaded(cache, cache_id_)); @@ -452,12 +460,13 @@ void AppCacheStorageImpl::GroupLoadTask::RunCompleted() { if (!storage_->is_disabled()) { if (success_) { DCHECK(group_record_.manifest_url == manifest_url_); - DCHECK(!storage_->working_set_.GetGroup(manifest_url_)); - DCHECK(!storage_->working_set_.GetCache(cache_record_.cache_id)); CreateCacheAndGroupFromRecords(&cache, &group); } else { - group = new AppCacheGroup( - storage_->service_, manifest_url_, storage_->NewGroupId()); + group = storage_->working_set_.GetGroup(manifest_url_); + if (!group) { + group = new AppCacheGroup( + storage_->service_, manifest_url_, storage_->NewGroupId()); + } } } FOR_EACH_DELEGATE(delegates_, OnGroupLoaded(group, manifest_url_)); |