| 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 <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "content/browser/service_worker/service_worker_database.h" | 18 #include "content/browser/service_worker/service_worker_database.h" |
| 19 #include "content/browser/service_worker/service_worker_version.h" | 19 #include "content/browser/service_worker/service_worker_version.h" |
| 20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
| 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 quota { | 29 namespace storage { |
| 30 class QuotaManagerProxy; | 30 class QuotaManagerProxy; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace content { | 33 namespace content { |
| 34 | 34 |
| 35 class ServiceWorkerContextCore; | 35 class ServiceWorkerContextCore; |
| 36 class ServiceWorkerDiskCache; | 36 class ServiceWorkerDiskCache; |
| 37 class ServiceWorkerRegistration; | 37 class ServiceWorkerRegistration; |
| 38 class ServiceWorkerRegistrationInfo; | 38 class ServiceWorkerRegistrationInfo; |
| 39 class ServiceWorkerResponseReader; | 39 class ServiceWorkerResponseReader; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 void(ServiceWorkerStatusCode status, bool are_equal)> | 56 void(ServiceWorkerStatusCode status, bool are_equal)> |
| 57 CompareCallback; | 57 CompareCallback; |
| 58 | 58 |
| 59 virtual ~ServiceWorkerStorage(); | 59 virtual ~ServiceWorkerStorage(); |
| 60 | 60 |
| 61 static scoped_ptr<ServiceWorkerStorage> Create( | 61 static scoped_ptr<ServiceWorkerStorage> Create( |
| 62 const base::FilePath& path, | 62 const base::FilePath& path, |
| 63 base::WeakPtr<ServiceWorkerContextCore> context, | 63 base::WeakPtr<ServiceWorkerContextCore> context, |
| 64 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, | 64 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, |
| 65 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 65 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
| 66 quota::QuotaManagerProxy* quota_manager_proxy); | 66 storage::QuotaManagerProxy* quota_manager_proxy); |
| 67 | 67 |
| 68 // Used for DeleteAndStartOver. Creates new storage based on |old_storage|. | 68 // Used for DeleteAndStartOver. Creates new storage based on |old_storage|. |
| 69 static scoped_ptr<ServiceWorkerStorage> Create( | 69 static scoped_ptr<ServiceWorkerStorage> Create( |
| 70 base::WeakPtr<ServiceWorkerContextCore> context, | 70 base::WeakPtr<ServiceWorkerContextCore> context, |
| 71 ServiceWorkerStorage* old_storage); | 71 ServiceWorkerStorage* old_storage); |
| 72 | 72 |
| 73 // Finds registration for |document_url| or |pattern| or |registration_id|. | 73 // Finds registration for |document_url| or |pattern| or |registration_id|. |
| 74 // The Find methods will find stored and initially installing registrations. | 74 // The Find methods will find stored and initially installing registrations. |
| 75 // Returns SERVICE_WORKER_OK with non-null registration if registration | 75 // Returns SERVICE_WORKER_OK with non-null registration if registration |
| 76 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching | 76 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 ServiceWorkerDatabase::Status status)> FindInDBCallback; | 217 ServiceWorkerDatabase::Status status)> FindInDBCallback; |
| 218 typedef base::Callback<void(const std::vector<int64>& resource_ids, | 218 typedef base::Callback<void(const std::vector<int64>& resource_ids, |
| 219 ServiceWorkerDatabase::Status status)> | 219 ServiceWorkerDatabase::Status status)> |
| 220 GetResourcesCallback; | 220 GetResourcesCallback; |
| 221 | 221 |
| 222 ServiceWorkerStorage( | 222 ServiceWorkerStorage( |
| 223 const base::FilePath& path, | 223 const base::FilePath& path, |
| 224 base::WeakPtr<ServiceWorkerContextCore> context, | 224 base::WeakPtr<ServiceWorkerContextCore> context, |
| 225 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, | 225 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, |
| 226 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 226 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
| 227 quota::QuotaManagerProxy* quota_manager_proxy); | 227 storage::QuotaManagerProxy* quota_manager_proxy); |
| 228 | 228 |
| 229 base::FilePath GetDatabasePath(); | 229 base::FilePath GetDatabasePath(); |
| 230 base::FilePath GetDiskCachePath(); | 230 base::FilePath GetDiskCachePath(); |
| 231 | 231 |
| 232 bool LazyInitialize( | 232 bool LazyInitialize( |
| 233 const base::Closure& callback); | 233 const base::Closure& callback); |
| 234 void DidReadInitialData( | 234 void DidReadInitialData( |
| 235 InitialData* data, | 235 InitialData* data, |
| 236 ServiceWorkerDatabase::Status status); | 236 ServiceWorkerDatabase::Status status); |
| 237 void DidFindRegistrationForDocument( | 237 void DidFindRegistrationForDocument( |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 State state_; | 370 State state_; |
| 371 | 371 |
| 372 base::FilePath path_; | 372 base::FilePath path_; |
| 373 base::WeakPtr<ServiceWorkerContextCore> context_; | 373 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 374 | 374 |
| 375 // Only accessed on |database_task_runner_|. | 375 // Only accessed on |database_task_runner_|. |
| 376 scoped_ptr<ServiceWorkerDatabase> database_; | 376 scoped_ptr<ServiceWorkerDatabase> database_; |
| 377 | 377 |
| 378 scoped_refptr<base::SequencedTaskRunner> database_task_runner_; | 378 scoped_refptr<base::SequencedTaskRunner> database_task_runner_; |
| 379 scoped_refptr<base::SingleThreadTaskRunner> disk_cache_thread_; | 379 scoped_refptr<base::SingleThreadTaskRunner> disk_cache_thread_; |
| 380 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 380 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; |
| 381 scoped_ptr<ServiceWorkerDiskCache> disk_cache_; | 381 scoped_ptr<ServiceWorkerDiskCache> disk_cache_; |
| 382 std::deque<int64> purgeable_resource_ids_; | 382 std::deque<int64> purgeable_resource_ids_; |
| 383 bool is_purge_pending_; | 383 bool is_purge_pending_; |
| 384 bool has_checked_for_stale_resources_; | 384 bool has_checked_for_stale_resources_; |
| 385 std::set<int64> pending_deletions_; | 385 std::set<int64> pending_deletions_; |
| 386 | 386 |
| 387 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; | 387 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; |
| 388 | 388 |
| 389 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 389 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
| 390 }; | 390 }; |
| 391 | 391 |
| 392 } // namespace content | 392 } // namespace content |
| 393 | 393 |
| 394 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 394 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
| OLD | NEW |