Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: content/browser/service_worker/service_worker_cache.h

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: memory leak fixed Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/common/service_worker/service_worker_types.h" 12 #include "content/common/service_worker/service_worker_types.h"
13 #include "net/base/completion_callback.h" 13 #include "net/base/completion_callback.h"
14 #include "net/disk_cache/disk_cache.h" 14 #include "net/disk_cache/disk_cache.h"
15 15
16 namespace net { 16 namespace net {
17 class URLRequestContext; 17 class URLRequestContext;
18 class IOBufferWithSize; 18 class IOBufferWithSize;
19 } 19 }
20 20
21 namespace storage { 21 namespace storage {
22 class BlobData; 22 class BlobDataBuilder;
23 class BlobDataHandle; 23 class BlobDataSnapshotHandle;
24 class BlobStorageContext; 24 class BlobStorageContext;
25 class QuotaManagerProxy; 25 class QuotaManagerProxy;
26 } 26 }
27 27
28 namespace content { 28 namespace content {
29 class ChromeBlobStorageContext; 29 class ChromeBlobStorageContext;
30 class ServiceWorkerCacheMetadata; 30 class ServiceWorkerCacheMetadata;
31 class TestServiceWorkerCache; 31 class TestServiceWorkerCache;
32 32
33 // Represents a ServiceWorker Cache as seen in 33 // Represents a ServiceWorker Cache as seen in
34 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 34 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
35 // Callbacks to the public functions will be called so long as the cache object 35 // Callbacks to the public functions will be called so long as the cache object
36 // lives. 36 // lives.
37 class CONTENT_EXPORT ServiceWorkerCache 37 class CONTENT_EXPORT ServiceWorkerCache
38 : public base::RefCounted<ServiceWorkerCache> { 38 : public base::RefCounted<ServiceWorkerCache> {
39 public: 39 public:
40 enum ErrorType { 40 enum ErrorType {
41 ErrorTypeOK = 0, 41 ErrorTypeOK = 0,
42 ErrorTypeExists, 42 ErrorTypeExists,
43 ErrorTypeStorage, 43 ErrorTypeStorage,
44 ErrorTypeNotFound 44 ErrorTypeNotFound
45 }; 45 };
46 46
47 enum EntryIndex { INDEX_HEADERS = 0, INDEX_RESPONSE_BODY }; 47 enum EntryIndex { INDEX_HEADERS = 0, INDEX_RESPONSE_BODY };
48 typedef base::Callback<void(ErrorType)> ErrorCallback; 48 typedef base::Callback<void(ErrorType)> ErrorCallback;
49 typedef base::Callback<void(ErrorType, 49 typedef base::Callback<void(ErrorType,
50 scoped_ptr<ServiceWorkerResponse>, 50 scoped_ptr<ServiceWorkerResponse>,
51 scoped_ptr<storage::BlobDataHandle>)> 51 scoped_ptr<storage::BlobDataSnapshotHandle>)>
52 ResponseCallback; 52 ResponseCallback;
53 typedef std::vector<ServiceWorkerFetchRequest> Requests; 53 typedef std::vector<ServiceWorkerFetchRequest> Requests;
54 typedef base::Callback<void(ErrorType, scoped_ptr<Requests>)> 54 typedef base::Callback<void(ErrorType, scoped_ptr<Requests>)>
55 RequestsCallback; 55 RequestsCallback;
56 56
57 static scoped_refptr<ServiceWorkerCache> CreateMemoryCache( 57 static scoped_refptr<ServiceWorkerCache> CreateMemoryCache(
58 const GURL& origin, 58 const GURL& origin,
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);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void InitBackend(const base::Closure& callback); 175 void InitBackend(const base::Closure& callback);
176 void InitDone(ErrorType error); 176 void InitDone(ErrorType error);
177 177
178 void IncPendingOps() { pending_ops_++; } 178 void IncPendingOps() { pending_ops_++; }
179 void DecPendingOps(); 179 void DecPendingOps();
180 void PendingErrorCallback(const ErrorCallback& callback, ErrorType error); 180 void PendingErrorCallback(const ErrorCallback& callback, ErrorType error);
181 void PendingResponseCallback( 181 void PendingResponseCallback(
182 const ResponseCallback& callback, 182 const ResponseCallback& callback,
183 ErrorType error, 183 ErrorType error,
184 scoped_ptr<ServiceWorkerResponse> response, 184 scoped_ptr<ServiceWorkerResponse> response,
185 scoped_ptr<storage::BlobDataHandle> blob_data_handle); 185 scoped_ptr<storage::BlobDataSnapshotHandle> blob_data_handle);
186 void PendingRequestsCallback(const RequestsCallback& callback, 186 void PendingRequestsCallback(const RequestsCallback& callback,
187 ErrorType error, 187 ErrorType error,
188 scoped_ptr<Requests> requests); 188 scoped_ptr<Requests> requests);
189 189
190 // The backend can be deleted via the Close function at any time so always 190 // The backend can be deleted via the Close function at any time so always
191 // check for its existence before use. 191 // check for its existence before use.
192 scoped_ptr<disk_cache::Backend> backend_; 192 scoped_ptr<disk_cache::Backend> backend_;
193 GURL origin_; 193 GURL origin_;
194 base::FilePath path_; 194 base::FilePath path_;
195 net::URLRequestContext* request_context_; 195 net::URLRequestContext* request_context_;
(...skipping 14 matching lines...) Expand all
210 base::Closure ops_complete_callback_; 210 base::Closure ops_complete_callback_;
211 211
212 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; 212 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_;
213 213
214 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); 214 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache);
215 }; 215 };
216 216
217 } // namespace content 217 } // namespace content
218 218
219 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ 219 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698