OLD | NEW |
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_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void DeleteCache(const std::string& cache_name, | 78 void DeleteCache(const std::string& cache_name, |
79 const BoolAndErrorCallback& callback); | 79 const BoolAndErrorCallback& callback); |
80 | 80 |
81 // Calls the callback with a vector of cache names (keys) available. | 81 // Calls the callback with a vector of cache names (keys) available. |
82 void EnumerateCaches(const StringsAndErrorCallback& callback); | 82 void EnumerateCaches(const StringsAndErrorCallback& callback); |
83 | 83 |
84 // TODO(jkarlin): Add match() function. | 84 // TODO(jkarlin): Add match() function. |
85 | 85 |
86 void CloseAllCaches(); | 86 void CloseAllCaches(); |
87 | 87 |
| 88 // The size of all of the origin's contents in memory. Returns 0 if the cache |
| 89 // backend is not a memory backend. |
| 90 int64 MemoryBackedSize() const; |
| 91 |
88 private: | 92 private: |
89 class MemoryLoader; | 93 class MemoryLoader; |
90 class SimpleCacheLoader; | 94 class SimpleCacheLoader; |
91 class CacheLoader; | 95 class CacheLoader; |
92 | 96 |
93 typedef std::map<std::string, base::WeakPtr<ServiceWorkerCache> > CacheMap; | 97 typedef std::map<std::string, base::WeakPtr<ServiceWorkerCache> > CacheMap; |
94 | 98 |
95 // Return a ServiceWorkerCache for the given name if the name is known. If the | 99 // Return a ServiceWorkerCache for the given name if the name is known. If the |
96 // ServiceWorkerCache has been deleted, creates a new one. | 100 // ServiceWorkerCache has been deleted, creates a new one. |
97 scoped_refptr<ServiceWorkerCache> GetLoadedCache( | 101 scoped_refptr<ServiceWorkerCache> GetLoadedCache( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 scoped_ptr<CacheLoader> cache_loader_; | 152 scoped_ptr<CacheLoader> cache_loader_; |
149 | 153 |
150 base::WeakPtrFactory<ServiceWorkerCacheStorage> weak_factory_; | 154 base::WeakPtrFactory<ServiceWorkerCacheStorage> weak_factory_; |
151 | 155 |
152 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage); | 156 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage); |
153 }; | 157 }; |
154 | 158 |
155 } // namespace content | 159 } // namespace content |
156 | 160 |
157 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ | 161 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ |
OLD | NEW |