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

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

Issue 985053002: [ServiceWorkerCache] Cache and CacheStorage creation UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also monitor cache storage creation Created 5 years, 9 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 <list> 8 #include <list>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 22 matching lines...) Expand all
33 class ServiceWorkerCacheScheduler; 33 class ServiceWorkerCacheScheduler;
34 class TestServiceWorkerCache; 34 class TestServiceWorkerCache;
35 35
36 // Represents a ServiceWorker Cache as seen in 36 // Represents a ServiceWorker Cache as seen in
37 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 37 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
38 // The asynchronous methods are executed serially. Callbacks to the 38 // The asynchronous methods are executed serially. Callbacks to the
39 // public functions will be called so long as the cache object lives. 39 // public functions will be called so long as the cache object lives.
40 class CONTENT_EXPORT ServiceWorkerCache 40 class CONTENT_EXPORT ServiceWorkerCache
41 : public base::RefCounted<ServiceWorkerCache> { 41 : public base::RefCounted<ServiceWorkerCache> {
42 public: 42 public:
43 // This enum is used in histograms, so do not change the ordering and always
44 // append new types to the end.
43 enum ErrorType { 45 enum ErrorType {
44 ErrorTypeOK = 0, 46 ERROR_TYPE_OK = 0,
45 ErrorTypeExists, 47 ERROR_TYPE_EXISTS,
46 ErrorTypeStorage, 48 ERROR_TYPE_STORAGE,
47 ErrorTypeNotFound 49 ERROR_TYPE_NOT_FOUND,
50 ERROR_TYPE_LAST = ERROR_TYPE_NOT_FOUND
48 }; 51 };
49 52
50 enum EntryIndex { INDEX_HEADERS = 0, INDEX_RESPONSE_BODY }; 53 enum EntryIndex { INDEX_HEADERS = 0, INDEX_RESPONSE_BODY };
51 typedef base::Callback<void(ErrorType)> ErrorCallback; 54 typedef base::Callback<void(ErrorType)> ErrorCallback;
52 typedef base::Callback<void(ErrorType, 55 typedef base::Callback<void(ErrorType,
53 scoped_ptr<ServiceWorkerResponse>, 56 scoped_ptr<ServiceWorkerResponse>,
54 scoped_ptr<storage::BlobDataHandle>)> 57 scoped_ptr<storage::BlobDataHandle>)>
55 ResponseCallback; 58 ResponseCallback;
56 typedef std::vector<ServiceWorkerFetchRequest> Requests; 59 typedef std::vector<ServiceWorkerFetchRequest> Requests;
57 typedef base::Callback<void(ErrorType, scoped_ptr<Requests>)> 60 typedef base::Callback<void(ErrorType, scoped_ptr<Requests>)>
58 RequestsCallback; 61 RequestsCallback;
59 62
60 static scoped_refptr<ServiceWorkerCache> CreateMemoryCache( 63 static scoped_refptr<ServiceWorkerCache> CreateMemoryCache(
61 const GURL& origin, 64 const GURL& origin,
62 net::URLRequestContext* request_context, 65 net::URLRequestContext* request_context,
63 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, 66 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy,
64 base::WeakPtr<storage::BlobStorageContext> blob_context); 67 base::WeakPtr<storage::BlobStorageContext> blob_context);
65 static scoped_refptr<ServiceWorkerCache> CreatePersistentCache( 68 static scoped_refptr<ServiceWorkerCache> CreatePersistentCache(
66 const GURL& origin, 69 const GURL& origin,
67 const base::FilePath& path, 70 const base::FilePath& path,
68 net::URLRequestContext* request_context, 71 net::URLRequestContext* request_context,
69 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, 72 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy,
70 base::WeakPtr<storage::BlobStorageContext> blob_context); 73 base::WeakPtr<storage::BlobStorageContext> blob_context);
71 74
72 // Returns ErrorTypeNotFound if not found. 75 // Returns ERROR_TYPE_NOT_FOUND if not found.
73 void Match(scoped_ptr<ServiceWorkerFetchRequest> request, 76 void Match(scoped_ptr<ServiceWorkerFetchRequest> request,
74 const ResponseCallback& callback); 77 const ResponseCallback& callback);
75 78
76 // Puts the request and response object in the cache. The response body (if 79 // Puts the request and response object in the cache. The response body (if
77 // present) is stored in the cache, but not the request body. Returns 80 // present) is stored in the cache, but not the request body. Returns
78 // ErrorTypeOK on success. 81 // ERROR_TYPE_OK on success.
79 void Put(scoped_ptr<ServiceWorkerFetchRequest> request, 82 void Put(scoped_ptr<ServiceWorkerFetchRequest> request,
80 scoped_ptr<ServiceWorkerResponse> response, 83 scoped_ptr<ServiceWorkerResponse> response,
81 const ResponseCallback& callback); 84 const ResponseCallback& callback);
82 85
83 // Returns ErrorNotFound if not found. Otherwise deletes and returns 86 // Returns ErrorNotFound if not found. Otherwise deletes and returns
84 // ErrorTypeOK. 87 // ERROR_TYPE_OK.
85 void Delete(scoped_ptr<ServiceWorkerFetchRequest> request, 88 void Delete(scoped_ptr<ServiceWorkerFetchRequest> request,
86 const ErrorCallback& callback); 89 const ErrorCallback& callback);
87 90
88 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. 91 // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest.
89 // Returns ErrorTypeOK and a vector of requests if there are no errors. 92 // Returns ErrorTypeOK and a vector of requests if there are no errors.
90 void Keys(const RequestsCallback& callback); 93 void Keys(const RequestsCallback& callback);
91 94
92 // Closes the backend. Future operations that require the backend 95 // Closes the backend. Future operations that require the backend
93 // will exit early. Close should only be called once per ServiceWorkerCache. 96 // will exit early. Close should only be called once per ServiceWorkerCache.
94 void Close(const base::Closure& callback); 97 void Close(const base::Closure& callback);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 bool memory_only_; 213 bool memory_only_;
211 214
212 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; 215 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_;
213 216
214 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); 217 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache);
215 }; 218 };
216 219
217 } // namespace content 220 } // namespace content
218 221
219 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ 222 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698