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 <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "content/browser/service_worker/service_worker_database.h" | 16 #include "content/browser/service_worker/service_worker_database.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
18 #include "content/common/service_worker/service_worker_status_code.h" | 18 #include "content/common/service_worker/service_worker_status_code.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
20 | 20 |
| 21 namespace base { |
| 22 class SequencedTaskRunner; |
| 23 } |
| 24 |
21 namespace quota { | 25 namespace quota { |
22 class QuotaManagerProxy; | 26 class QuotaManagerProxy; |
23 } | 27 } |
24 | 28 |
25 namespace content { | 29 namespace content { |
26 | 30 |
27 class ServiceWorkerContextCore; | 31 class ServiceWorkerContextCore; |
28 class ServiceWorkerRegistration; | 32 class ServiceWorkerRegistration; |
29 class ServiceWorkerRegistrationInfo; | 33 class ServiceWorkerRegistrationInfo; |
30 class ServiceWorkerVersion; | 34 class ServiceWorkerVersion; |
31 | 35 |
32 // This class provides an interface to store and retrieve ServiceWorker | 36 // This class provides an interface to store and retrieve ServiceWorker |
33 // registration data. | 37 // registration data. |
34 class CONTENT_EXPORT ServiceWorkerStorage { | 38 class CONTENT_EXPORT ServiceWorkerStorage { |
35 public: | 39 public: |
36 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; | 40 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; |
37 typedef base::Callback<void(ServiceWorkerStatusCode status, | 41 typedef base::Callback<void(ServiceWorkerStatusCode status, |
38 const scoped_refptr<ServiceWorkerRegistration>& | 42 const scoped_refptr<ServiceWorkerRegistration>& |
39 registration)> FindRegistrationCallback; | 43 registration)> FindRegistrationCallback; |
40 typedef base::Callback< | 44 typedef base::Callback< |
41 void(const std::vector<ServiceWorkerRegistrationInfo>& registrations)> | 45 void(const std::vector<ServiceWorkerRegistrationInfo>& registrations)> |
42 GetAllRegistrationInfosCallback; | 46 GetAllRegistrationInfosCallback; |
43 typedef base::Callback< | 47 typedef base::Callback< |
44 void(ServiceWorkerStatusCode status, int result)> | 48 void(ServiceWorkerStatusCode status, int result)> |
45 CompareCallback; | 49 CompareCallback; |
46 | 50 |
47 ServiceWorkerStorage(const base::FilePath& path, | 51 ServiceWorkerStorage(const base::FilePath& path, |
48 base::WeakPtr<ServiceWorkerContextCore> context, | 52 base::WeakPtr<ServiceWorkerContextCore> context, |
| 53 base::SequencedTaskRunner* database_task_runner, |
49 quota::QuotaManagerProxy* quota_manager_proxy); | 54 quota::QuotaManagerProxy* quota_manager_proxy); |
50 ~ServiceWorkerStorage(); | 55 ~ServiceWorkerStorage(); |
51 | 56 |
52 // Finds registration for |document_url| or |pattern| or |registration_id|. | 57 // Finds registration for |document_url| or |pattern| or |registration_id|. |
53 // The Find methods will find stored and initially installing registrations. | 58 // The Find methods will find stored and initially installing registrations. |
54 // Returns SERVICE_WORKER_OK with non-null registration if registration | 59 // Returns SERVICE_WORKER_OK with non-null registration if registration |
55 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching | 60 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching |
56 // registration is found. The FindRegistrationForPattern method is | 61 // registration is found. The FindRegistrationForPattern method is |
57 // guaranteed to return asynchronously. However, the methods to find | 62 // guaranteed to return asynchronously. However, the methods to find |
58 // for |document_url| or |registration_id| may complete immediately | 63 // for |document_url| or |registration_id| may complete immediately |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 RegistrationRefsById; | 135 RegistrationRefsById; |
131 RegistrationRefsById installing_registrations_; | 136 RegistrationRefsById installing_registrations_; |
132 | 137 |
133 int64 last_registration_id_; | 138 int64 last_registration_id_; |
134 int64 last_version_id_; | 139 int64 last_version_id_; |
135 int64 last_resource_id_; | 140 int64 last_resource_id_; |
136 bool simulated_lazy_initted_; | 141 bool simulated_lazy_initted_; |
137 | 142 |
138 base::FilePath path_; | 143 base::FilePath path_; |
139 base::WeakPtr<ServiceWorkerContextCore> context_; | 144 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 145 scoped_refptr<base::SequencedTaskRunner> database_task_runner_; |
140 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 146 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
141 | 147 |
142 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 148 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
143 }; | 149 }; |
144 | 150 |
145 } // namespace content | 151 } // namespace content |
146 | 152 |
147 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 153 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
OLD | NEW |