| 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/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 const ErrorCallback& callback); | 83 const ErrorCallback& callback); |
| 84 | 84 |
| 85 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. | 85 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. |
| 86 // Returns ErrorTypeOK and a vector of requests if there are no errors. The | 86 // Returns ErrorTypeOK and a vector of requests if there are no errors. The |
| 87 // callback will always be called. | 87 // callback will always be called. |
| 88 void Keys(const RequestsCallback& callback); | 88 void Keys(const RequestsCallback& callback); |
| 89 | 89 |
| 90 // Prevent further operations on this object and delete the backend. | 90 // Prevent further operations on this object and delete the backend. |
| 91 void Close(); | 91 void Close(); |
| 92 | 92 |
| 93 // The size of the cache contents in memory. Returns 0 if the cache backend is |
| 94 // not a memory cache backend. |
| 95 int64 MemoryBackedSize() const; |
| 96 |
| 93 void set_backend(scoped_ptr<disk_cache::Backend> backend) { | 97 void set_backend(scoped_ptr<disk_cache::Backend> backend) { |
| 94 backend_ = backend.Pass(); | 98 backend_ = backend.Pass(); |
| 95 } | 99 } |
| 96 | 100 |
| 97 base::WeakPtr<ServiceWorkerCache> AsWeakPtr(); | 101 base::WeakPtr<ServiceWorkerCache> AsWeakPtr(); |
| 98 | 102 |
| 99 private: | 103 private: |
| 100 friend class base::RefCounted<ServiceWorkerCache>; | 104 friend class base::RefCounted<ServiceWorkerCache>; |
| 101 | 105 |
| 102 struct KeysContext; | 106 struct KeysContext; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // check for its existence before use. | 143 // check for its existence before use. |
| 140 scoped_ptr<disk_cache::Backend> backend_; | 144 scoped_ptr<disk_cache::Backend> backend_; |
| 141 GURL origin_; | 145 GURL origin_; |
| 142 base::FilePath path_; | 146 base::FilePath path_; |
| 143 net::URLRequestContext* request_context_; | 147 net::URLRequestContext* request_context_; |
| 144 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; | 148 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; |
| 145 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 149 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
| 146 bool initialized_; | 150 bool initialized_; |
| 147 std::vector<base::Closure> init_callbacks_; | 151 std::vector<base::Closure> init_callbacks_; |
| 148 | 152 |
| 153 // Whether or not to store data in disk or memory. |
| 154 bool memory_only_; |
| 155 |
| 149 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; | 156 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; |
| 150 | 157 |
| 151 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); | 158 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); |
| 152 }; | 159 }; |
| 153 | 160 |
| 154 } // namespace content | 161 } // namespace content |
| 155 | 162 |
| 156 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ | 163 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ |
| OLD | NEW |