| 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_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> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/gtest_prod_util.h" |
| 17 #include "base/macros.h" | 18 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 20 #include "content/browser/cache_storage/cache_storage_cache.h" | 21 #include "content/browser/cache_storage/cache_storage_cache.h" |
| 21 #include "content/browser/cache_storage/cache_storage_cache_observer.h" | 22 #include "content/browser/cache_storage/cache_storage_cache_observer.h" |
| 22 | 23 |
| 23 namespace base { | 24 namespace base { |
| 24 class SequencedTaskRunner; | 25 class SequencedTaskRunner; |
| 25 } | 26 } |
| 26 | 27 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // The size of all of the origin's contents. This value should be used as an | 113 // The size of all of the origin's contents. This value should be used as an |
| 113 // estimate only since the cache may be modified at any time. | 114 // estimate only since the cache may be modified at any time. |
| 114 void Size(SizeCallback callback); | 115 void Size(SizeCallback callback); |
| 115 | 116 |
| 116 // The functions below are for tests to verify that the operations run | 117 // The functions below are for tests to verify that the operations run |
| 117 // serially. | 118 // serially. |
| 118 void StartAsyncOperationForTesting(); | 119 void StartAsyncOperationForTesting(); |
| 119 void CompleteAsyncOperationForTesting(); | 120 void CompleteAsyncOperationForTesting(); |
| 120 | 121 |
| 121 // CacheStorageCacheObserver: | 122 // CacheStorageCacheObserver: |
| 122 void CacheSizeUpdated(const CacheStorageCache* cache, int64_t size) override; | 123 void CacheSizeUpdated(const CacheStorageCache* cache) override; |
| 123 | 124 |
| 124 private: | 125 private: |
| 125 friend class CacheStorageCacheHandle; | 126 friend class CacheStorageCacheHandle; |
| 126 friend class CacheStorageCache; | 127 friend class CacheStorageCache; |
| 127 friend class CacheStorageManagerTest; | 128 friend class CacheStorageManagerTest; |
| 129 FRIEND_TEST_ALL_PREFIXES(CacheStorageManagerTest, PersistedCacheKeyUsed); |
| 128 class CacheLoader; | 130 class CacheLoader; |
| 129 class MemoryLoader; | 131 class MemoryLoader; |
| 130 class SimpleCacheLoader; | 132 class SimpleCacheLoader; |
| 131 struct CacheMatchResponse; | 133 struct CacheMatchResponse; |
| 132 | 134 |
| 133 typedef std::map<std::string, std::unique_ptr<CacheStorageCache>> CacheMap; | 135 typedef std::map<std::string, std::unique_ptr<CacheStorageCache>> CacheMap; |
| 134 | 136 |
| 137 // Generate a new padding key. For testing only and *not thread safe*. |
| 138 static void GenerateNewKeyForTesting(); |
| 139 |
| 135 // Functions for exposing handles to CacheStorageCache to clients. | 140 // Functions for exposing handles to CacheStorageCache to clients. |
| 136 std::unique_ptr<CacheStorageCacheHandle> CreateCacheHandle( | 141 std::unique_ptr<CacheStorageCacheHandle> CreateCacheHandle( |
| 137 CacheStorageCache* cache); | 142 CacheStorageCache* cache); |
| 138 void AddCacheHandleRef(CacheStorageCache* cache); | 143 void AddCacheHandleRef(CacheStorageCache* cache); |
| 139 void DropCacheHandleRef(CacheStorageCache* cache); | 144 void DropCacheHandleRef(CacheStorageCache* cache); |
| 140 | 145 |
| 141 // Returns a CacheStorageCacheHandle for the given name if the name is known. | 146 // Returns a CacheStorageCacheHandle for the given name if the name is known. |
| 142 // If the CacheStorageCache has been deleted, creates a new one. | 147 // If the CacheStorageCache has been deleted, creates a new one. |
| 143 std::unique_ptr<CacheStorageCacheHandle> GetLoadedCache( | 148 std::unique_ptr<CacheStorageCacheHandle> GetLoadedCache( |
| 144 const std::string& cache_name); | 149 const std::string& cache_name); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 base::CancelableClosure index_write_task_; | 269 base::CancelableClosure index_write_task_; |
| 265 | 270 |
| 266 base::WeakPtrFactory<CacheStorage> weak_factory_; | 271 base::WeakPtrFactory<CacheStorage> weak_factory_; |
| 267 | 272 |
| 268 DISALLOW_COPY_AND_ASSIGN(CacheStorage); | 273 DISALLOW_COPY_AND_ASSIGN(CacheStorage); |
| 269 }; | 274 }; |
| 270 | 275 |
| 271 } // namespace content | 276 } // namespace content |
| 272 | 277 |
| 273 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ | 278 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ |
| OLD | NEW |