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

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

Issue 1470073003: [CacheStorage] Keep caches alive for 30 seconds after opening (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS3 Created 5 years 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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // The size of all of the origin's contents in memory. Returns 0 if the cache 95 // The size of all of the origin's contents in memory. Returns 0 if the cache
96 // backend is not a memory backend. Runs synchronously. 96 // backend is not a memory backend. Runs synchronously.
97 int64 MemoryBackedSize() const; 97 int64 MemoryBackedSize() const;
98 98
99 // The functions below are for tests to verify that the operations run 99 // The functions below are for tests to verify that the operations run
100 // serially. 100 // serially.
101 void StartAsyncOperationForTesting(); 101 void StartAsyncOperationForTesting();
102 void CompleteAsyncOperationForTesting(); 102 void CompleteAsyncOperationForTesting();
103 103
104 private: 104 private:
105 friend class TestCacheStorage;
106
105 class MemoryLoader; 107 class MemoryLoader;
106 class SimpleCacheLoader; 108 class SimpleCacheLoader;
107 class CacheLoader; 109 class CacheLoader;
108 110
109 typedef std::map<std::string, base::WeakPtr<CacheStorageCache>> CacheMap; 111 typedef std::map<std::string, base::WeakPtr<CacheStorageCache>> CacheMap;
110 112
111 // Return a CacheStorageCache for the given name if the name is known. If the 113 // Return a CacheStorageCache for the given name if the name is known. If the
112 // CacheStorageCache has been deleted, creates a new one. 114 // CacheStorageCache has been deleted, creates a new one.
113 scoped_refptr<CacheStorageCache> GetLoadedCache( 115 scoped_refptr<CacheStorageCache> GetLoadedCache(
114 const std::string& cache_name); 116 const std::string& cache_name);
115 117
118 // Holds a reference to a cache for thirty seconds.
119 void TemporarilyPreserveCache(const scoped_refptr<CacheStorageCache>& cache);
120 virtual void SchedulePreservedCacheRemoval(
121 const base::Closure& callback); // Virtual for testing.
122 void RemovePreservedCache(const CacheStorageCache* cache);
123
116 // Initializer and its callback are below. 124 // Initializer and its callback are below.
117 void LazyInit(); 125 void LazyInit();
118 void LazyInitImpl(); 126 void LazyInitImpl();
119 void LazyInitDidLoadIndex( 127 void LazyInitDidLoadIndex(
120 scoped_ptr<std::vector<std::string>> indexed_cache_names); 128 scoped_ptr<std::vector<std::string>> indexed_cache_names);
121 129
122 // The Open and CreateCache callbacks are below. 130 // The Open and CreateCache callbacks are below.
123 void OpenCacheImpl(const std::string& cache_name, 131 void OpenCacheImpl(const std::string& cache_name,
124 const CacheAndErrorCallback& callback); 132 const CacheAndErrorCallback& callback);
125 void CreateCacheDidCreateCache(const std::string& cache_name, 133 void CreateCacheDidCreateCache(const std::string& cache_name,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 218
211 // The TaskRunner to run file IO on. 219 // The TaskRunner to run file IO on.
212 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_; 220 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_;
213 221
214 // Whether or not to store data in disk or memory. 222 // Whether or not to store data in disk or memory.
215 bool memory_only_; 223 bool memory_only_;
216 224
217 // Performs backend specific operations (memory vs disk). 225 // Performs backend specific operations (memory vs disk).
218 scoped_ptr<CacheLoader> cache_loader_; 226 scoped_ptr<CacheLoader> cache_loader_;
219 227
228 // Holds ref pointers to recently opened caches so that they can be reused
229 // without having the open the cache again.
230 std::map<const CacheStorageCache*, scoped_refptr<CacheStorageCache>>
231 preserved_caches_;
232
220 base::WeakPtrFactory<CacheStorage> weak_factory_; 233 base::WeakPtrFactory<CacheStorage> weak_factory_;
221 234
222 DISALLOW_COPY_AND_ASSIGN(CacheStorage); 235 DISALLOW_COPY_AND_ASSIGN(CacheStorage);
223 }; 236 };
224 237
225 } // namespace content 238 } // namespace content
226 239
227 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ 240 #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