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_CONTEXT_WRAPPER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 // The core context is only for use on the IO thread. | 61 // The core context is only for use on the IO thread. |
62 ServiceWorkerContextCore* context(); | 62 ServiceWorkerContextCore* context(); |
63 | 63 |
64 // The process manager can be used on either UI or IO. | 64 // The process manager can be used on either UI or IO. |
65 ServiceWorkerProcessManager* process_manager() { | 65 ServiceWorkerProcessManager* process_manager() { |
66 return process_manager_.get(); | 66 return process_manager_.get(); |
67 } | 67 } |
68 | 68 |
69 // ServiceWorkerContext implementation: | 69 // ServiceWorkerContext implementation: |
70 virtual void RegisterServiceWorker( | 70 void RegisterServiceWorker(const GURL& pattern, |
71 const GURL& pattern, | 71 const GURL& script_url, |
72 const GURL& script_url, | 72 const ResultCallback& continuation) override; |
73 const ResultCallback& continuation) override; | 73 void UnregisterServiceWorker(const GURL& pattern, |
74 virtual void UnregisterServiceWorker( | 74 const ResultCallback& continuation) override; |
75 const GURL& pattern, | 75 void Terminate() override; |
76 const ResultCallback& continuation) override; | 76 void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override; |
77 virtual void Terminate() override; | 77 void DeleteForOrigin(const GURL& origin_url) override; |
78 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override; | |
79 virtual void DeleteForOrigin(const GURL& origin_url) override; | |
80 | 78 |
81 // DeleteForOrigin with completion callback. Does not exit early, and returns | 79 // DeleteForOrigin with completion callback. Does not exit early, and returns |
82 // false if one or more of the deletions fail. | 80 // false if one or more of the deletions fail. |
83 virtual void DeleteForOrigin(const GURL& origin_url, | 81 virtual void DeleteForOrigin(const GURL& origin_url, |
84 const ResultCallback& done); | 82 const ResultCallback& done); |
85 | 83 |
86 void AddObserver(ServiceWorkerContextObserver* observer); | 84 void AddObserver(ServiceWorkerContextObserver* observer); |
87 void RemoveObserver(ServiceWorkerContextObserver* observer); | 85 void RemoveObserver(ServiceWorkerContextObserver* observer); |
88 | 86 |
89 bool is_incognito() const { return is_incognito_; } | 87 bool is_incognito() const { return is_incognito_; } |
90 | 88 |
91 // The URLRequestContext doesn't exist until after the StoragePartition is | 89 // The URLRequestContext doesn't exist until after the StoragePartition is |
92 // made (which is after this object is made). This function must be called | 90 // made (which is after this object is made). This function must be called |
93 // after this object is created but before any ServiceWorkerCache operations. | 91 // after this object is created but before any ServiceWorkerCache operations. |
94 // It must be called on the IO thread. If either parameter is NULL the | 92 // It must be called on the IO thread. If either parameter is NULL the |
95 // function immediately returns without forwarding to the | 93 // function immediately returns without forwarding to the |
96 // ServiceWorkerCacheStorageManager. | 94 // ServiceWorkerCacheStorageManager. |
97 void SetBlobParametersForCache( | 95 void SetBlobParametersForCache( |
98 net::URLRequestContextGetter* request_context, | 96 net::URLRequestContextGetter* request_context, |
99 ChromeBlobStorageContext* blob_storage_context); | 97 ChromeBlobStorageContext* blob_storage_context); |
100 | 98 |
101 private: | 99 private: |
102 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; | 100 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; |
103 friend class EmbeddedWorkerTestHelper; | 101 friend class EmbeddedWorkerTestHelper; |
104 friend class ServiceWorkerProcessManager; | 102 friend class ServiceWorkerProcessManager; |
105 friend class MockServiceWorkerContextWrapper; | 103 friend class MockServiceWorkerContextWrapper; |
106 | 104 |
107 virtual ~ServiceWorkerContextWrapper(); | 105 ~ServiceWorkerContextWrapper() override; |
108 | 106 |
109 void InitInternal( | 107 void InitInternal( |
110 const base::FilePath& user_data_directory, | 108 const base::FilePath& user_data_directory, |
111 const scoped_refptr<base::SequencedTaskRunner>& stores_task_runner, | 109 const scoped_refptr<base::SequencedTaskRunner>& stores_task_runner, |
112 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, | 110 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, |
113 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 111 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
114 storage::QuotaManagerProxy* quota_manager_proxy, | 112 storage::QuotaManagerProxy* quota_manager_proxy, |
115 storage::SpecialStoragePolicy* special_storage_policy); | 113 storage::SpecialStoragePolicy* special_storage_policy); |
116 void ShutdownOnIO(); | 114 void ShutdownOnIO(); |
117 | 115 |
118 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); | 116 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); |
119 | 117 |
120 void DidGetAllRegistrationsForGetAllOrigins( | 118 void DidGetAllRegistrationsForGetAllOrigins( |
121 const GetUsageInfoCallback& callback, | 119 const GetUsageInfoCallback& callback, |
122 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | 120 const std::vector<ServiceWorkerRegistrationInfo>& registrations); |
123 | 121 |
124 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > | 122 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > |
125 observer_list_; | 123 observer_list_; |
126 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; | 124 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; |
127 // Cleared in Shutdown(): | 125 // Cleared in Shutdown(): |
128 scoped_ptr<ServiceWorkerContextCore> context_core_; | 126 scoped_ptr<ServiceWorkerContextCore> context_core_; |
129 | 127 |
130 // Initialized in Init(); true if the user data directory is empty. | 128 // Initialized in Init(); true if the user data directory is empty. |
131 bool is_incognito_; | 129 bool is_incognito_; |
132 }; | 130 }; |
133 | 131 |
134 } // namespace content | 132 } // namespace content |
135 | 133 |
136 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 134 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
OLD | NEW |