| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // not a memory cache backend. | 97 // not a memory cache backend. |
| 98 int64 MemoryBackedSize() const; | 98 int64 MemoryBackedSize() const; |
| 99 | 99 |
| 100 base::WeakPtr<CacheStorageCache> AsWeakPtr(); | 100 base::WeakPtr<CacheStorageCache> AsWeakPtr(); |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 friend class base::RefCounted<CacheStorageCache>; | 103 friend class base::RefCounted<CacheStorageCache>; |
| 104 friend class TestCacheStorageCache; | 104 friend class TestCacheStorageCache; |
| 105 | 105 |
| 106 struct KeysContext; | 106 struct KeysContext; |
| 107 struct MatchContext; | |
| 108 struct PutContext; | 107 struct PutContext; |
| 109 | 108 |
| 110 // The backend progresses from uninitialized, to open, to closed, and cannot | 109 // The backend progresses from uninitialized, to open, to closed, and cannot |
| 111 // reverse direction. The open step may be skipped. | 110 // reverse direction. The open step may be skipped. |
| 112 enum BackendState { | 111 enum BackendState { |
| 113 BACKEND_UNINITIALIZED, // No backend, create backend on first operation. | 112 BACKEND_UNINITIALIZED, // No backend, create backend on first operation. |
| 114 BACKEND_OPEN, // Backend can be used. | 113 BACKEND_OPEN, // Backend can be used. |
| 115 BACKEND_CLOSED // Backend cannot be used. All ops should fail. | 114 BACKEND_CLOSED // Backend cannot be used. All ops should fail. |
| 116 }; | 115 }; |
| 117 | 116 |
| 118 using Entries = std::vector<disk_cache::Entry*>; | 117 using Entries = std::vector<disk_cache::Entry*>; |
| 119 using ScopedBackendPtr = scoped_ptr<disk_cache::Backend>; | 118 using ScopedBackendPtr = scoped_ptr<disk_cache::Backend>; |
| 120 | 119 |
| 121 CacheStorageCache( | 120 CacheStorageCache( |
| 122 const GURL& origin, | 121 const GURL& origin, |
| 123 const base::FilePath& path, | 122 const base::FilePath& path, |
| 124 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | 123 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
| 125 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 124 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
| 126 base::WeakPtr<storage::BlobStorageContext> blob_context); | 125 base::WeakPtr<storage::BlobStorageContext> blob_context); |
| 127 | 126 |
| 128 // Async operations in progress will cancel and not run their callbacks. | 127 // Async operations in progress will cancel and not run their callbacks. |
| 129 virtual ~CacheStorageCache(); | 128 virtual ~CacheStorageCache(); |
| 130 | 129 |
| 131 // Match callbacks | 130 // Match callbacks |
| 132 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 131 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
| 133 const ResponseCallback& callback); | 132 const ResponseCallback& callback); |
| 134 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); | 133 void MatchDidOpenEntry(scoped_ptr<ServiceWorkerFetchRequest> request, |
| 135 void MatchDidReadMetadata(scoped_ptr<MatchContext> match_context, | 134 const ResponseCallback& callback, |
| 135 scoped_ptr<disk_cache::Entry*> entry_ptr, |
| 136 int rv); |
| 137 void MatchDidReadMetadata(scoped_ptr<ServiceWorkerFetchRequest> request, |
| 138 const ResponseCallback& callback, |
| 139 disk_cache::ScopedEntryPtr entry, |
| 136 scoped_ptr<CacheMetadata> headers); | 140 scoped_ptr<CacheMetadata> headers); |
| 137 void MatchDidReadResponseBodyData(scoped_ptr<MatchContext> match_context, | |
| 138 int rv); | |
| 139 void MatchDoneWithBody(scoped_ptr<MatchContext> match_context); | |
| 140 | 141 |
| 141 // Puts the request and response object in the cache. The response body (if | 142 // 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 | 143 // present) is stored in the cache, but not the request body. Returns OK on |
| 143 // success. | 144 // success. |
| 144 void Put(const CacheStorageBatchOperation& operation, | 145 void Put(const CacheStorageBatchOperation& operation, |
| 145 const ErrorCallback& callback); | 146 const ErrorCallback& callback); |
| 146 void PutImpl(scoped_ptr<PutContext> put_context); | 147 void PutImpl(scoped_ptr<PutContext> put_context); |
| 147 void PutDidDelete(scoped_ptr<PutContext> put_context, | 148 void PutDidDelete(scoped_ptr<PutContext> put_context, |
| 148 CacheStorageError delete_error); | 149 CacheStorageError delete_error); |
| 149 void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv); | 150 void PutDidCreateEntry(scoped_ptr<disk_cache::Entry*> entry_ptr, |
| 151 scoped_ptr<PutContext> put_context, |
| 152 int rv); |
| 150 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, | 153 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, |
| 151 int expected_bytes, | 154 int expected_bytes, |
| 152 int rv); | 155 int rv); |
| 153 void PutDidWriteBlobToCache( | 156 void PutDidWriteBlobToCache( |
| 154 scoped_ptr<PutContext> put_context, | 157 scoped_ptr<PutContext> put_context, |
| 155 scoped_ptr<CacheStorageBlobToDiskCache> blob_reader, | 158 scoped_ptr<CacheStorageBlobToDiskCache> blob_reader, |
| 156 disk_cache::ScopedEntryPtr entry, | 159 disk_cache::ScopedEntryPtr entry, |
| 157 bool success); | 160 bool success); |
| 158 | 161 |
| 159 // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK. | 162 // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 bool memory_only_; | 221 bool memory_only_; |
| 219 | 222 |
| 220 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; | 223 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; |
| 221 | 224 |
| 222 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); | 225 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); |
| 223 }; | 226 }; |
| 224 | 227 |
| 225 } // namespace content | 228 } // namespace content |
| 226 | 229 |
| 227 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 230 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
| OLD | NEW |