Chromium Code Reviews| 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_CACHE_H_ | 5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
| 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 void Close(const base::Closure& callback); | 93 void Close(const base::Closure& callback); |
| 94 | 94 |
| 95 // The size of the cache contents in memory. Returns 0 if the cache backend is | 95 // The size of the cache contents in memory. Returns 0 if the cache backend is |
| 96 // not a memory cache backend. | 96 // not a memory cache backend. |
| 97 int64 MemoryBackedSize() const; | 97 int64 MemoryBackedSize() const; |
| 98 | 98 |
| 99 base::WeakPtr<CacheStorageCache> AsWeakPtr(); | 99 base::WeakPtr<CacheStorageCache> AsWeakPtr(); |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 friend class base::RefCounted<CacheStorageCache>; | 102 friend class base::RefCounted<CacheStorageCache>; |
| 103 friend class CacheStorageCacheTest; | |
|
jkarlin
2015/06/12 15:53:37
Is this necessary? Not seeing any uses of it in th
gavinp
2015/06/12 18:10:30
Done.
| |
| 103 friend class TestCacheStorageCache; | 104 friend class TestCacheStorageCache; |
| 104 | 105 |
| 105 class BlobReader; | 106 class BlobReader; |
| 106 struct KeysContext; | 107 struct KeysContext; |
| 107 struct MatchContext; | 108 struct MatchContext; |
| 108 struct PutContext; | 109 struct PutContext; |
| 109 | 110 |
| 110 // The backend progresses from uninitialized, to open, to closed, and cannot | 111 // The backend progresses from uninitialized, to open, to closed, and cannot |
| 111 // reverse direction. The open step may be skipped. | 112 // reverse direction. The open step may be skipped. |
| 112 enum BackendState { | 113 enum BackendState { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 124 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | 125 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
| 125 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 126 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
| 126 base::WeakPtr<storage::BlobStorageContext> blob_context); | 127 base::WeakPtr<storage::BlobStorageContext> blob_context); |
| 127 | 128 |
| 128 // Async operations in progress will cancel and not run their callbacks. | 129 // Async operations in progress will cancel and not run their callbacks. |
| 129 virtual ~CacheStorageCache(); | 130 virtual ~CacheStorageCache(); |
| 130 | 131 |
| 131 // Match callbacks | 132 // Match callbacks |
| 132 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 133 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
| 133 const ResponseCallback& callback); | 134 const ResponseCallback& callback); |
| 134 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); | 135 void MatchDidOpenEntry(scoped_ptr<disk_cache::Entry*> entry_ptr, |
| 136 scoped_ptr<MatchContext> match_context, | |
| 137 int rv); | |
| 135 void MatchDidReadMetadata(scoped_ptr<MatchContext> match_context, | 138 void MatchDidReadMetadata(scoped_ptr<MatchContext> match_context, |
| 136 scoped_ptr<CacheMetadata> headers); | 139 scoped_ptr<CacheMetadata> headers); |
| 137 void MatchDidReadResponseBodyData(scoped_ptr<MatchContext> match_context, | |
| 138 int rv); | |
| 139 void MatchDoneWithBody(scoped_ptr<MatchContext> match_context); | |
| 140 | 140 |
| 141 // Puts the request and response object in the cache. The response body (if | 141 // Puts the request and response object in the cache. The response body (if |
| 142 // present) is stored in the cache, but not the request body. Returns OK on | 142 // present) is stored in the cache, but not the request body. Returns OK on |
| 143 // success. | 143 // success. |
| 144 void Put(const CacheStorageBatchOperation& operation, | 144 void Put(const CacheStorageBatchOperation& operation, |
| 145 const ErrorCallback& callback); | 145 const ErrorCallback& callback); |
| 146 void PutImpl(scoped_ptr<PutContext> put_context); | 146 void PutImpl(scoped_ptr<PutContext> put_context); |
| 147 void PutDidDelete(scoped_ptr<PutContext> put_context, | 147 void PutDidDelete(scoped_ptr<PutContext> put_context, |
| 148 CacheStorageError delete_error); | 148 CacheStorageError delete_error); |
| 149 void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv); | 149 void PutDidCreateEntry(scoped_ptr<disk_cache::Entry*> entry_ptr, |
| 150 scoped_ptr<PutContext> put_context, | |
| 151 int rv); | |
| 150 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, | 152 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, |
| 151 int expected_bytes, | 153 int expected_bytes, |
| 152 int rv); | 154 int rv); |
| 153 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, | 155 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, |
| 154 scoped_ptr<BlobReader> blob_reader, | 156 scoped_ptr<BlobReader> blob_reader, |
| 155 disk_cache::ScopedEntryPtr entry, | 157 disk_cache::ScopedEntryPtr entry, |
| 156 bool success); | 158 bool success); |
| 157 | 159 |
| 158 // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK. | 160 // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK. |
| 159 void Delete(const CacheStorageBatchOperation& operation, | 161 void Delete(const CacheStorageBatchOperation& operation, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 bool memory_only_; | 219 bool memory_only_; |
| 218 | 220 |
| 219 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; | 221 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; |
| 220 | 222 |
| 221 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); | 223 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); |
| 222 }; | 224 }; |
| 223 | 225 |
| 224 } // namespace content | 226 } // namespace content |
| 225 | 227 |
| 226 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 228 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
| OLD | NEW |