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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 const GURL& origin, | 141 const GURL& origin, |
142 const StatusCallback& callback); | 142 const StatusCallback& callback); |
143 | 143 |
144 scoped_ptr<ServiceWorkerResponseReader> CreateResponseReader( | 144 scoped_ptr<ServiceWorkerResponseReader> CreateResponseReader( |
145 int64 response_id); | 145 int64 response_id); |
146 scoped_ptr<ServiceWorkerResponseWriter> CreateResponseWriter( | 146 scoped_ptr<ServiceWorkerResponseWriter> CreateResponseWriter( |
147 int64 response_id); | 147 int64 response_id); |
148 scoped_ptr<ServiceWorkerResponseMetadataWriter> CreateResponseMetadataWriter( | 148 scoped_ptr<ServiceWorkerResponseMetadataWriter> CreateResponseMetadataWriter( |
149 int64 response_id); | 149 int64 response_id); |
150 | 150 |
151 // Adds |id| to the set of resources ids that are in the disk | 151 // Adds |resource_id| to the set of resources that are in the disk cache |
152 // cache but not yet stored with a registration. | 152 // but not yet stored with a registration. |
153 void StoreUncommittedResponseId(int64 id); | 153 void StoreUncommittedResourceId(int64 resource_id); |
154 | 154 |
155 // Removes |id| from uncommitted list, adds it to the | 155 // Removes resource ids from uncommitted list, adds them to the purgeable list |
156 // purgeable list and purges it. | 156 // and purges them. |
157 void DoomUncommittedResponse(int64 id); | 157 void DoomUncommittedResource(int64 resource_id); |
| 158 void DoomUncommittedResources(const std::set<int64>& resource_ids); |
158 | 159 |
159 // Provide a storage mechanism to read/write arbitrary data associated with | 160 // Provide a storage mechanism to read/write arbitrary data associated with |
160 // a registration. Each registration has its own key namespace. Stored data | 161 // a registration. Each registration has its own key namespace. Stored data |
161 // is deleted when the associated registraton is deleted. | 162 // is deleted when the associated registraton is deleted. |
162 void GetUserData(int64 registration_id, | 163 void GetUserData(int64 registration_id, |
163 const std::string& key, | 164 const std::string& key, |
164 const GetUserDataCallback& callback); | 165 const GetUserDataCallback& callback); |
165 void StoreUserData(int64 registration_id, | 166 void StoreUserData(int64 registration_id, |
166 const GURL& origin, | 167 const GURL& origin, |
167 const std::string& key, | 168 const std::string& key, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 ServiceWorkerDatabase::Status status); | 354 ServiceWorkerDatabase::Status status); |
354 void DidUpdateToActiveState( | 355 void DidUpdateToActiveState( |
355 const StatusCallback& callback, | 356 const StatusCallback& callback, |
356 ServiceWorkerDatabase::Status status); | 357 ServiceWorkerDatabase::Status status); |
357 void DidDeleteRegistration( | 358 void DidDeleteRegistration( |
358 const DidDeleteRegistrationParams& params, | 359 const DidDeleteRegistrationParams& params, |
359 bool origin_is_deletable, | 360 bool origin_is_deletable, |
360 const ServiceWorkerDatabase::RegistrationData& deleted_version, | 361 const ServiceWorkerDatabase::RegistrationData& deleted_version, |
361 const std::vector<int64>& newly_purgeable_resources, | 362 const std::vector<int64>& newly_purgeable_resources, |
362 ServiceWorkerDatabase::Status status); | 363 ServiceWorkerDatabase::Status status); |
| 364 void DidWriteUncommittedResourceIds(ServiceWorkerDatabase::Status status); |
| 365 void DidPurgeUncommittedResourceIds(const std::set<int64>& resource_ids, |
| 366 ServiceWorkerDatabase::Status status); |
363 void DidStoreUserData( | 367 void DidStoreUserData( |
364 const StatusCallback& callback, | 368 const StatusCallback& callback, |
365 ServiceWorkerDatabase::Status status); | 369 ServiceWorkerDatabase::Status status); |
366 void DidGetUserData( | 370 void DidGetUserData( |
367 const GetUserDataCallback& callback, | 371 const GetUserDataCallback& callback, |
368 const std::string& data, | 372 const std::string& data, |
369 ServiceWorkerDatabase::Status status); | 373 ServiceWorkerDatabase::Status status); |
370 void DidDeleteUserData( | 374 void DidDeleteUserData( |
371 const StatusCallback& callback, | 375 const StatusCallback& callback, |
372 ServiceWorkerDatabase::Status status); | 376 ServiceWorkerDatabase::Status status); |
(...skipping 21 matching lines...) Expand all Loading... |
394 void MigrateDiskCache(); | 398 void MigrateDiskCache(); |
395 void DidMigrateDiskCache(ServiceWorkerStatusCode status); | 399 void DidMigrateDiskCache(ServiceWorkerStatusCode status); |
396 void DidSetDiskCacheMigrationNotNeeded(ServiceWorkerDatabase::Status status); | 400 void DidSetDiskCacheMigrationNotNeeded(ServiceWorkerDatabase::Status status); |
397 void OnDiskCacheMigrationFailed( | 401 void OnDiskCacheMigrationFailed( |
398 ServiceWorkerMetrics::DiskCacheMigrationResult result); | 402 ServiceWorkerMetrics::DiskCacheMigrationResult result); |
399 void InitializeDiskCache(); | 403 void InitializeDiskCache(); |
400 void OnDiskCacheInitialized(int rv); | 404 void OnDiskCacheInitialized(int rv); |
401 | 405 |
402 void DeleteOldDiskCache(); | 406 void DeleteOldDiskCache(); |
403 | 407 |
404 void StartPurgingResources(const std::vector<int64>& ids); | 408 void StartPurgingResources(const std::set<int64>& resource_ids); |
| 409 void StartPurgingResources(const std::vector<int64>& resource_ids); |
405 void StartPurgingResources(const ResourceList& resources); | 410 void StartPurgingResources(const ResourceList& resources); |
406 void ContinuePurgingResources(); | 411 void ContinuePurgingResources(); |
407 void PurgeResource(int64 id); | 412 void PurgeResource(int64 id); |
408 void OnResourcePurged(int64 id, int rv); | 413 void OnResourcePurged(int64 id, int rv); |
409 | 414 |
410 // Deletes purgeable and uncommitted resources left over from the previous | 415 // Deletes purgeable and uncommitted resources left over from the previous |
411 // browser session. This must be called once per session before any database | 416 // browser session. This must be called once per session before any database |
412 // operation that may mutate the purgeable or uncommitted resource lists. | 417 // operation that may mutate the purgeable or uncommitted resource lists. |
413 void DeleteStaleResources(); | 418 void DeleteStaleResources(); |
414 void DidCollectStaleResources(const std::vector<int64>& stale_resource_ids, | 419 void DidCollectStaleResources(const std::vector<int64>& stale_resource_ids, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 std::set<int64> pending_deletions_; | 534 std::set<int64> pending_deletions_; |
530 | 535 |
531 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; | 536 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; |
532 | 537 |
533 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 538 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
534 }; | 539 }; |
535 | 540 |
536 } // namespace content | 541 } // namespace content |
537 | 542 |
538 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 543 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
OLD | NEW |