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. |
jkarlin
2015/05/08 12:04:25
Add a TODO and a corresponding crbug to make this
jkarlin
2015/05/08 15:27:27
Add a comment that operations can't be mixed. Desc
nhiroki
2015/05/11 07:35:04
Done.
nhiroki
2015/05/11 07:35:04
Done.
| |
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, | 81 void BatchDidOperation(const base::Closure& barrier_closure, |
jkarlin
2015/05/08 11:45:43
nit: Suggest BatchDidOneOperation. I hope to chang
nhiroki
2015/05/11 07:35:04
Done.
| |
82 const ErrorCallback& callback); | 82 ErrorCallback* callback, |
83 | 83 ErrorType error); |
84 // Returns ErrorNotFound if not found. Otherwise deletes and returns | 84 void BatchDidAllOperations(scoped_ptr<ErrorCallback> callback); |
85 // ERROR_TYPE_OK. | |
86 void Delete(scoped_ptr<ServiceWorkerFetchRequest> request, | |
87 const ErrorCallback& callback); | |
88 | 85 |
89 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. | 86 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. |
90 // Returns ErrorTypeOK and a vector of requests if there are no errors. | 87 // Returns ErrorTypeOK and a vector of requests if there are no errors. |
91 void Keys(const RequestsCallback& callback); | 88 void Keys(const RequestsCallback& callback); |
92 | 89 |
93 // Closes the backend. Future operations that require the backend | 90 // Closes the backend. Future operations that require the backend |
94 // will exit early. Close should only be called once per CacheStorageCache. | 91 // will exit early. Close should only be called once per CacheStorageCache. |
95 void Close(const base::Closure& callback); | 92 void Close(const base::Closure& callback); |
96 | 93 |
97 // The size of the cache contents in memory. Returns 0 if the cache backend is | 94 // 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 | 130 // Match callbacks |
134 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 131 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
135 const ResponseCallback& callback); | 132 const ResponseCallback& callback); |
136 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); | 133 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); |
137 void MatchDidReadMetadata(scoped_ptr<MatchContext> match_context, | 134 void MatchDidReadMetadata(scoped_ptr<MatchContext> match_context, |
138 scoped_ptr<CacheMetadata> headers); | 135 scoped_ptr<CacheMetadata> headers); |
139 void MatchDidReadResponseBodyData(scoped_ptr<MatchContext> match_context, | 136 void MatchDidReadResponseBodyData(scoped_ptr<MatchContext> match_context, |
140 int rv); | 137 int rv); |
141 void MatchDoneWithBody(scoped_ptr<MatchContext> match_context); | 138 void MatchDoneWithBody(scoped_ptr<MatchContext> match_context); |
142 | 139 |
143 // Put callbacks. | 140 // Puts the request and response object in the cache. The response body (if |
141 // present) is stored in the cache, but not the request body. Returns | |
142 // ERROR_TYPE_OK on success. | |
143 void Put(const CacheStorageBatchOperation& operation, | |
144 const ErrorCallback& callback); | |
144 void PutImpl(scoped_ptr<PutContext> put_context); | 145 void PutImpl(scoped_ptr<PutContext> put_context); |
145 void PutDidDelete(scoped_ptr<PutContext> put_context, ErrorType delete_error); | 146 void PutDidDelete(scoped_ptr<PutContext> put_context, ErrorType delete_error); |
146 void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv); | 147 void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv); |
147 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, | 148 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, |
148 int expected_bytes, | 149 int expected_bytes, |
149 int rv); | 150 int rv); |
150 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, | 151 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, |
151 scoped_ptr<BlobReader> blob_reader, | 152 scoped_ptr<BlobReader> blob_reader, |
152 disk_cache::ScopedEntryPtr entry, | 153 disk_cache::ScopedEntryPtr entry, |
153 bool success); | 154 bool success); |
154 | 155 |
155 // Delete callbacks | 156 // Returns ErrorNotFound if not found. Otherwise deletes and returns |
157 // ERROR_TYPE_OK. | |
158 void Delete(const CacheStorageBatchOperation& operation, | |
159 const ErrorCallback& callback); | |
156 void DeleteImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 160 void DeleteImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
157 const ErrorCallback& callback); | 161 const ErrorCallback& callback); |
158 void DeleteDidOpenEntry( | 162 void DeleteDidOpenEntry( |
159 const GURL& origin, | 163 const GURL& origin, |
160 scoped_ptr<ServiceWorkerFetchRequest> request, | 164 scoped_ptr<ServiceWorkerFetchRequest> request, |
161 const CacheStorageCache::ErrorCallback& callback, | 165 const CacheStorageCache::ErrorCallback& callback, |
162 scoped_ptr<disk_cache::Entry*> entryptr, | 166 scoped_ptr<disk_cache::Entry*> entryptr, |
163 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 167 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
164 int rv); | 168 int rv); |
165 | 169 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 bool memory_only_; | 215 bool memory_only_; |
212 | 216 |
213 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; | 217 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; |
214 | 218 |
215 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); | 219 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); |
216 }; | 220 }; |
217 | 221 |
218 } // namespace content | 222 } // namespace content |
219 | 223 |
220 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 224 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
OLD | NEW |