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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 const GURL& origin, | 67 const GURL& origin, |
68 const base::FilePath& path, | 68 const base::FilePath& path, |
69 net::URLRequestContext* request_context, | 69 net::URLRequestContext* request_context, |
70 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 70 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
71 base::WeakPtr<storage::BlobStorageContext> blob_context); | 71 base::WeakPtr<storage::BlobStorageContext> blob_context); |
72 | 72 |
73 // Returns ERROR_TYPE_NOT_FOUND if not found. | 73 // Returns ERROR_TYPE_NOT_FOUND if not found. |
74 void Match(scoped_ptr<ServiceWorkerFetchRequest> request, | 74 void Match(scoped_ptr<ServiceWorkerFetchRequest> request, |
75 const ResponseCallback& callback); | 75 const ResponseCallback& callback); |
76 | 76 |
77 // Puts the request and response object in the cache. The response body (if | 77 // Runs given batch operations. This corresponds to the Batch Cache Operations |
78 // present) is stored in the cache, but not the request body. Returns | 78 // algorithm in the spec. |
79 // ERROR_TYPE_OK on success. | 79 void BatchOperation(const std::vector<CacheStorageBatchOperation>& operations, |
80 void Put(scoped_ptr<ServiceWorkerFetchRequest> request, | 80 const ErrorCallback& callback); |
81 scoped_ptr<ServiceWorkerResponse> response, | |
82 const ErrorCallback& callback); | |
83 | |
84 // Returns ErrorNotFound if not found. Otherwise deletes and returns | |
85 // ERROR_TYPE_OK. | |
86 void Delete(scoped_ptr<ServiceWorkerFetchRequest> request, | |
87 const ErrorCallback& callback); | |
88 | 81 |
89 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. | 82 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. |
90 // Returns ErrorTypeOK and a vector of requests if there are no errors. | 83 // Returns ErrorTypeOK and a vector of requests if there are no errors. |
91 void Keys(const RequestsCallback& callback); | 84 void Keys(const RequestsCallback& callback); |
92 | 85 |
93 // Closes the backend. Future operations that require the backend | 86 // Closes the backend. Future operations that require the backend |
94 // will exit early. Close should only be called once per CacheStorageCache. | 87 // will exit early. Close should only be called once per CacheStorageCache. |
95 void Close(const base::Closure& callback); | 88 void Close(const base::Closure& callback); |
96 | 89 |
97 // The size of the cache contents in memory. Returns 0 if the cache backend is | 90 // The size of the cache contents in memory. Returns 0 if the cache backend is |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Match callbacks | 126 // Match callbacks |
134 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 127 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
135 const ResponseCallback& callback); | 128 const ResponseCallback& callback); |
136 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); | 129 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); |
137 void MatchDidReadMetadata(scoped_ptr<MatchContext> match_context, | 130 void MatchDidReadMetadata(scoped_ptr<MatchContext> match_context, |
138 scoped_ptr<CacheMetadata> headers); | 131 scoped_ptr<CacheMetadata> headers); |
139 void MatchDidReadResponseBodyData(scoped_ptr<MatchContext> match_context, | 132 void MatchDidReadResponseBodyData(scoped_ptr<MatchContext> match_context, |
140 int rv); | 133 int rv); |
141 void MatchDoneWithBody(scoped_ptr<MatchContext> match_context); | 134 void MatchDoneWithBody(scoped_ptr<MatchContext> match_context); |
142 | 135 |
143 // Put callbacks. | 136 // Puts the request and response object in the cache. The response body (if |
| 137 // present) is stored in the cache, but not the request body. Returns |
| 138 // ERROR_TYPE_OK on success. |
| 139 void Put(const CacheStorageBatchOperation& operation, |
| 140 const ErrorCallback& callback); |
144 void PutImpl(scoped_ptr<PutContext> put_context); | 141 void PutImpl(scoped_ptr<PutContext> put_context); |
145 void PutDidDelete(scoped_ptr<PutContext> put_context, ErrorType delete_error); | 142 void PutDidDelete(scoped_ptr<PutContext> put_context, ErrorType delete_error); |
146 void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv); | 143 void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv); |
147 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, | 144 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, |
148 int expected_bytes, | 145 int expected_bytes, |
149 int rv); | 146 int rv); |
150 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, | 147 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, |
151 scoped_ptr<BlobReader> blob_reader, | 148 scoped_ptr<BlobReader> blob_reader, |
152 disk_cache::ScopedEntryPtr entry, | 149 disk_cache::ScopedEntryPtr entry, |
153 bool success); | 150 bool success); |
154 | 151 |
155 // Delete callbacks | 152 // Returns ErrorNotFound if not found. Otherwise deletes and returns |
| 153 // ERROR_TYPE_OK. |
| 154 void Delete(const CacheStorageBatchOperation& operation, |
| 155 const ErrorCallback& callback); |
156 void DeleteImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 156 void DeleteImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
157 const ErrorCallback& callback); | 157 const ErrorCallback& callback); |
158 void DeleteDidOpenEntry( | 158 void DeleteDidOpenEntry( |
159 const GURL& origin, | 159 const GURL& origin, |
160 scoped_ptr<ServiceWorkerFetchRequest> request, | 160 scoped_ptr<ServiceWorkerFetchRequest> request, |
161 const CacheStorageCache::ErrorCallback& callback, | 161 const CacheStorageCache::ErrorCallback& callback, |
162 scoped_ptr<disk_cache::Entry*> entryptr, | 162 scoped_ptr<disk_cache::Entry*> entryptr, |
163 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 163 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
164 int rv); | 164 int rv); |
165 | 165 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 bool memory_only_; | 211 bool memory_only_; |
212 | 212 |
213 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; | 213 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; |
214 | 214 |
215 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); | 215 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); |
216 }; | 216 }; |
217 | 217 |
218 } // namespace content | 218 } // namespace content |
219 | 219 |
220 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 220 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
OLD | NEW |