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