| 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 10 matching lines...) Expand all Loading... |
| 21 #include "content/common/service_worker/service_worker_status_code.h" | 21 #include "content/common/service_worker/service_worker_status_code.h" |
| 22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class SequencedTaskRunner; | 25 class SequencedTaskRunner; |
| 26 class SingleThreadTaskRunner; | 26 class SingleThreadTaskRunner; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace storage { | 29 namespace storage { |
| 30 class QuotaManagerProxy; | 30 class QuotaManagerProxy; |
| 31 class SpecialStoragePolicy; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace content { | 34 namespace content { |
| 34 | 35 |
| 35 class ServiceWorkerContextCore; | 36 class ServiceWorkerContextCore; |
| 36 class ServiceWorkerDiskCache; | 37 class ServiceWorkerDiskCache; |
| 37 class ServiceWorkerRegistration; | 38 class ServiceWorkerRegistration; |
| 38 class ServiceWorkerRegistrationInfo; | 39 class ServiceWorkerRegistrationInfo; |
| 39 class ServiceWorkerResponseReader; | 40 class ServiceWorkerResponseReader; |
| 40 class ServiceWorkerResponseWriter; | 41 class ServiceWorkerResponseWriter; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 56 void(ServiceWorkerStatusCode status, bool are_equal)> | 57 void(ServiceWorkerStatusCode status, bool are_equal)> |
| 57 CompareCallback; | 58 CompareCallback; |
| 58 | 59 |
| 59 virtual ~ServiceWorkerStorage(); | 60 virtual ~ServiceWorkerStorage(); |
| 60 | 61 |
| 61 static scoped_ptr<ServiceWorkerStorage> Create( | 62 static scoped_ptr<ServiceWorkerStorage> Create( |
| 62 const base::FilePath& path, | 63 const base::FilePath& path, |
| 63 base::WeakPtr<ServiceWorkerContextCore> context, | 64 base::WeakPtr<ServiceWorkerContextCore> context, |
| 64 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, | 65 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, |
| 65 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 66 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
| 66 storage::QuotaManagerProxy* quota_manager_proxy); | 67 storage::QuotaManagerProxy* quota_manager_proxy, |
| 68 storage::SpecialStoragePolicy* special_storage_policy); |
| 67 | 69 |
| 68 // Used for DeleteAndStartOver. Creates new storage based on |old_storage|. | 70 // Used for DeleteAndStartOver. Creates new storage based on |old_storage|. |
| 69 static scoped_ptr<ServiceWorkerStorage> Create( | 71 static scoped_ptr<ServiceWorkerStorage> Create( |
| 70 base::WeakPtr<ServiceWorkerContextCore> context, | 72 base::WeakPtr<ServiceWorkerContextCore> context, |
| 71 ServiceWorkerStorage* old_storage); | 73 ServiceWorkerStorage* old_storage); |
| 72 | 74 |
| 73 // Finds registration for |document_url| or |pattern| or |registration_id|. | 75 // Finds registration for |document_url| or |pattern| or |registration_id|. |
| 74 // The Find methods will find stored and initially installing registrations. | 76 // The Find methods will find stored and initially installing registrations. |
| 75 // Returns SERVICE_WORKER_OK with non-null registration if registration | 77 // Returns SERVICE_WORKER_OK with non-null registration if registration |
| 76 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching | 78 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 ServiceWorkerDatabase::Status status)> FindInDBCallback; | 220 ServiceWorkerDatabase::Status status)> FindInDBCallback; |
| 219 typedef base::Callback<void(const std::vector<int64>& resource_ids, | 221 typedef base::Callback<void(const std::vector<int64>& resource_ids, |
| 220 ServiceWorkerDatabase::Status status)> | 222 ServiceWorkerDatabase::Status status)> |
| 221 GetResourcesCallback; | 223 GetResourcesCallback; |
| 222 | 224 |
| 223 ServiceWorkerStorage( | 225 ServiceWorkerStorage( |
| 224 const base::FilePath& path, | 226 const base::FilePath& path, |
| 225 base::WeakPtr<ServiceWorkerContextCore> context, | 227 base::WeakPtr<ServiceWorkerContextCore> context, |
| 226 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, | 228 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, |
| 227 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 229 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
| 228 storage::QuotaManagerProxy* quota_manager_proxy); | 230 storage::QuotaManagerProxy* quota_manager_proxy, |
| 231 storage::SpecialStoragePolicy* special_storage_policy); |
| 229 | 232 |
| 230 base::FilePath GetDatabasePath(); | 233 base::FilePath GetDatabasePath(); |
| 231 base::FilePath GetDiskCachePath(); | 234 base::FilePath GetDiskCachePath(); |
| 232 | 235 |
| 233 bool LazyInitialize( | 236 bool LazyInitialize( |
| 234 const base::Closure& callback); | 237 const base::Closure& callback); |
| 235 void DidReadInitialData( | 238 void DidReadInitialData( |
| 236 InitialData* data, | 239 InitialData* data, |
| 237 ServiceWorkerDatabase::Status status); | 240 ServiceWorkerDatabase::Status status); |
| 238 void DidFindRegistrationForDocument( | 241 void DidFindRegistrationForDocument( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 void PurgeResource(int64 id); | 298 void PurgeResource(int64 id); |
| 296 void OnResourcePurged(int64 id, int rv); | 299 void OnResourcePurged(int64 id, int rv); |
| 297 | 300 |
| 298 // Deletes purgeable and uncommitted resources left over from the previous | 301 // Deletes purgeable and uncommitted resources left over from the previous |
| 299 // browser session. This must be called once per session before any database | 302 // browser session. This must be called once per session before any database |
| 300 // operation that may mutate the purgeable or uncommitted resource lists. | 303 // operation that may mutate the purgeable or uncommitted resource lists. |
| 301 void DeleteStaleResources(); | 304 void DeleteStaleResources(); |
| 302 void DidCollectStaleResources(const std::vector<int64>& stale_resource_ids, | 305 void DidCollectStaleResources(const std::vector<int64>& stale_resource_ids, |
| 303 ServiceWorkerDatabase::Status status); | 306 ServiceWorkerDatabase::Status status); |
| 304 | 307 |
| 308 void ClearSessionOnlyOrigins(); |
| 309 |
| 305 // Static cross-thread helpers. | 310 // Static cross-thread helpers. |
| 306 static void CollectStaleResourcesFromDB( | 311 static void CollectStaleResourcesFromDB( |
| 307 ServiceWorkerDatabase* database, | 312 ServiceWorkerDatabase* database, |
| 308 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 313 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 309 const GetResourcesCallback& callback); | 314 const GetResourcesCallback& callback); |
| 310 static void ReadInitialDataFromDB( | 315 static void ReadInitialDataFromDB( |
| 311 ServiceWorkerDatabase* database, | 316 ServiceWorkerDatabase* database, |
| 312 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 317 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 313 const InitializeCallback& callback); | 318 const InitializeCallback& callback); |
| 314 static void DeleteRegistrationFromDB( | 319 static void DeleteRegistrationFromDB( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 332 ServiceWorkerDatabase* database, | 337 ServiceWorkerDatabase* database, |
| 333 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 338 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 334 const GURL& scope, | 339 const GURL& scope, |
| 335 const FindInDBCallback& callback); | 340 const FindInDBCallback& callback); |
| 336 static void FindForIdInDB( | 341 static void FindForIdInDB( |
| 337 ServiceWorkerDatabase* database, | 342 ServiceWorkerDatabase* database, |
| 338 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 343 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 339 int64 registration_id, | 344 int64 registration_id, |
| 340 const GURL& origin, | 345 const GURL& origin, |
| 341 const FindInDBCallback& callback); | 346 const FindInDBCallback& callback); |
| 347 static void DeleteAllDataForOriginsFromDB( |
| 348 ServiceWorkerDatabase* database, |
| 349 const std::set<GURL>& origins); |
| 342 | 350 |
| 343 void ScheduleDeleteAndStartOver(); | 351 void ScheduleDeleteAndStartOver(); |
| 344 void DidDeleteDatabase( | 352 void DidDeleteDatabase( |
| 345 const StatusCallback& callback, | 353 const StatusCallback& callback, |
| 346 ServiceWorkerDatabase::Status status); | 354 ServiceWorkerDatabase::Status status); |
| 347 void DidDeleteDiskCache( | 355 void DidDeleteDiskCache( |
| 348 const StatusCallback& callback, | 356 const StatusCallback& callback, |
| 349 bool result); | 357 bool result); |
| 350 | 358 |
| 351 // For finding registrations being installed or uninstalled. | 359 // For finding registrations being installed or uninstalled. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 372 | 380 |
| 373 base::FilePath path_; | 381 base::FilePath path_; |
| 374 base::WeakPtr<ServiceWorkerContextCore> context_; | 382 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 375 | 383 |
| 376 // Only accessed on |database_task_runner_|. | 384 // Only accessed on |database_task_runner_|. |
| 377 scoped_ptr<ServiceWorkerDatabase> database_; | 385 scoped_ptr<ServiceWorkerDatabase> database_; |
| 378 | 386 |
| 379 scoped_refptr<base::SequencedTaskRunner> database_task_runner_; | 387 scoped_refptr<base::SequencedTaskRunner> database_task_runner_; |
| 380 scoped_refptr<base::SingleThreadTaskRunner> disk_cache_thread_; | 388 scoped_refptr<base::SingleThreadTaskRunner> disk_cache_thread_; |
| 381 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; | 389 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; |
| 390 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; |
| 382 scoped_ptr<ServiceWorkerDiskCache> disk_cache_; | 391 scoped_ptr<ServiceWorkerDiskCache> disk_cache_; |
| 383 std::deque<int64> purgeable_resource_ids_; | 392 std::deque<int64> purgeable_resource_ids_; |
| 384 bool is_purge_pending_; | 393 bool is_purge_pending_; |
| 385 bool has_checked_for_stale_resources_; | 394 bool has_checked_for_stale_resources_; |
| 386 std::set<int64> pending_deletions_; | 395 std::set<int64> pending_deletions_; |
| 387 | 396 |
| 388 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; | 397 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; |
| 389 | 398 |
| 390 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 399 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
| 391 }; | 400 }; |
| 392 | 401 |
| 393 } // namespace content | 402 } // namespace content |
| 394 | 403 |
| 395 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 404 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
| OLD | NEW |