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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 const GURL& origin, | 57 const GURL& origin, |
58 const base::FilePath& path, | 58 const base::FilePath& path, |
59 net::URLRequestContext* request_context, | 59 net::URLRequestContext* request_context, |
60 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 60 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
61 base::WeakPtr<storage::BlobStorageContext> blob_context); | 61 base::WeakPtr<storage::BlobStorageContext> blob_context); |
62 | 62 |
63 // Returns ERROR_TYPE_NOT_FOUND if not found. | 63 // Returns ERROR_TYPE_NOT_FOUND if not found. |
64 void Match(scoped_ptr<ServiceWorkerFetchRequest> request, | 64 void Match(scoped_ptr<ServiceWorkerFetchRequest> request, |
65 const ResponseCallback& callback); | 65 const ResponseCallback& callback); |
66 | 66 |
67 // Puts the request and response object in the cache. The response body (if | 67 // Runs given batch operations. This corresponds to the Batch Cache Operations |
68 // present) is stored in the cache, but not the request body. Returns | 68 // algorithm in the spec. |
69 // ERROR_TYPE_OK on success. | 69 // |
70 void Put(scoped_ptr<ServiceWorkerFetchRequest> request, | 70 // |operations| cannot mix PUT and DELETE operations and cannot contain |
71 scoped_ptr<ServiceWorkerResponse> response, | 71 // multiple DELETE operations. |
72 const ErrorCallback& callback); | 72 // |
73 | 73 // In the case of the PUT operation, puts request and response objects in the |
74 // Returns ErrorNotFound if not found. Otherwise deletes and returns | 74 // cache and returns OK when all operations are successfully completed. |
75 // ERROR_TYPE_OK. | 75 // In the case of the DELETE operation, returns ERROR_NOT_FOUND if a specified |
76 void Delete(scoped_ptr<ServiceWorkerFetchRequest> request, | 76 // entry is not found. Otherwise deletes it and returns OK. |
77 const ErrorCallback& callback); | 77 // |
| 78 // TODO(nhiroki): This function should run all operations atomically. |
| 79 // http://crbug.com/486637 |
| 80 void BatchOperation(const std::vector<CacheStorageBatchOperation>& operations, |
| 81 const ErrorCallback& callback); |
| 82 void BatchDidOneOperation(const base::Closure& barrier_closure, |
| 83 ErrorCallback* callback, |
| 84 CacheStorageError error); |
| 85 void BatchDidAllOperations(scoped_ptr<ErrorCallback> callback); |
78 | 86 |
79 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. | 87 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. |
80 // Returns CACHE_STORAGE_OK and a vector of requests if there are no errors. | 88 // Returns CACHE_STORAGE_OK and a vector of requests if there are no errors. |
81 void Keys(const RequestsCallback& callback); | 89 void Keys(const RequestsCallback& callback); |
82 | 90 |
83 // Closes the backend. Future operations that require the backend | 91 // Closes the backend. Future operations that require the backend |
84 // will exit early. Close should only be called once per CacheStorageCache. | 92 // will exit early. Close should only be called once per CacheStorageCache. |
85 void Close(const base::Closure& callback); | 93 void Close(const base::Closure& callback); |
86 | 94 |
87 // 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 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // Match callbacks | 131 // Match callbacks |
124 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 132 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
125 const ResponseCallback& callback); | 133 const ResponseCallback& callback); |
126 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); | 134 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); |
127 void MatchDidReadMetadata(scoped_ptr<MatchContext> match_context, | 135 void MatchDidReadMetadata(scoped_ptr<MatchContext> match_context, |
128 scoped_ptr<CacheMetadata> headers); | 136 scoped_ptr<CacheMetadata> headers); |
129 void MatchDidReadResponseBodyData(scoped_ptr<MatchContext> match_context, | 137 void MatchDidReadResponseBodyData(scoped_ptr<MatchContext> match_context, |
130 int rv); | 138 int rv); |
131 void MatchDoneWithBody(scoped_ptr<MatchContext> match_context); | 139 void MatchDoneWithBody(scoped_ptr<MatchContext> match_context); |
132 | 140 |
133 // Put callbacks. | 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 |
| 143 // success. |
| 144 void Put(const CacheStorageBatchOperation& operation, |
| 145 const ErrorCallback& callback); |
134 void PutImpl(scoped_ptr<PutContext> put_context); | 146 void PutImpl(scoped_ptr<PutContext> put_context); |
135 void PutDidDelete(scoped_ptr<PutContext> put_context, | 147 void PutDidDelete(scoped_ptr<PutContext> put_context, |
136 CacheStorageError delete_error); | 148 CacheStorageError delete_error); |
137 void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv); | 149 void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv); |
138 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, | 150 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, |
139 int expected_bytes, | 151 int expected_bytes, |
140 int rv); | 152 int rv); |
141 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, | 153 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, |
142 scoped_ptr<BlobReader> blob_reader, | 154 scoped_ptr<BlobReader> blob_reader, |
143 disk_cache::ScopedEntryPtr entry, | 155 disk_cache::ScopedEntryPtr entry, |
144 bool success); | 156 bool success); |
145 | 157 |
146 // Delete callbacks | 158 // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK. |
| 159 void Delete(const CacheStorageBatchOperation& operation, |
| 160 const ErrorCallback& callback); |
147 void DeleteImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 161 void DeleteImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
148 const ErrorCallback& callback); | 162 const ErrorCallback& callback); |
149 void DeleteDidOpenEntry( | 163 void DeleteDidOpenEntry( |
150 const GURL& origin, | 164 const GURL& origin, |
151 scoped_ptr<ServiceWorkerFetchRequest> request, | 165 scoped_ptr<ServiceWorkerFetchRequest> request, |
152 const CacheStorageCache::ErrorCallback& callback, | 166 const CacheStorageCache::ErrorCallback& callback, |
153 scoped_ptr<disk_cache::Entry*> entryptr, | 167 scoped_ptr<disk_cache::Entry*> entryptr, |
154 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 168 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
155 int rv); | 169 int rv); |
156 | 170 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 bool memory_only_; | 217 bool memory_only_; |
204 | 218 |
205 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; | 219 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; |
206 | 220 |
207 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); | 221 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); |
208 }; | 222 }; |
209 | 223 |
210 } // namespace content | 224 } // namespace content |
211 | 225 |
212 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 226 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
OLD | NEW |