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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "content/browser/service_worker/service_worker_database.h" | 19 #include "content/browser/service_worker/service_worker_database.h" |
| 20 #include "content/browser/service_worker/service_worker_database_task_manager.h" | 20 #include "content/browser/service_worker/service_worker_database_task_manager.h" |
| 21 #include "content/browser/service_worker/service_worker_metrics.h" | |
| 21 #include "content/browser/service_worker/service_worker_version.h" | 22 #include "content/browser/service_worker/service_worker_version.h" |
| 22 #include "content/common/content_export.h" | 23 #include "content/common/content_export.h" |
| 23 #include "content/common/service_worker/service_worker_status_code.h" | 24 #include "content/common/service_worker/service_worker_status_code.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 25 | 26 |
| 26 namespace base { | 27 namespace base { |
| 27 class SequencedTaskRunner; | 28 class SequencedTaskRunner; |
| 28 class SingleThreadTaskRunner; | 29 class SingleThreadTaskRunner; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace storage { | 32 namespace storage { |
| 32 class QuotaManagerProxy; | 33 class QuotaManagerProxy; |
| 33 class SpecialStoragePolicy; | 34 class SpecialStoragePolicy; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace content { | 37 namespace content { |
| 37 | 38 |
| 38 class ServiceWorkerContextCore; | 39 class ServiceWorkerContextCore; |
| 39 class ServiceWorkerDiskCache; | 40 class ServiceWorkerDiskCache; |
| 41 class ServiceWorkerDiskCacheMigrator; | |
| 40 class ServiceWorkerRegistration; | 42 class ServiceWorkerRegistration; |
| 41 class ServiceWorkerResponseMetadataWriter; | 43 class ServiceWorkerResponseMetadataWriter; |
| 42 class ServiceWorkerResponseReader; | 44 class ServiceWorkerResponseReader; |
| 43 class ServiceWorkerResponseWriter; | 45 class ServiceWorkerResponseWriter; |
| 44 struct ServiceWorkerRegistrationInfo; | 46 struct ServiceWorkerRegistrationInfo; |
| 45 | 47 |
| 46 // This class provides an interface to store and retrieve ServiceWorker | 48 // This class provides an interface to store and retrieve ServiceWorker |
| 47 // registration data. | 49 // registration data. |
| 48 class CONTENT_EXPORT ServiceWorkerStorage | 50 class CONTENT_EXPORT ServiceWorkerStorage |
| 49 : NON_EXPORTED_BASE(public ServiceWorkerVersion::Listener) { | 51 : NON_EXPORTED_BASE(public ServiceWorkerVersion::Listener) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 207 |
| 206 // |resources| must already be on the purgeable list. | 208 // |resources| must already be on the purgeable list. |
| 207 void PurgeResources(const ResourceList& resources); | 209 void PurgeResources(const ResourceList& resources); |
| 208 | 210 |
| 209 private: | 211 private: |
| 210 friend class ServiceWorkerHandleTest; | 212 friend class ServiceWorkerHandleTest; |
| 211 friend class ServiceWorkerStorageTest; | 213 friend class ServiceWorkerStorageTest; |
| 212 friend class ServiceWorkerResourceStorageTest; | 214 friend class ServiceWorkerResourceStorageTest; |
| 213 friend class ServiceWorkerControlleeRequestHandlerTest; | 215 friend class ServiceWorkerControlleeRequestHandlerTest; |
| 214 friend class ServiceWorkerContextRequestHandlerTest; | 216 friend class ServiceWorkerContextRequestHandlerTest; |
| 217 friend class ServiceWorkerDiskCacheMigratorTest; | |
| 215 friend class ServiceWorkerRequestHandlerTest; | 218 friend class ServiceWorkerRequestHandlerTest; |
| 216 friend class ServiceWorkerURLRequestJobTest; | 219 friend class ServiceWorkerURLRequestJobTest; |
| 217 friend class ServiceWorkerVersionBrowserTest; | 220 friend class ServiceWorkerVersionBrowserTest; |
| 218 friend class ServiceWorkerVersionTest; | 221 friend class ServiceWorkerVersionTest; |
| 219 friend class ServiceWorkerWriteToCacheJobTest; | 222 friend class ServiceWorkerWriteToCacheJobTest; |
| 220 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDispatcherHostTest, | 223 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDispatcherHostTest, |
| 221 CleanupOnRendererCrash); | 224 CleanupOnRendererCrash); |
| 222 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerResourceStorageTest, | 225 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerResourceStorageTest, |
| 223 DeleteRegistration_NoLiveVersion); | 226 DeleteRegistration_NoLiveVersion); |
| 224 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerResourceStorageTest, | 227 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerResourceStorageTest, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 ServiceWorkerStorage( | 289 ServiceWorkerStorage( |
| 287 const base::FilePath& path, | 290 const base::FilePath& path, |
| 288 base::WeakPtr<ServiceWorkerContextCore> context, | 291 base::WeakPtr<ServiceWorkerContextCore> context, |
| 289 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, | 292 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, |
| 290 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 293 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
| 291 storage::QuotaManagerProxy* quota_manager_proxy, | 294 storage::QuotaManagerProxy* quota_manager_proxy, |
| 292 storage::SpecialStoragePolicy* special_storage_policy); | 295 storage::SpecialStoragePolicy* special_storage_policy); |
| 293 | 296 |
| 294 base::FilePath GetDatabasePath(); | 297 base::FilePath GetDatabasePath(); |
| 295 base::FilePath GetDiskCachePath(); | 298 base::FilePath GetDiskCachePath(); |
| 299 base::FilePath GetOldDiskCachePath(); | |
|
falken
2015/06/01 04:31:50
Can you add a comment about what the Old* function
nhiroki
2015/06/02 09:18:33
Done.
| |
| 296 | 300 |
| 297 // Loads the registration data from backend storage. This must be called | |
| 298 // before any method that requires registration data. | |
| 299 bool LazyInitialize( | 301 bool LazyInitialize( |
| 300 const base::Closure& callback); | 302 const base::Closure& callback); |
| 303 void DidCheckOldDiskCacheDirectory(bool exists); | |
| 304 void DidInitializeOldDiskCache( | |
| 305 scoped_ptr<ServiceWorkerDiskCache> old_disk_cache, | |
| 306 int result); | |
| 307 void DidDiskCacheMigrated(scoped_ptr<ServiceWorkerDiskCacheMigrator> migrator, | |
|
falken
2015/06/01 04:31:50
nit: this is ungrammatical... maybe DidMigrateDisk
nhiroki
2015/06/02 09:18:33
Done.
| |
| 308 scoped_ptr<ServiceWorkerDiskCache> old_disk_cache, | |
| 309 ServiceWorkerStatusCode status); | |
| 310 void DidDeleteOldDiskCache(bool deleted); | |
| 311 void AbortLazyInitialize( | |
| 312 ServiceWorkerMetrics::DiskCacheMigrationResult result); | |
| 313 void ContinueLazyInitialize(); | |
| 301 void DidReadInitialData( | 314 void DidReadInitialData( |
| 302 InitialData* data, | 315 InitialData* data, |
| 303 ServiceWorkerDatabase::Status status); | 316 ServiceWorkerDatabase::Status status); |
| 317 | |
| 304 void DidFindRegistrationForDocument( | 318 void DidFindRegistrationForDocument( |
| 305 const GURL& document_url, | 319 const GURL& document_url, |
| 306 const FindRegistrationCallback& callback, | 320 const FindRegistrationCallback& callback, |
| 307 int64 callback_id, | 321 int64 callback_id, |
| 308 const ServiceWorkerDatabase::RegistrationData& data, | 322 const ServiceWorkerDatabase::RegistrationData& data, |
| 309 const ResourceList& resources, | 323 const ResourceList& resources, |
| 310 ServiceWorkerDatabase::Status status); | 324 ServiceWorkerDatabase::Status status); |
| 311 void DidFindRegistrationForPattern( | 325 void DidFindRegistrationForPattern( |
| 312 const GURL& scope, | 326 const GURL& scope, |
| 313 const FindRegistrationCallback& callback, | 327 const FindRegistrationCallback& callback, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 std::set<int64> pending_deletions_; | 506 std::set<int64> pending_deletions_; |
| 493 | 507 |
| 494 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; | 508 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; |
| 495 | 509 |
| 496 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 510 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
| 497 }; | 511 }; |
| 498 | 512 |
| 499 } // namespace content | 513 } // namespace content |
| 500 | 514 |
| 501 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 515 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
| OLD | NEW |