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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // (the callback may be called prior to the method returning) or | 80 // (the callback may be called prior to the method returning) or |
81 // asynchronously. | 81 // asynchronously. |
82 void FindRegistrationForDocument(const GURL& document_url, | 82 void FindRegistrationForDocument(const GURL& document_url, |
83 const FindRegistrationCallback& callback); | 83 const FindRegistrationCallback& callback); |
84 void FindRegistrationForPattern(const GURL& scope, | 84 void FindRegistrationForPattern(const GURL& scope, |
85 const FindRegistrationCallback& callback); | 85 const FindRegistrationCallback& callback); |
86 void FindRegistrationForId(int64 registration_id, | 86 void FindRegistrationForId(int64 registration_id, |
87 const GURL& origin, | 87 const GURL& origin, |
88 const FindRegistrationCallback& callback); | 88 const FindRegistrationCallback& callback); |
89 | 89 |
| 90 ServiceWorkerRegistration* GetUninstallingRegistration(const GURL& scope); |
| 91 |
90 // Returns info about all stored and initially installing registrations. | 92 // Returns info about all stored and initially installing registrations. |
91 void GetAllRegistrations(const GetAllRegistrationInfosCallback& callback); | 93 void GetAllRegistrations(const GetAllRegistrationInfosCallback& callback); |
92 | 94 |
93 // Commits |registration| with the installed but not activated |version| | 95 // Commits |registration| with the installed but not activated |version| |
94 // to storage, overwritting any pre-existing registration data for the scope. | 96 // to storage, overwritting any pre-existing registration data for the scope. |
95 // A pre-existing version's script resources remain available if that version | 97 // A pre-existing version's script resources remain available if that version |
96 // is live. PurgeResources should be called when it's OK to delete them. | 98 // is live. PurgeResources should be called when it's OK to delete them. |
97 void StoreRegistration( | 99 void StoreRegistration( |
98 ServiceWorkerRegistration* registration, | 100 ServiceWorkerRegistration* registration, |
99 ServiceWorkerVersion* version, | 101 ServiceWorkerVersion* version, |
(...skipping 29 matching lines...) Expand all Loading... |
129 const CompareCallback& callback); | 131 const CompareCallback& callback); |
130 | 132 |
131 // Deletes the storage and starts over. | 133 // Deletes the storage and starts over. |
132 void DeleteAndStartOver(const StatusCallback& callback); | 134 void DeleteAndStartOver(const StatusCallback& callback); |
133 | 135 |
134 // Returns new IDs which are guaranteed to be unique in the storage. | 136 // Returns new IDs which are guaranteed to be unique in the storage. |
135 int64 NewRegistrationId(); | 137 int64 NewRegistrationId(); |
136 int64 NewVersionId(); | 138 int64 NewVersionId(); |
137 int64 NewResourceId(); | 139 int64 NewResourceId(); |
138 | 140 |
139 // Intended for use only by ServiceWorkerRegisterJob. | 141 // Intended for use only by ServiceWorkerRegisterJob and |
| 142 // ServiceWorkerRegistration. |
140 void NotifyInstallingRegistration( | 143 void NotifyInstallingRegistration( |
141 ServiceWorkerRegistration* registration); | 144 ServiceWorkerRegistration* registration); |
142 void NotifyDoneInstallingRegistration( | 145 void NotifyDoneInstallingRegistration( |
143 ServiceWorkerRegistration* registration, | 146 ServiceWorkerRegistration* registration, |
144 ServiceWorkerVersion* version, | 147 ServiceWorkerVersion* version, |
145 ServiceWorkerStatusCode status); | 148 ServiceWorkerStatusCode status); |
| 149 void NotifyUninstallingRegistration(ServiceWorkerRegistration* registration); |
| 150 void NotifyDoneUninstallingRegistration( |
| 151 ServiceWorkerRegistration* registration); |
146 | 152 |
147 void Disable(); | 153 void Disable(); |
148 bool IsDisabled() const; | 154 bool IsDisabled() const; |
149 | 155 |
150 // |resources| must already be on the purgeable list. | 156 // |resources| must already be on the purgeable list. |
151 void PurgeResources(const ResourceList& resources); | 157 void PurgeResources(const ResourceList& resources); |
152 | 158 |
153 private: | 159 private: |
154 friend class ServiceWorkerResourceStorageTest; | 160 friend class ServiceWorkerResourceStorageTest; |
155 friend class ServiceWorkerControlleeRequestHandlerTest; | 161 friend class ServiceWorkerControlleeRequestHandlerTest; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 const FindInDBCallback& callback); | 334 const FindInDBCallback& callback); |
329 | 335 |
330 void ScheduleDeleteAndStartOver(); | 336 void ScheduleDeleteAndStartOver(); |
331 void DidDeleteDatabase( | 337 void DidDeleteDatabase( |
332 const StatusCallback& callback, | 338 const StatusCallback& callback, |
333 ServiceWorkerDatabase::Status status); | 339 ServiceWorkerDatabase::Status status); |
334 void DidDeleteDiskCache( | 340 void DidDeleteDiskCache( |
335 const StatusCallback& callback, | 341 const StatusCallback& callback, |
336 bool result); | 342 bool result); |
337 | 343 |
338 // For finding registrations being installed. | 344 // For finding registrations being installed or uninstalled. |
339 RegistrationRefsById installing_registrations_; | 345 RegistrationRefsById installing_registrations_; |
| 346 RegistrationRefsById uninstalling_registrations_; |
340 | 347 |
341 // Origins having registations. | 348 // Origins having registations. |
342 std::set<GURL> registered_origins_; | 349 std::set<GURL> registered_origins_; |
343 | 350 |
344 // Pending database tasks waiting for initialization. | 351 // Pending database tasks waiting for initialization. |
345 std::vector<base::Closure> pending_tasks_; | 352 std::vector<base::Closure> pending_tasks_; |
346 | 353 |
347 int64 next_registration_id_; | 354 int64 next_registration_id_; |
348 int64 next_version_id_; | 355 int64 next_version_id_; |
349 int64 next_resource_id_; | 356 int64 next_resource_id_; |
(...skipping 22 matching lines...) Expand all Loading... |
372 std::set<int64> pending_deletions_; | 379 std::set<int64> pending_deletions_; |
373 | 380 |
374 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; | 381 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; |
375 | 382 |
376 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 383 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
377 }; | 384 }; |
378 | 385 |
379 } // namespace content | 386 } // namespace content |
380 | 387 |
381 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 388 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
OLD | NEW |