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 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
15 #include "content/common/service_worker/service_worker_status_code.h" | 16 #include "content/common/service_worker/service_worker_status_code.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 namespace quota { | 19 namespace quota { |
19 class QuotaManagerProxy; | 20 class QuotaManagerProxy; |
20 } | 21 } |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
24 class ServiceWorkerRegistration; | 25 class ServiceWorkerRegistration; |
26 class ServiceWorkerRegistrationInfo; | |
25 | 27 |
26 // This class provides an interface to load registration data and | 28 // This class provides an interface to load registration data and |
27 // instantiate ServiceWorkerRegistration objects. | 29 // instantiate ServiceWorkerRegistration objects. |
28 class CONTENT_EXPORT ServiceWorkerStorage { | 30 class CONTENT_EXPORT ServiceWorkerStorage { |
29 public: | 31 public: |
30 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; | 32 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; |
31 typedef base::Callback<void(ServiceWorkerStatusCode status, | 33 typedef base::Callback<void(ServiceWorkerStatusCode status, |
32 const scoped_refptr<ServiceWorkerRegistration>& | 34 const scoped_refptr<ServiceWorkerRegistration>& |
33 registration)> FindRegistrationCallback; | 35 registration)> FindRegistrationCallback; |
34 | 36 |
35 ServiceWorkerStorage(const base::FilePath& path, | 37 ServiceWorkerStorage(const base::FilePath& path, |
36 quota::QuotaManagerProxy* quota_manager_proxy); | 38 quota::QuotaManagerProxy* quota_manager_proxy); |
37 ~ServiceWorkerStorage(); | 39 ~ServiceWorkerStorage(); |
38 | 40 |
39 // Finds registration for |document_url| or |pattern|. | 41 // Finds registration for |document_url| or |pattern|. |
40 // Returns SERVICE_WORKER_OK with non-null registration if registration | 42 // Returns SERVICE_WORKER_OK with non-null registration if registration |
41 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching | 43 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching |
42 // registration is found. | 44 // registration is found. |
43 void FindRegistrationForDocument(const GURL& document_url, | 45 void FindRegistrationForDocument(const GURL& document_url, |
44 const FindRegistrationCallback& callback); | 46 const FindRegistrationCallback& callback); |
45 void FindRegistrationForPattern(const GURL& pattern, | 47 void FindRegistrationForPattern(const GURL& pattern, |
46 const FindRegistrationCallback& callback); | 48 const FindRegistrationCallback& callback); |
47 | 49 |
50 typedef base::Callback< | |
51 void(const std::vector<ServiceWorkerRegistrationInfo>& registrations)> | |
52 GetAllRegistrationInfosCallback; | |
michaeln
2014/03/06 01:19:02
lets put the typedef up top with the other typedef
| |
53 void GetAllRegistrations(const GetAllRegistrationInfosCallback& callback); | |
54 | |
48 // Stores |registration|. Returns SERVICE_WORKER_ERROR_EXISTS if | 55 // Stores |registration|. Returns SERVICE_WORKER_ERROR_EXISTS if |
49 // conflicting registration (which has different script_url) is | 56 // conflicting registration (which has different script_url) is |
50 // already registered for the |registration|->pattern(). | 57 // already registered for the |registration|->pattern(). |
51 void StoreRegistration(ServiceWorkerRegistration* registration, | 58 void StoreRegistration(ServiceWorkerRegistration* registration, |
52 const StatusCallback& callback); | 59 const StatusCallback& callback); |
53 | 60 |
54 // Deletes |registration|. This may return SERVICE_WORKER_ERROR_NOT_FOUND | 61 // Deletes |registration|. This may return SERVICE_WORKER_ERROR_NOT_FOUND |
55 // if no matching registration is found. | 62 // if no matching registration is found. |
56 void DeleteRegistration(const GURL& pattern, | 63 void DeleteRegistration(const GURL& pattern, |
57 const StatusCallback& callback); | 64 const StatusCallback& callback); |
(...skipping 18 matching lines...) Expand all Loading... | |
76 | 83 |
77 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 84 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
78 base::FilePath path_; | 85 base::FilePath path_; |
79 | 86 |
80 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 87 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
81 }; | 88 }; |
82 | 89 |
83 } // namespace content | 90 } // namespace content |
84 | 91 |
85 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 92 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
OLD | NEW |