| 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_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 virtual ~ServiceWorkerCache(); | 62 virtual ~ServiceWorkerCache(); |
| 63 | 63 |
| 64 // Loads the backend and calls the callback with the result (true for | 64 // Loads the backend and calls the callback with the result (true for |
| 65 // success). This must be called before member functions that require a | 65 // success). This must be called before member functions that require a |
| 66 // backend are called. The callback will always be called. | 66 // backend are called. The callback will always be called. |
| 67 void CreateBackend(const ErrorCallback& callback); | 67 void CreateBackend(const ErrorCallback& callback); |
| 68 | 68 |
| 69 // Returns ErrorTypeNotFound if not found. The callback will always be called. | 69 // Returns ErrorTypeNotFound if not found. The callback will always be called. |
| 70 // |request| must remain valid until the callback is called. | 70 // |request| must remain valid until the callback is called. |
| 71 void Match(ServiceWorkerFetchRequest* request, | 71 void Match(scoped_ptr<ServiceWorkerFetchRequest> request, |
| 72 const ResponseCallback& callback); | 72 const ResponseCallback& callback); |
| 73 | 73 |
| 74 // Puts the request and response object in the cache. The response body (if | 74 // Puts the request and response object in the cache. The response body (if |
| 75 // present) is stored in the cache, but not the request body. Returns | 75 // present) is stored in the cache, but not the request body. Returns |
| 76 // ErrorTypeOK on success. The callback will always be called. |request| and | 76 // ErrorTypeOK on success. The callback will always be called. |request| and |
| 77 // |response| must remain valid until the callback is called. | 77 // |response| must remain valid until the callback is called. |
| 78 void Put(ServiceWorkerFetchRequest* request, | 78 void Put(scoped_ptr<ServiceWorkerFetchRequest> request, |
| 79 ServiceWorkerResponse* response, | 79 scoped_ptr<ServiceWorkerResponse> response, |
| 80 const ErrorCallback& callback); | 80 const ErrorCallback& callback); |
| 81 | 81 |
| 82 // Returns ErrorNotFound if not found. Otherwise deletes and returns | 82 // Returns ErrorNotFound if not found. Otherwise deletes and returns |
| 83 // ErrorTypeOK. The callback will always be called. |request| must remain | 83 // ErrorTypeOK. The callback will always be called. |request| must remain |
| 84 // valid until the callback is called. | 84 // valid until the callback is called. |
| 85 void Delete(ServiceWorkerFetchRequest* request, | 85 void Delete(scoped_ptr<ServiceWorkerFetchRequest> request, |
| 86 const ErrorCallback& callback); | 86 const ErrorCallback& callback); |
| 87 | 87 |
| 88 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. | 88 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. |
| 89 // Returns ErrorTypeOK and a vector of requests if there are no errors. The | 89 // Returns ErrorTypeOK and a vector of requests if there are no errors. The |
| 90 // callback will always be called. | 90 // callback will always be called. |
| 91 void Keys(const RequestsCallback& callback); | 91 void Keys(const RequestsCallback& callback); |
| 92 | 92 |
| 93 // Call to determine if CreateBackend must be called. | 93 // Call to determine if CreateBackend must be called. |
| 94 bool HasCreatedBackend() const; | 94 bool HasCreatedBackend() const; |
| 95 | 95 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 123 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 123 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
| 124 | 124 |
| 125 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; | 125 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; |
| 126 | 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); | 127 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 } // namespace content | 130 } // namespace content |
| 131 | 131 |
| 132 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ | 132 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ |
| OLD | NEW |