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

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

Issue 2111243003: [CacheStorage] Keep deleted caches alive until last reference is gone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS3 Created 4 years, 5 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
« no previous file with comments | « no previous file | content/browser/cache_storage/cache_storage.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ 5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_
6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // The cache will also be deleted in the CacheStorage's destructor so be sure 70 // The cache will also be deleted in the CacheStorage's destructor so be sure
71 // to check the handle's value before using it. 71 // to check the handle's value before using it.
72 void OpenCache(const std::string& cache_name, 72 void OpenCache(const std::string& cache_name,
73 const CacheAndErrorCallback& callback); 73 const CacheAndErrorCallback& callback);
74 74
75 // Calls the callback with whether or not the cache exists. 75 // Calls the callback with whether or not the cache exists.
76 void HasCache(const std::string& cache_name, 76 void HasCache(const std::string& cache_name,
77 const BoolAndErrorCallback& callback); 77 const BoolAndErrorCallback& callback);
78 78
79 // Deletes the cache if it exists. If it doesn't exist, 79 // Deletes the cache if it exists. If it doesn't exist,
80 // CACHE_STORAGE_ERROR_NOT_FOUND is returned. 80 // CACHE_STORAGE_ERROR_NOT_FOUND is returned. Any existing
81 // CacheStorageCacheHandle(s) to the cache will remain valid but future
82 // CacheStorage operations won't be able to access the cache. The cache
83 // isn't actually erased from disk until the last handle is dropped.
84 // TODO(jkarlin): Rename to DoomCache.
81 void DeleteCache(const std::string& cache_name, 85 void DeleteCache(const std::string& cache_name,
82 const BoolAndErrorCallback& callback); 86 const BoolAndErrorCallback& callback);
83 87
84 // Calls the callback with a vector of cache names (keys) available. 88 // Calls the callback with a vector of cache names (keys) available.
85 void EnumerateCaches(const StringsAndErrorCallback& callback); 89 void EnumerateCaches(const StringsAndErrorCallback& callback);
86 90
87 // Calls match on the cache with the given |cache_name|. 91 // Calls match on the cache with the given |cache_name|.
88 void MatchCache(const std::string& cache_name, 92 void MatchCache(const std::string& cache_name,
89 std::unique_ptr<ServiceWorkerFetchRequest> request, 93 std::unique_ptr<ServiceWorkerFetchRequest> request,
90 const CacheStorageCache::ResponseCallback& callback); 94 const CacheStorageCache::ResponseCallback& callback);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 std::unique_ptr<CacheStorageCacheHandle> cache_handle, 151 std::unique_ptr<CacheStorageCacheHandle> cache_handle,
148 bool success); 152 bool success);
149 153
150 // The HasCache callbacks are below. 154 // The HasCache callbacks are below.
151 void HasCacheImpl(const std::string& cache_name, 155 void HasCacheImpl(const std::string& cache_name,
152 const BoolAndErrorCallback& callback); 156 const BoolAndErrorCallback& callback);
153 157
154 // The DeleteCache callbacks are below. 158 // The DeleteCache callbacks are below.
155 void DeleteCacheImpl(const std::string& cache_name, 159 void DeleteCacheImpl(const std::string& cache_name,
156 const BoolAndErrorCallback& callback); 160 const BoolAndErrorCallback& callback);
157 161 void DeleteCacheDidWriteIndex(
158 void DeleteCacheDidClose(
159 const std::string& cache_name, 162 const std::string& cache_name,
163 const StringVector& original_ordered_cache_names,
160 const BoolAndErrorCallback& callback, 164 const BoolAndErrorCallback& callback,
161 const StringVector& ordered_cache_names, 165 bool success);
162 std::unique_ptr<CacheStorageCacheHandle> cache_handle, 166 void DeleteCacheFinalize(std::unique_ptr<CacheStorageCache> doomed_cache);
163 int64_t cache_size); 167 void DeleteCacheDidGetSize(std::unique_ptr<CacheStorageCache> cache,
164 void DeleteCacheDidWriteIndex(const std::string& cache_name, 168 int64_t cache_size);
165 const BoolAndErrorCallback& callback, 169 void DeleteCacheDidCleanUp(bool success);
166 int cache_size,
167 bool success);
168 void DeleteCacheDidCleanUp(const BoolAndErrorCallback& callback,
169 bool success);
170 170
171 // The EnumerateCache callbacks are below. 171 // The EnumerateCache callbacks are below.
172 void EnumerateCachesImpl(const StringsAndErrorCallback& callback); 172 void EnumerateCachesImpl(const StringsAndErrorCallback& callback);
173 173
174 // The MatchCache callbacks are below. 174 // The MatchCache callbacks are below.
175 void MatchCacheImpl(const std::string& cache_name, 175 void MatchCacheImpl(const std::string& cache_name,
176 std::unique_ptr<ServiceWorkerFetchRequest> request, 176 std::unique_ptr<ServiceWorkerFetchRequest> request,
177 const CacheStorageCache::ResponseCallback& callback); 177 const CacheStorageCache::ResponseCallback& callback);
178 void MatchCacheDidMatch(std::unique_ptr<CacheStorageCacheHandle> cache_handle, 178 void MatchCacheDidMatch(std::unique_ptr<CacheStorageCacheHandle> cache_handle,
179 const CacheStorageCache::ResponseCallback& callback, 179 const CacheStorageCache::ResponseCallback& callback,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 // The pending operation scheduler. 228 // The pending operation scheduler.
229 std::unique_ptr<CacheStorageScheduler> scheduler_; 229 std::unique_ptr<CacheStorageScheduler> scheduler_;
230 230
231 // The map of cache names to CacheStorageCache objects. 231 // The map of cache names to CacheStorageCache objects.
232 CacheMap cache_map_; 232 CacheMap cache_map_;
233 233
234 // Caches that have been deleted but must still be held onto until all handles 234 // Caches that have been deleted but must still be held onto until all handles
235 // have been released. 235 // have been released.
236 std::map<CacheStorageCache*, std::unique_ptr<CacheStorageCache>> 236 std::map<CacheStorageCache*, std::unique_ptr<CacheStorageCache>>
237 deleted_caches_; 237 doomed_caches_;
238 238
239 // CacheStorageCacheHandle reference counts 239 // CacheStorageCacheHandle reference counts
240 std::map<CacheStorageCache*, size_t> cache_handle_counts_; 240 std::map<CacheStorageCache*, size_t> cache_handle_counts_;
241 241
242 // The names of caches in the order that they were created. 242 // The names of caches in the order that they were created.
243 StringVector ordered_cache_names_; 243 StringVector ordered_cache_names_;
244 244
245 // The file path for this CacheStorage. 245 // The file path for this CacheStorage.
246 base::FilePath origin_path_; 246 base::FilePath origin_path_;
247 247
(...skipping 10 matching lines...) Expand all
258 GURL origin_; 258 GURL origin_;
259 259
260 base::WeakPtrFactory<CacheStorage> weak_factory_; 260 base::WeakPtrFactory<CacheStorage> weak_factory_;
261 261
262 DISALLOW_COPY_AND_ASSIGN(CacheStorage); 262 DISALLOW_COPY_AND_ASSIGN(CacheStorage);
263 }; 263 };
264 264
265 } // namespace content 265 } // namespace content
266 266
267 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ 267 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/cache_storage/cache_storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698