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

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

Issue 672813002: [ServiceWorker] Added size deltas and total size computation for QuotaM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_STORAGE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
7 7
8 #include <algorithm>
8 #include <deque> 9 #include <deque>
9 #include <map> 10 #include <map>
10 #include <set> 11 #include <set>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/bind.h" 14 #include "base/bind.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
17 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; 51 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback;
51 typedef base::Callback<void(ServiceWorkerStatusCode status, 52 typedef base::Callback<void(ServiceWorkerStatusCode status,
52 const scoped_refptr<ServiceWorkerRegistration>& 53 const scoped_refptr<ServiceWorkerRegistration>&
53 registration)> FindRegistrationCallback; 54 registration)> FindRegistrationCallback;
54 typedef base::Callback< 55 typedef base::Callback<
55 void(const std::vector<ServiceWorkerRegistrationInfo>& registrations)> 56 void(const std::vector<ServiceWorkerRegistrationInfo>& registrations)>
56 GetAllRegistrationInfosCallback; 57 GetAllRegistrationInfosCallback;
57 typedef base::Callback< 58 typedef base::Callback<
58 void(ServiceWorkerStatusCode status, bool are_equal)> 59 void(ServiceWorkerStatusCode status, bool are_equal)>
59 CompareCallback; 60 CompareCallback;
61 typedef base::Callback<void(const std::map<GURL, int64>& origin_usage)>
62 OriginUsageCallback;
60 63
61 ~ServiceWorkerStorage() override; 64 ~ServiceWorkerStorage() override;
62 65
63 static scoped_ptr<ServiceWorkerStorage> Create( 66 static scoped_ptr<ServiceWorkerStorage> Create(
64 const base::FilePath& path, 67 const base::FilePath& path,
65 base::WeakPtr<ServiceWorkerContextCore> context, 68 base::WeakPtr<ServiceWorkerContextCore> context,
66 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, 69 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager,
67 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, 70 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread,
68 storage::QuotaManagerProxy* quota_manager_proxy, 71 storage::QuotaManagerProxy* quota_manager_proxy,
69 storage::SpecialStoragePolicy* special_storage_policy); 72 storage::SpecialStoragePolicy* special_storage_policy);
(...skipping 18 matching lines...) Expand all
88 const FindRegistrationCallback& callback); 91 const FindRegistrationCallback& callback);
89 void FindRegistrationForId(int64 registration_id, 92 void FindRegistrationForId(int64 registration_id,
90 const GURL& origin, 93 const GURL& origin,
91 const FindRegistrationCallback& callback); 94 const FindRegistrationCallback& callback);
92 95
93 ServiceWorkerRegistration* GetUninstallingRegistration(const GURL& scope); 96 ServiceWorkerRegistration* GetUninstallingRegistration(const GURL& scope);
94 97
95 // Returns info about all stored and initially installing registrations. 98 // Returns info about all stored and initially installing registrations.
96 void GetAllRegistrations(const GetAllRegistrationInfosCallback& callback); 99 void GetAllRegistrations(const GetAllRegistrationInfosCallback& callback);
97 100
101 void GetAllUsageByOrigin(const OriginUsageCallback& callback);
102
98 // Commits |registration| with the installed but not activated |version| 103 // Commits |registration| with the installed but not activated |version|
99 // to storage, overwritting any pre-existing registration data for the scope. 104 // to storage, overwritting any pre-existing registration data for the
100 // A pre-existing version's script resources remain available if that version 105 // scope.
106 // A pre-existing version's script resources remain available if that
107 // version
101 // is live. PurgeResources should be called when it's OK to delete them. 108 // is live. PurgeResources should be called when it's OK to delete them.
michaeln 2014/10/24 23:15:47 how the comment is wrapped is on with one word lin
dmurph 2014/10/27 21:37:06 Done.
102 void StoreRegistration( 109 void StoreRegistration(ServiceWorkerRegistration* registration,
103 ServiceWorkerRegistration* registration, 110 ServiceWorkerVersion* version,
104 ServiceWorkerVersion* version, 111 const StatusCallback& callback);
105 const StatusCallback& callback);
106 112
107 // Updates the state of the registration's stored version to active. 113 // Updates the state of the registration's stored version to active.
108 void UpdateToActiveState( 114 void UpdateToActiveState(
109 ServiceWorkerRegistration* registration, 115 ServiceWorkerRegistration* registration,
110 const StatusCallback& callback); 116 const StatusCallback& callback);
111 117
112 // Updates the stored time to match the value of 118 // Updates the stored time to match the value of
113 // registration->last_update_check(). 119 // registration->last_update_check().
114 void UpdateLastUpdateCheckTime(ServiceWorkerRegistration* registration); 120 void UpdateLastUpdateCheckTime(ServiceWorkerRegistration* registration);
115 121
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 DidDeleteRegistrationParams(); 206 DidDeleteRegistrationParams();
201 ~DidDeleteRegistrationParams(); 207 ~DidDeleteRegistrationParams();
202 }; 208 };
203 209
204 typedef std::vector<ServiceWorkerDatabase::RegistrationData> RegistrationList; 210 typedef std::vector<ServiceWorkerDatabase::RegistrationData> RegistrationList;
205 typedef std::map<int64, scoped_refptr<ServiceWorkerRegistration> > 211 typedef std::map<int64, scoped_refptr<ServiceWorkerRegistration> >
206 RegistrationRefsById; 212 RegistrationRefsById;
207 typedef base::Callback<void( 213 typedef base::Callback<void(
208 InitialData* data, 214 InitialData* data,
209 ServiceWorkerDatabase::Status status)> InitializeCallback; 215 ServiceWorkerDatabase::Status status)> InitializeCallback;
210 typedef base::Callback< 216 typedef base::Callback<void(
211 void(const GURL& origin, 217 const GURL& origin,
212 int64 deleted_version_id, 218 const ServiceWorkerDatabase::RegistrationData& deleted_version_data,
213 const std::vector<int64>& newly_purgeable_resources, 219 const std::vector<int64>& newly_purgeable_resources,
214 ServiceWorkerDatabase::Status status)> WriteRegistrationCallback; 220 ServiceWorkerDatabase::Status status)> WriteRegistrationCallback;
215 typedef base::Callback< 221 typedef base::Callback<
216 void(bool origin_is_deletable, 222 void(bool origin_is_deletable,
217 int64 version_id, 223 int64 version_id,
218 const std::vector<int64>& newly_purgeable_resources, 224 const std::vector<int64>& newly_purgeable_resources,
219 ServiceWorkerDatabase::Status status)> DeleteRegistrationCallback; 225 ServiceWorkerDatabase::Status status)> DeleteRegistrationCallback;
220 typedef base::Callback<void( 226 typedef base::Callback<void(
221 const ServiceWorkerDatabase::RegistrationData& data, 227 const ServiceWorkerDatabase::RegistrationData& data,
222 const ResourceList& resources, 228 const ResourceList& resources,
223 ServiceWorkerDatabase::Status status)> FindInDBCallback; 229 ServiceWorkerDatabase::Status status)> FindInDBCallback;
224 typedef base::Callback<void(const std::vector<int64>& resource_ids, 230 typedef base::Callback<void(const std::vector<int64>& resource_ids,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 ServiceWorkerDatabase::Status status); 262 ServiceWorkerDatabase::Status status);
257 void DidFindRegistrationForId( 263 void DidFindRegistrationForId(
258 const FindRegistrationCallback& callback, 264 const FindRegistrationCallback& callback,
259 const ServiceWorkerDatabase::RegistrationData& data, 265 const ServiceWorkerDatabase::RegistrationData& data,
260 const ResourceList& resources, 266 const ResourceList& resources,
261 ServiceWorkerDatabase::Status status); 267 ServiceWorkerDatabase::Status status);
262 void DidGetAllRegistrations( 268 void DidGetAllRegistrations(
263 const GetAllRegistrationInfosCallback& callback, 269 const GetAllRegistrationInfosCallback& callback,
264 RegistrationList* registrations, 270 RegistrationList* registrations,
265 ServiceWorkerDatabase::Status status); 271 ServiceWorkerDatabase::Status status);
266 void DidStoreRegistration(const StatusCallback& callback, 272 void DidGetRegistrationsForUsage(const OriginUsageCallback& callback,
267 const GURL& origin, 273 RegistrationList* registrations,
268 int64 deleted_version_id, 274 ServiceWorkerDatabase::Status status);
269 const std::vector<int64>& newly_purgeable_resources, 275 void DidStoreRegistration(
270 ServiceWorkerDatabase::Status status); 276 const StatusCallback& callback,
277 const ServiceWorkerDatabase::RegistrationData& new_version,
278 const GURL& origin,
279 const ServiceWorkerDatabase::RegistrationData& deleted_version,
280 const std::vector<int64>& newly_purgeable_resources,
281 ServiceWorkerDatabase::Status status);
271 void DidUpdateToActiveState( 282 void DidUpdateToActiveState(
272 const StatusCallback& callback, 283 const StatusCallback& callback,
273 ServiceWorkerDatabase::Status status); 284 ServiceWorkerDatabase::Status status);
274 void DidDeleteRegistration( 285 void DidDeleteRegistration(
275 const DidDeleteRegistrationParams& params, 286 const DidDeleteRegistrationParams& params,
276 bool origin_is_deletable, 287 bool origin_is_deletable,
277 int64 version_id, 288 int64 version_id,
278 const std::vector<int64>& newly_purgeable_resources, 289 const std::vector<int64>& newly_purgeable_resources,
279 ServiceWorkerDatabase::Status status); 290 ServiceWorkerDatabase::Status status);
280 void ReturnFoundRegistration( 291 void ReturnFoundRegistration(
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 std::set<int64> pending_deletions_; 410 std::set<int64> pending_deletions_;
400 411
401 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; 412 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_;
402 413
403 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); 414 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage);
404 }; 415 };
405 416
406 } // namespace content 417 } // namespace content
407 418
408 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ 419 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698