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

Side by Side Diff: content/browser/cache_storage/cache_storage.cc

Issue 2232223003: [CacheStorage] Check doomed caches first when dropping cache handles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Rebase Created 4 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cache_storage/cache_storage.h" 5 #include "content/browser/cache_storage/cache_storage.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // load the backend, that happens lazily when the cache is used. 106 // load the backend, that happens lazily when the cache is used.
107 virtual std::unique_ptr<CacheStorageCache> CreateCache( 107 virtual std::unique_ptr<CacheStorageCache> CreateCache(
108 const std::string& cache_name) = 0; 108 const std::string& cache_name) = 0;
109 109
110 // Deletes any pre-existing cache of the same name and then loads it. 110 // Deletes any pre-existing cache of the same name and then loads it.
111 virtual void PrepareNewCacheDestination(const std::string& cache_name, 111 virtual void PrepareNewCacheDestination(const std::string& cache_name,
112 const CacheCallback& callback) = 0; 112 const CacheCallback& callback) = 0;
113 113
114 // After the backend has been deleted, do any extra house keeping such as 114 // After the backend has been deleted, do any extra house keeping such as
115 // removing the cache's directory. 115 // removing the cache's directory.
116 virtual void CleanUpDeletedCache(const std::string& key, 116 virtual void CleanUpDeletedCache(const std::string& key) = 0;
117 const BoolCallback& callback) = 0;
118 117
119 // Writes the cache names (and sizes) to disk if applicable. 118 // Writes the cache names (and sizes) to disk if applicable.
120 virtual void WriteIndex(const StringVector& cache_names, 119 virtual void WriteIndex(const StringVector& cache_names,
121 const BoolCallback& callback) = 0; 120 const BoolCallback& callback) = 0;
122 121
123 // Loads the cache names from disk if applicable. 122 // Loads the cache names from disk if applicable.
124 virtual void LoadIndex(std::unique_ptr<std::vector<std::string>> cache_names, 123 virtual void LoadIndex(std::unique_ptr<std::vector<std::string>> cache_names,
125 const StringVectorCallback& callback) = 0; 124 const StringVectorCallback& callback) = 0;
126 125
126 // Called when CacheStorage has created a cache. Used to hold onto a handle to
127 // the cache if necessary.
128 virtual void NotifyCacheCreated(
129 const std::string& cache_name,
130 std::unique_ptr<CacheStorageCacheHandle> cache_handle){};
131
132 // Notification that a cache has been doomed and will be deleted once the last
133 // cache handle has been dropped. If the loader is holding a handle to the
134 // cache, it should drop it now.
135 virtual void NotifyCacheDoomed(const std::string& cache_name){};
136
127 protected: 137 protected:
128 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_; 138 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_;
129 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 139 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
130 140
131 // Owned by CacheStorage which owns this. 141 // Owned by CacheStorage which owns this.
132 storage::QuotaManagerProxy* quota_manager_proxy_; 142 storage::QuotaManagerProxy* quota_manager_proxy_;
133 143
134 base::WeakPtr<storage::BlobStorageContext> blob_context_; 144 base::WeakPtr<storage::BlobStorageContext> blob_context_;
135 145
136 // Raw pointer is safe because this object is owned by cache_storage_. 146 // Raw pointer is safe because this object is owned by cache_storage_.
137 CacheStorage* cache_storage_; 147 CacheStorage* cache_storage_;
138 148
139 GURL origin_; 149 GURL origin_;
140 }; 150 };
141 151
142 // Creates memory-only ServiceWorkerCaches. Because these caches have no 152 // Creates memory-only ServiceWorkerCaches. Because these caches have no
143 // persistent storage it is not safe to free them from memory if they might be 153 // persistent storage it is not safe to free them from memory if they might be
144 // used again. Therefore this class holds a reference to each cache until the 154 // used again. Therefore this class holds a reference to each cache until the
145 // cache is deleted. 155 // cache is doomed.
146 class CacheStorage::MemoryLoader : public CacheStorage::CacheLoader { 156 class CacheStorage::MemoryLoader : public CacheStorage::CacheLoader {
147 public: 157 public:
148 MemoryLoader(base::SequencedTaskRunner* cache_task_runner, 158 MemoryLoader(base::SequencedTaskRunner* cache_task_runner,
149 scoped_refptr<net::URLRequestContextGetter> request_context, 159 scoped_refptr<net::URLRequestContextGetter> request_context,
150 storage::QuotaManagerProxy* quota_manager_proxy, 160 storage::QuotaManagerProxy* quota_manager_proxy,
151 base::WeakPtr<storage::BlobStorageContext> blob_context, 161 base::WeakPtr<storage::BlobStorageContext> blob_context,
152 CacheStorage* cache_storage, 162 CacheStorage* cache_storage,
153 const GURL& origin) 163 const GURL& origin)
154 : CacheLoader(cache_task_runner, 164 : CacheLoader(cache_task_runner,
155 request_context, 165 request_context,
156 quota_manager_proxy, 166 quota_manager_proxy,
157 blob_context, 167 blob_context,
158 cache_storage, 168 cache_storage,
159 origin) {} 169 origin) {}
160 170
161 std::unique_ptr<CacheStorageCache> CreateCache( 171 std::unique_ptr<CacheStorageCache> CreateCache(
162 const std::string& cache_name) override { 172 const std::string& cache_name) override {
163 return CacheStorageCache::CreateMemoryCache( 173 return CacheStorageCache::CreateMemoryCache(
164 origin_, cache_name, cache_storage_, request_context_getter_, 174 origin_, cache_name, cache_storage_, request_context_getter_,
165 quota_manager_proxy_, blob_context_); 175 quota_manager_proxy_, blob_context_);
166 } 176 }
167 177
168 void PrepareNewCacheDestination(const std::string& cache_name, 178 void PrepareNewCacheDestination(const std::string& cache_name,
169 const CacheCallback& callback) override { 179 const CacheCallback& callback) override {
170 std::unique_ptr<CacheStorageCache> cache = CreateCache(cache_name); 180 std::unique_ptr<CacheStorageCache> cache = CreateCache(cache_name);
171 callback.Run(std::move(cache)); 181 callback.Run(std::move(cache));
172 } 182 }
173 183
174 void CleanUpDeletedCache(const std::string& cache_name, 184 void CleanUpDeletedCache(const std::string& cache_name) override {}
175 const BoolCallback& callback) override { 185
176 CacheHandles::iterator it = cache_handles_.find(cache_name); 186 void WriteIndex(const StringVector& cache_names,
177 DCHECK(it != cache_handles_.end()); 187 const BoolCallback& callback) override {
178 cache_handles_.erase(it);
179 callback.Run(true); 188 callback.Run(true);
180 } 189 }
181 190
182 void WriteIndex(const StringVector& cache_names,
183 const BoolCallback& callback) override {
184 callback.Run(false);
185 }
186
187 void LoadIndex(std::unique_ptr<std::vector<std::string>> cache_names, 191 void LoadIndex(std::unique_ptr<std::vector<std::string>> cache_names,
188 const StringVectorCallback& callback) override { 192 const StringVectorCallback& callback) override {
189 callback.Run(std::move(cache_names)); 193 callback.Run(std::move(cache_names));
190 } 194 }
191 195
192 void StoreCacheHandle(const std::string& cache_name, 196 void NotifyCacheCreated(
193 std::unique_ptr<CacheStorageCacheHandle> cache_handle) { 197 const std::string& cache_name,
198 std::unique_ptr<CacheStorageCacheHandle> cache_handle) override {
194 DCHECK(!ContainsKey(cache_handles_, cache_name)); 199 DCHECK(!ContainsKey(cache_handles_, cache_name));
195 cache_handles_.insert(std::make_pair(cache_name, std::move(cache_handle))); 200 cache_handles_.insert(std::make_pair(cache_name, std::move(cache_handle)));
196 } 201 };
202
203 void NotifyCacheDoomed(const std::string& cache_name) override {
204 DCHECK(ContainsKey(cache_handles_, cache_name));
205 cache_handles_.erase(cache_name);
206 };
197 207
198 private: 208 private:
199 typedef std::map<std::string, std::unique_ptr<CacheStorageCacheHandle>> 209 typedef std::map<std::string, std::unique_ptr<CacheStorageCacheHandle>>
200 CacheHandles; 210 CacheHandles;
201 ~MemoryLoader() override {} 211 ~MemoryLoader() override {}
202 212
203 // Keep a reference to each cache to ensure that it's not freed before the 213 // Keep a reference to each cache to ensure that it's not freed before the
204 // client calls CacheStorage::Delete or the CacheStorage is 214 // client calls CacheStorage::Delete or the CacheStorage is
205 // freed. 215 // freed.
206 CacheHandles cache_handles_; 216 CacheHandles cache_handles_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 const std::string& cache_dir) { 276 const std::string& cache_dir) {
267 if (cache_dir.empty()) { 277 if (cache_dir.empty()) {
268 callback.Run(std::unique_ptr<CacheStorageCache>()); 278 callback.Run(std::unique_ptr<CacheStorageCache>());
269 return; 279 return;
270 } 280 }
271 281
272 cache_name_to_cache_dir_[cache_name] = cache_dir; 282 cache_name_to_cache_dir_[cache_name] = cache_dir;
273 callback.Run(CreateCache(cache_name)); 283 callback.Run(CreateCache(cache_name));
274 } 284 }
275 285
276 void CleanUpDeletedCache(const std::string& cache_name, 286 void CleanUpDeletedCache(const std::string& cache_name) override {
277 const BoolCallback& callback) override {
278 DCHECK_CURRENTLY_ON(BrowserThread::IO); 287 DCHECK_CURRENTLY_ON(BrowserThread::IO);
279 DCHECK(ContainsKey(cache_name_to_cache_dir_, cache_name)); 288 DCHECK(ContainsKey(cache_name_to_cache_dir_, cache_name));
280 289
281 base::FilePath cache_path = 290 base::FilePath cache_path =
282 origin_path_.AppendASCII(cache_name_to_cache_dir_[cache_name]); 291 origin_path_.AppendASCII(cache_name_to_cache_dir_[cache_name]);
283 cache_name_to_cache_dir_.erase(cache_name); 292 cache_name_to_cache_dir_.erase(cache_name);
284 293
285 cache_task_runner_->PostTask( 294 cache_task_runner_->PostTask(
286 FROM_HERE, 295 FROM_HERE, base::Bind(&SimpleCacheLoader::CleanUpDeleteCacheDirInPool,
287 base::Bind(&SimpleCacheLoader::CleanUpDeleteCacheDirInPool, cache_path, 296 cache_path));
288 callback, base::ThreadTaskRunnerHandle::Get()));
289 } 297 }
290 298
291 static void CleanUpDeleteCacheDirInPool( 299 static void CleanUpDeleteCacheDirInPool(const base::FilePath& cache_path) {
292 const base::FilePath& cache_path, 300 base::DeleteFile(cache_path, true /* recursive */);
293 const BoolCallback& callback,
294 scoped_refptr<base::SingleThreadTaskRunner> original_task_runner) {
295 bool rv = base::DeleteFile(cache_path, true);
296 original_task_runner->PostTask(FROM_HERE, base::Bind(callback, rv));
297 } 301 }
298 302
299 void WriteIndex(const StringVector& cache_names, 303 void WriteIndex(const StringVector& cache_names,
300 const BoolCallback& callback) override { 304 const BoolCallback& callback) override {
301 DCHECK_CURRENTLY_ON(BrowserThread::IO); 305 DCHECK_CURRENTLY_ON(BrowserThread::IO);
302 306
303 // 1. Create the index file as a string. (WriteIndex) 307 // 1. Create the index file as a string. (WriteIndex)
304 // 2. Write the file to disk. (WriteIndexWriteToFileInPool) 308 // 2. Write the file to disk. (WriteIndexWriteToFileInPool)
305 309
306 CacheStorageIndex index; 310 CacheStorageIndex index;
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 callback.Run(std::unique_ptr<CacheStorageCacheHandle>(), 735 callback.Run(std::unique_ptr<CacheStorageCacheHandle>(),
732 CACHE_STORAGE_ERROR_STORAGE); 736 CACHE_STORAGE_ERROR_STORAGE);
733 return; 737 return;
734 } 738 }
735 739
736 CacheStorageCache* cache_ptr = cache.get(); 740 CacheStorageCache* cache_ptr = cache.get();
737 741
738 cache_map_.insert(std::make_pair(cache_name, std::move(cache))); 742 cache_map_.insert(std::make_pair(cache_name, std::move(cache)));
739 ordered_cache_names_.push_back(cache_name); 743 ordered_cache_names_.push_back(cache_name);
740 744
741 if (memory_only_) {
742 static_cast<MemoryLoader*>(cache_loader_.get())
743 ->StoreCacheHandle(cache_name, CreateCacheHandle(cache_ptr));
744 }
745
746 cache_loader_->WriteIndex( 745 cache_loader_->WriteIndex(
747 ordered_cache_names_, 746 ordered_cache_names_,
748 base::Bind(&CacheStorage::CreateCacheDidWriteIndex, 747 base::Bind(&CacheStorage::CreateCacheDidWriteIndex,
749 weak_factory_.GetWeakPtr(), callback, 748 weak_factory_.GetWeakPtr(), callback,
750 base::Passed(CreateCacheHandle(cache_ptr)))); 749 base::Passed(CreateCacheHandle(cache_ptr))));
750
751 cache_loader_->NotifyCacheCreated(cache_name, CreateCacheHandle(cache_ptr));
751 } 752 }
752 753
753 void CacheStorage::CreateCacheDidWriteIndex( 754 void CacheStorage::CreateCacheDidWriteIndex(
754 const CacheAndErrorCallback& callback, 755 const CacheAndErrorCallback& callback,
755 std::unique_ptr<CacheStorageCacheHandle> cache_handle, 756 std::unique_ptr<CacheStorageCacheHandle> cache_handle,
756 bool success) { 757 bool success) {
757 DCHECK_CURRENTLY_ON(BrowserThread::IO); 758 DCHECK_CURRENTLY_ON(BrowserThread::IO);
758 DCHECK(cache_handle); 759 DCHECK(cache_handle);
759 760
760 // TODO(jkarlin): Handle !success. 761 // TODO(jkarlin): Handle !success.
761 762
762 callback.Run(std::move(cache_handle), CACHE_STORAGE_OK); 763 callback.Run(std::move(cache_handle), CACHE_STORAGE_OK);
763 } 764 }
764 765
765 void CacheStorage::HasCacheImpl(const std::string& cache_name, 766 void CacheStorage::HasCacheImpl(const std::string& cache_name,
766 const BoolAndErrorCallback& callback) { 767 const BoolAndErrorCallback& callback) {
767 bool has_cache = ContainsKey(cache_map_, cache_name); 768 bool has_cache = ContainsKey(cache_map_, cache_name);
768 callback.Run(has_cache, CACHE_STORAGE_OK); 769 callback.Run(has_cache, CACHE_STORAGE_OK);
769 } 770 }
770 771
771 void CacheStorage::DeleteCacheImpl(const std::string& cache_name, 772 void CacheStorage::DeleteCacheImpl(const std::string& cache_name,
772 const BoolAndErrorCallback& callback) { 773 const BoolAndErrorCallback& callback) {
773 std::unique_ptr<CacheStorageCacheHandle> cache_handle = 774 if (!GetLoadedCache(cache_name)) {
774 GetLoadedCache(cache_name);
775 if (!cache_handle) {
776 base::ThreadTaskRunnerHandle::Get()->PostTask( 775 base::ThreadTaskRunnerHandle::Get()->PostTask(
777 FROM_HERE, base::Bind(callback, false, CACHE_STORAGE_ERROR_NOT_FOUND)); 776 FROM_HERE, base::Bind(callback, false, CACHE_STORAGE_ERROR_NOT_FOUND));
778 return; 777 return;
779 } 778 }
780 779
781 CacheMap::iterator map_iter = cache_map_.find(cache_name);
782 deleted_caches_.insert(
783 std::make_pair(cache_handle->value(), std::move(map_iter->second)));
784 cache_map_.erase(map_iter);
785
786 // Delete the name from ordered_cache_names_. 780 // Delete the name from ordered_cache_names_.
781 StringVector original_ordered_cache_names = ordered_cache_names_;
787 StringVector::iterator iter = std::find( 782 StringVector::iterator iter = std::find(
788 ordered_cache_names_.begin(), ordered_cache_names_.end(), cache_name); 783 ordered_cache_names_.begin(), ordered_cache_names_.end(), cache_name);
789 DCHECK(iter != ordered_cache_names_.end()); 784 DCHECK(iter != ordered_cache_names_.end());
790 ordered_cache_names_.erase(iter); 785 ordered_cache_names_.erase(iter);
791 786
792 CacheStorageCache* cache_ptr = cache_handle->value(); 787 cache_loader_->WriteIndex(ordered_cache_names_,
793 cache_ptr->GetSizeThenClose( 788 base::Bind(&CacheStorage::DeleteCacheDidWriteIndex,
794 base::Bind(&CacheStorage::DeleteCacheDidClose, weak_factory_.GetWeakPtr(), 789 weak_factory_.GetWeakPtr(), cache_name,
795 cache_name, callback, ordered_cache_names_, 790 original_ordered_cache_names, callback));
796 base::Passed(std::move(cache_handle))));
797 }
798
799 void CacheStorage::DeleteCacheDidClose(
800 const std::string& cache_name,
801 const BoolAndErrorCallback& callback,
802 const StringVector& ordered_cache_names,
803 std::unique_ptr<CacheStorageCacheHandle> cache_handle,
804 int64_t cache_size) {
805 cache_loader_->WriteIndex(
806 ordered_cache_names,
807 base::Bind(&CacheStorage::DeleteCacheDidWriteIndex,
808 weak_factory_.GetWeakPtr(), cache_name, callback, cache_size));
809 } 791 }
810 792
811 void CacheStorage::DeleteCacheDidWriteIndex( 793 void CacheStorage::DeleteCacheDidWriteIndex(
812 const std::string& cache_name, 794 const std::string& cache_name,
795 const StringVector& original_ordered_cache_names,
813 const BoolAndErrorCallback& callback, 796 const BoolAndErrorCallback& callback,
814 int cache_size,
815 bool success) { 797 bool success) {
816 DCHECK_CURRENTLY_ON(BrowserThread::IO); 798 DCHECK_CURRENTLY_ON(BrowserThread::IO);
817 799
800 if (!success) {
801 // Undo any changes if the change couldn't be written to disk.
802 ordered_cache_names_ = original_ordered_cache_names;
803 callback.Run(false, CACHE_STORAGE_ERROR_STORAGE);
804 return;
805 }
806
807 CacheMap::iterator map_iter = cache_map_.find(cache_name);
808 doomed_caches_.insert(
809 std::make_pair(map_iter->second.get(), std::move(map_iter->second)));
810 cache_map_.erase(map_iter);
811
812 cache_loader_->NotifyCacheDoomed(cache_name);
813
814 callback.Run(true, CACHE_STORAGE_OK);
815 }
816
817 // Call this once the last handle to a doomed cache is gone. It's okay if this
818 // doesn't get to complete before shutdown, the cache will be removed from disk
819 // on next startup in that case.
820 void CacheStorage::DeleteCacheFinalize(
821 std::unique_ptr<CacheStorageCache> doomed_cache) {
822 CacheStorageCache* cache = doomed_cache.get();
823 cache->Size(base::Bind(&CacheStorage::DeleteCacheDidGetSize,
824 weak_factory_.GetWeakPtr(),
825 base::Passed(std::move(doomed_cache))));
826 }
827
828 void CacheStorage::DeleteCacheDidGetSize(
829 std::unique_ptr<CacheStorageCache> cache,
830 int64_t cache_size) {
818 quota_manager_proxy_->NotifyStorageModified( 831 quota_manager_proxy_->NotifyStorageModified(
819 storage::QuotaClient::kServiceWorkerCache, origin_, 832 storage::QuotaClient::kServiceWorkerCache, origin_,
820 storage::kStorageTypeTemporary, -1 * cache_size); 833 storage::kStorageTypeTemporary, -1 * cache_size);
821 834
822 cache_loader_->CleanUpDeletedCache( 835 cache_loader_->CleanUpDeletedCache(cache->cache_name());
823 cache_name, base::Bind(&CacheStorage::DeleteCacheDidCleanUp,
824 weak_factory_.GetWeakPtr(), callback));
825 }
826
827 void CacheStorage::DeleteCacheDidCleanUp(const BoolAndErrorCallback& callback,
828 bool success) {
829 DCHECK_CURRENTLY_ON(BrowserThread::IO);
830
831 callback.Run(true, CACHE_STORAGE_OK);
832 } 836 }
833 837
834 void CacheStorage::EnumerateCachesImpl( 838 void CacheStorage::EnumerateCachesImpl(
835 const StringsAndErrorCallback& callback) { 839 const StringsAndErrorCallback& callback) {
836 callback.Run(ordered_cache_names_, CACHE_STORAGE_OK); 840 callback.Run(ordered_cache_names_, CACHE_STORAGE_OK);
837 } 841 }
838 842
839 void CacheStorage::MatchCacheImpl( 843 void CacheStorage::MatchCacheImpl(
840 const std::string& cache_name, 844 const std::string& cache_name,
841 std::unique_ptr<ServiceWorkerFetchRequest> request, 845 std::unique_ptr<ServiceWorkerFetchRequest> request,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 } 940 }
937 941
938 void CacheStorage::DropCacheHandleRef(CacheStorageCache* cache) { 942 void CacheStorage::DropCacheHandleRef(CacheStorageCache* cache) {
939 DCHECK_CURRENTLY_ON(BrowserThread::IO); 943 DCHECK_CURRENTLY_ON(BrowserThread::IO);
940 auto iter = cache_handle_counts_.find(cache); 944 auto iter = cache_handle_counts_.find(cache);
941 DCHECK(iter != cache_handle_counts_.end()); 945 DCHECK(iter != cache_handle_counts_.end());
942 DCHECK(iter->second >= 1); 946 DCHECK(iter->second >= 1);
943 947
944 iter->second -= 1; 948 iter->second -= 1;
945 if (iter->second == 0) { 949 if (iter->second == 0) {
946 // Delete the CacheStorageCache object. It's either in the main cache map or 950 auto doomed_caches_iter = doomed_caches_.find(cache);
947 // the CacheStorage::Delete operation has run on the cache, in which case 951 if (doomed_caches_iter != doomed_caches_.end()) {
948 // it's in the deleted caches map. 952 // The last reference to a doomed cache is gone, perform clean up.
949 auto cache_map_iter = cache_map_.find(cache->cache_name()); 953 DeleteCacheFinalize(std::move(doomed_caches_iter->second));
950 954 doomed_caches_.erase(doomed_caches_iter);
951 if (cache_map_iter == cache_map_.end()) {
952 auto deleted_caches_iter = deleted_caches_.find(cache);
953 DCHECK(deleted_caches_iter != deleted_caches_.end());
954 deleted_caches_.erase(deleted_caches_iter);
955 return; 955 return;
956 } 956 }
957 957
958 auto cache_map_iter = cache_map_.find(cache->cache_name());
959 DCHECK(cache_map_iter != cache_map_.end());
960
958 cache_map_iter->second.reset(); 961 cache_map_iter->second.reset();
959 cache_handle_counts_.erase(iter); 962 cache_handle_counts_.erase(iter);
960 } 963 }
961 } 964 }
962 965
963 std::unique_ptr<CacheStorageCacheHandle> CacheStorage::CreateCacheHandle( 966 std::unique_ptr<CacheStorageCacheHandle> CacheStorage::CreateCacheHandle(
964 CacheStorageCache* cache) { 967 CacheStorageCache* cache) {
965 DCHECK(cache); 968 DCHECK(cache);
966 return std::unique_ptr<CacheStorageCacheHandle>(new CacheStorageCacheHandle( 969 return std::unique_ptr<CacheStorageCacheHandle>(new CacheStorageCacheHandle(
967 cache->AsWeakPtr(), weak_factory_.GetWeakPtr())); 970 cache->AsWeakPtr(), weak_factory_.GetWeakPtr()));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 void CacheStorage::PendingSizeCallback(const SizeCallback& callback, 1093 void CacheStorage::PendingSizeCallback(const SizeCallback& callback,
1091 int64_t size) { 1094 int64_t size) {
1092 base::WeakPtr<CacheStorage> cache_storage = weak_factory_.GetWeakPtr(); 1095 base::WeakPtr<CacheStorage> cache_storage = weak_factory_.GetWeakPtr();
1093 1096
1094 callback.Run(size); 1097 callback.Run(size);
1095 if (cache_storage) 1098 if (cache_storage)
1096 scheduler_->CompleteOperationAndRunNext(); 1099 scheduler_->CompleteOperationAndRunNext();
1097 } 1100 }
1098 1101
1099 } // namespace content 1102 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage.h ('k') | content/browser/cache_storage/cache_storage_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698