OLD | NEW |
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 <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // This class provides an interface to store and retrieve ServiceWorker | 46 // This class provides an interface to store and retrieve ServiceWorker |
47 // registration data. | 47 // registration data. |
48 class CONTENT_EXPORT ServiceWorkerStorage | 48 class CONTENT_EXPORT ServiceWorkerStorage |
49 : NON_EXPORTED_BASE(public ServiceWorkerVersion::Listener) { | 49 : NON_EXPORTED_BASE(public ServiceWorkerVersion::Listener) { |
50 public: | 50 public: |
51 typedef std::vector<ServiceWorkerDatabase::ResourceRecord> ResourceList; | 51 typedef std::vector<ServiceWorkerDatabase::ResourceRecord> ResourceList; |
52 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; | 52 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; |
53 typedef base::Callback<void(ServiceWorkerStatusCode status, | 53 typedef base::Callback<void(ServiceWorkerStatusCode status, |
54 const scoped_refptr<ServiceWorkerRegistration>& | 54 const scoped_refptr<ServiceWorkerRegistration>& |
55 registration)> FindRegistrationCallback; | 55 registration)> FindRegistrationCallback; |
56 typedef base::Callback< | 56 typedef base::Callback<void( |
57 void(const std::vector<ServiceWorkerRegistrationInfo>& registrations)> | 57 const std::vector<scoped_refptr<ServiceWorkerRegistration>>& |
58 GetRegistrationsInfosCallback; | 58 registrations)> GetRegistrationsCallback; |
| 59 typedef base::Callback<void(const std::vector<ServiceWorkerRegistrationInfo>& |
| 60 registrations)> GetRegistrationsInfosCallback; |
59 typedef base::Callback< | 61 typedef base::Callback< |
60 void(ServiceWorkerStatusCode status, bool are_equal)> | 62 void(ServiceWorkerStatusCode status, bool are_equal)> |
61 CompareCallback; | 63 CompareCallback; |
62 typedef base::Callback< | 64 typedef base::Callback< |
63 void(const std::string& data, ServiceWorkerStatusCode status)> | 65 void(const std::string& data, ServiceWorkerStatusCode status)> |
64 GetUserDataCallback; | 66 GetUserDataCallback; |
65 typedef base::Callback<void( | 67 typedef base::Callback<void( |
66 const std::vector<std::pair<int64, std::string>>& user_data, | 68 const std::vector<std::pair<int64, std::string>>& user_data, |
67 ServiceWorkerStatusCode status)> | 69 ServiceWorkerStatusCode status)> |
68 GetUserDataForAllRegistrationsCallback; | 70 GetUserDataForAllRegistrationsCallback; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // Generally |FindRegistrationForId| should be used to look up a registration | 104 // Generally |FindRegistrationForId| should be used to look up a registration |
103 // by |registration_id| since it's more efficient. But if a |registration_id| | 105 // by |registration_id| since it's more efficient. But if a |registration_id| |
104 // is all that is available this method can be used instead. | 106 // is all that is available this method can be used instead. |
105 // Like |FindRegistrationForId| this method may complete immediately (the | 107 // Like |FindRegistrationForId| this method may complete immediately (the |
106 // callback may be called prior to the method returning) or asynchronously. | 108 // callback may be called prior to the method returning) or asynchronously. |
107 void FindRegistrationForIdOnly(int64 registration_id, | 109 void FindRegistrationForIdOnly(int64 registration_id, |
108 const FindRegistrationCallback& callback); | 110 const FindRegistrationCallback& callback); |
109 | 111 |
110 ServiceWorkerRegistration* GetUninstallingRegistration(const GURL& scope); | 112 ServiceWorkerRegistration* GetUninstallingRegistration(const GURL& scope); |
111 | 113 |
112 // Returns info about all stored and initially installing registrations for | 114 // Returns all stored registrations for a given origin. |
113 // a given origin. | 115 void GetRegistrationsForOrigin(const GURL& origin, |
114 void GetRegistrationsForOrigin( | 116 const GetRegistrationsCallback& callback); |
115 const GURL& origin, const GetRegistrationsInfosCallback& callback); | |
116 | 117 |
117 // Returns info about all stored and initially installing registrations. | 118 // Returns info about all stored and initially installing registrations. |
118 void GetAllRegistrations(const GetRegistrationsInfosCallback& callback); | 119 void GetAllRegistrationsInfos(const GetRegistrationsInfosCallback& callback); |
119 | 120 |
120 // Commits |registration| with the installed but not activated |version| | 121 // Commits |registration| with the installed but not activated |version| |
121 // to storage, overwritting any pre-existing registration data for the scope. | 122 // to storage, overwritting any pre-existing registration data for the scope. |
122 // A pre-existing version's script resources remain available if that version | 123 // A pre-existing version's script resources remain available if that version |
123 // is live. PurgeResources should be called when it's OK to delete them. | 124 // is live. PurgeResources should be called when it's OK to delete them. |
124 void StoreRegistration(ServiceWorkerRegistration* registration, | 125 void StoreRegistration(ServiceWorkerRegistration* registration, |
125 ServiceWorkerVersion* version, | 126 ServiceWorkerVersion* version, |
126 const StatusCallback& callback); | 127 const StatusCallback& callback); |
127 | 128 |
128 // Updates the state of the registration's stored version to active. | 129 // Updates the state of the registration's stored version to active. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 const GURL& scope, | 313 const GURL& scope, |
313 const FindRegistrationCallback& callback, | 314 const FindRegistrationCallback& callback, |
314 const ServiceWorkerDatabase::RegistrationData& data, | 315 const ServiceWorkerDatabase::RegistrationData& data, |
315 const ResourceList& resources, | 316 const ResourceList& resources, |
316 ServiceWorkerDatabase::Status status); | 317 ServiceWorkerDatabase::Status status); |
317 void DidFindRegistrationForId( | 318 void DidFindRegistrationForId( |
318 const FindRegistrationCallback& callback, | 319 const FindRegistrationCallback& callback, |
319 const ServiceWorkerDatabase::RegistrationData& data, | 320 const ServiceWorkerDatabase::RegistrationData& data, |
320 const ResourceList& resources, | 321 const ResourceList& resources, |
321 ServiceWorkerDatabase::Status status); | 322 ServiceWorkerDatabase::Status status); |
322 void DidGetRegistrations( | 323 void DidGetRegistrations(const GetRegistrationsCallback& callback, |
323 const GetRegistrationsInfosCallback& callback, | 324 RegistrationList* registration_data_list, |
324 RegistrationList* registrations, | 325 std::vector<ResourceList>* resources_list, |
325 const GURL& origin_filter, | 326 const GURL& origin_filter, |
326 ServiceWorkerDatabase::Status status); | 327 ServiceWorkerDatabase::Status status); |
| 328 void DidGetRegistrationsInfos(const GetRegistrationsInfosCallback& callback, |
| 329 RegistrationList* registration_data_list, |
| 330 const GURL& origin_filter, |
| 331 ServiceWorkerDatabase::Status status); |
327 void DidStoreRegistration( | 332 void DidStoreRegistration( |
328 const StatusCallback& callback, | 333 const StatusCallback& callback, |
329 const ServiceWorkerDatabase::RegistrationData& new_version, | 334 const ServiceWorkerDatabase::RegistrationData& new_version, |
330 const GURL& origin, | 335 const GURL& origin, |
331 const ServiceWorkerDatabase::RegistrationData& deleted_version, | 336 const ServiceWorkerDatabase::RegistrationData& deleted_version, |
332 const std::vector<int64>& newly_purgeable_resources, | 337 const std::vector<int64>& newly_purgeable_resources, |
333 ServiceWorkerDatabase::Status status); | 338 ServiceWorkerDatabase::Status status); |
334 void DidUpdateToActiveState( | 339 void DidUpdateToActiveState( |
335 const StatusCallback& callback, | 340 const StatusCallback& callback, |
336 ServiceWorkerDatabase::Status status); | 341 ServiceWorkerDatabase::Status status); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 std::set<int64> pending_deletions_; | 497 std::set<int64> pending_deletions_; |
493 | 498 |
494 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; | 499 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; |
495 | 500 |
496 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 501 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
497 }; | 502 }; |
498 | 503 |
499 } // namespace content | 504 } // namespace content |
500 | 505 |
501 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 506 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
OLD | NEW |