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_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 WebServiceWorkerUnregistrationCallbacks; | 60 WebServiceWorkerUnregistrationCallbacks; |
61 typedef | 61 typedef |
62 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationCallbacks | 62 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationCallbacks |
63 WebServiceWorkerGetRegistrationCallbacks; | 63 WebServiceWorkerGetRegistrationCallbacks; |
64 typedef | 64 typedef |
65 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationsCallbacks | 65 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationsCallbacks |
66 WebServiceWorkerGetRegistrationsCallbacks; | 66 WebServiceWorkerGetRegistrationsCallbacks; |
67 typedef blink::WebServiceWorkerProvider:: | 67 typedef blink::WebServiceWorkerProvider:: |
68 WebServiceWorkerGetRegistrationForReadyCallbacks | 68 WebServiceWorkerGetRegistrationForReadyCallbacks |
69 WebServiceWorkerGetRegistrationForReadyCallbacks; | 69 WebServiceWorkerGetRegistrationForReadyCallbacks; |
| 70 using WebEnableNavigationPreloadCallbacks = |
| 71 blink::WebServiceWorkerRegistration::WebEnableNavigationPreloadCallbacks; |
70 | 72 |
71 ServiceWorkerDispatcher( | 73 ServiceWorkerDispatcher( |
72 ThreadSafeSender* thread_safe_sender, | 74 ThreadSafeSender* thread_safe_sender, |
73 base::SingleThreadTaskRunner* main_thread_task_runner); | 75 base::SingleThreadTaskRunner* main_thread_task_runner); |
74 ~ServiceWorkerDispatcher() override; | 76 ~ServiceWorkerDispatcher() override; |
75 | 77 |
76 void OnMessageReceived(const IPC::Message& msg); | 78 void OnMessageReceived(const IPC::Message& msg); |
77 | 79 |
78 // Corresponds to navigator.serviceWorker.register(). | 80 // Corresponds to navigator.serviceWorker.register(). |
79 void RegisterServiceWorker( | 81 void RegisterServiceWorker( |
(...skipping 16 matching lines...) Expand all Loading... |
96 WebServiceWorkerGetRegistrationCallbacks* callbacks); | 98 WebServiceWorkerGetRegistrationCallbacks* callbacks); |
97 // Corresponds to navigator.serviceWorker.getRegistrations(). | 99 // Corresponds to navigator.serviceWorker.getRegistrations(). |
98 void GetRegistrations( | 100 void GetRegistrations( |
99 int provider_id, | 101 int provider_id, |
100 WebServiceWorkerGetRegistrationsCallbacks* callbacks); | 102 WebServiceWorkerGetRegistrationsCallbacks* callbacks); |
101 | 103 |
102 void GetRegistrationForReady( | 104 void GetRegistrationForReady( |
103 int provider_id, | 105 int provider_id, |
104 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks); | 106 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks); |
105 | 107 |
| 108 // Corresponds to NavigationPreloadManager.enable/disable. |
| 109 void EnableNavigationPreload( |
| 110 int provider_id, |
| 111 int64_t registration_id, |
| 112 bool enable, |
| 113 std::unique_ptr<WebEnableNavigationPreloadCallbacks> callbacks); |
| 114 |
106 // Called when a new provider context for a document is created. Usually | 115 // Called when a new provider context for a document is created. Usually |
107 // this happens when a new document is being loaded, and is called much | 116 // this happens when a new document is being loaded, and is called much |
108 // earlier than AddScriptClient. | 117 // earlier than AddScriptClient. |
109 // (This is attached only to the document thread's ServiceWorkerDispatcher) | 118 // (This is attached only to the document thread's ServiceWorkerDispatcher) |
110 void AddProviderContext(ServiceWorkerProviderContext* provider_context); | 119 void AddProviderContext(ServiceWorkerProviderContext* provider_context); |
111 void RemoveProviderContext(ServiceWorkerProviderContext* provider_context); | 120 void RemoveProviderContext(ServiceWorkerProviderContext* provider_context); |
112 | 121 |
113 // Called when navigator.serviceWorker is instantiated or detached | 122 // Called when navigator.serviceWorker is instantiated or detached |
114 // for a document whose provider can be identified by |provider_id|. | 123 // for a document whose provider can be identified by |provider_id|. |
115 void AddProviderClient(int provider_id, | 124 void AddProviderClient(int provider_id, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 typedef IDMap<WebServiceWorkerUpdateCallbacks, IDMapOwnPointer> | 162 typedef IDMap<WebServiceWorkerUpdateCallbacks, IDMapOwnPointer> |
154 UpdateCallbackMap; | 163 UpdateCallbackMap; |
155 typedef IDMap<WebServiceWorkerUnregistrationCallbacks, | 164 typedef IDMap<WebServiceWorkerUnregistrationCallbacks, |
156 IDMapOwnPointer> UnregistrationCallbackMap; | 165 IDMapOwnPointer> UnregistrationCallbackMap; |
157 typedef IDMap<WebServiceWorkerGetRegistrationCallbacks, | 166 typedef IDMap<WebServiceWorkerGetRegistrationCallbacks, |
158 IDMapOwnPointer> GetRegistrationCallbackMap; | 167 IDMapOwnPointer> GetRegistrationCallbackMap; |
159 typedef IDMap<WebServiceWorkerGetRegistrationsCallbacks, | 168 typedef IDMap<WebServiceWorkerGetRegistrationsCallbacks, |
160 IDMapOwnPointer> GetRegistrationsCallbackMap; | 169 IDMapOwnPointer> GetRegistrationsCallbackMap; |
161 typedef IDMap<WebServiceWorkerGetRegistrationForReadyCallbacks, | 170 typedef IDMap<WebServiceWorkerGetRegistrationForReadyCallbacks, |
162 IDMapOwnPointer> GetRegistrationForReadyCallbackMap; | 171 IDMapOwnPointer> GetRegistrationForReadyCallbackMap; |
| 172 using EnableNavigationPreloadCallbackMap = |
| 173 IDMap<WebEnableNavigationPreloadCallbacks, IDMapOwnPointer>; |
163 | 174 |
164 typedef std::map<int, blink::WebServiceWorkerProviderClient*> | 175 typedef std::map<int, blink::WebServiceWorkerProviderClient*> |
165 ProviderClientMap; | 176 ProviderClientMap; |
166 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; | 177 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; |
167 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; | 178 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; |
168 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; | 179 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; |
169 typedef std::map<int, WebServiceWorkerRegistrationImpl*> | 180 typedef std::map<int, WebServiceWorkerRegistrationImpl*> |
170 RegistrationObjectMap; | 181 RegistrationObjectMap; |
171 | 182 |
172 friend class ServiceWorkerDispatcherTest; | 183 friend class ServiceWorkerDispatcherTest; |
(...skipping 24 matching lines...) Expand all Loading... |
197 void OnDidGetRegistrations( | 208 void OnDidGetRegistrations( |
198 int thread_id, | 209 int thread_id, |
199 int request_id, | 210 int request_id, |
200 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos, | 211 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos, |
201 const std::vector<ServiceWorkerVersionAttributes>& attrs); | 212 const std::vector<ServiceWorkerVersionAttributes>& attrs); |
202 void OnDidGetRegistrationForReady( | 213 void OnDidGetRegistrationForReady( |
203 int thread_id, | 214 int thread_id, |
204 int request_id, | 215 int request_id, |
205 const ServiceWorkerRegistrationObjectInfo& info, | 216 const ServiceWorkerRegistrationObjectInfo& info, |
206 const ServiceWorkerVersionAttributes& attrs); | 217 const ServiceWorkerVersionAttributes& attrs); |
| 218 void OnDidEnableNavigationPreload(int thread_id, int request_id); |
207 void OnRegistrationError(int thread_id, | 219 void OnRegistrationError(int thread_id, |
208 int request_id, | 220 int request_id, |
209 blink::WebServiceWorkerError::ErrorType error_type, | 221 blink::WebServiceWorkerError::ErrorType error_type, |
210 const base::string16& message); | 222 const base::string16& message); |
211 void OnUpdateError(int thread_id, | 223 void OnUpdateError(int thread_id, |
212 int request_id, | 224 int request_id, |
213 blink::WebServiceWorkerError::ErrorType error_type, | 225 blink::WebServiceWorkerError::ErrorType error_type, |
214 const base::string16& message); | 226 const base::string16& message); |
215 void OnUnregistrationError(int thread_id, | 227 void OnUnregistrationError(int thread_id, |
216 int request_id, | 228 int request_id, |
217 blink::WebServiceWorkerError::ErrorType error_type, | 229 blink::WebServiceWorkerError::ErrorType error_type, |
218 const base::string16& message); | 230 const base::string16& message); |
219 void OnGetRegistrationError( | 231 void OnGetRegistrationError( |
220 int thread_id, | 232 int thread_id, |
221 int request_id, | 233 int request_id, |
222 blink::WebServiceWorkerError::ErrorType error_type, | 234 blink::WebServiceWorkerError::ErrorType error_type, |
223 const base::string16& message); | 235 const base::string16& message); |
224 void OnGetRegistrationsError( | 236 void OnGetRegistrationsError( |
225 int thread_id, | 237 int thread_id, |
226 int request_id, | 238 int request_id, |
227 blink::WebServiceWorkerError::ErrorType error_type, | 239 blink::WebServiceWorkerError::ErrorType error_type, |
228 const base::string16& message); | 240 const base::string16& message); |
| 241 void OnEnableNavigationPreloadError( |
| 242 int thread_id, |
| 243 int request_id, |
| 244 blink::WebServiceWorkerError::ErrorType error_type, |
| 245 const std::string& message); |
229 void OnServiceWorkerStateChanged(int thread_id, | 246 void OnServiceWorkerStateChanged(int thread_id, |
230 int handle_id, | 247 int handle_id, |
231 blink::WebServiceWorkerState state); | 248 blink::WebServiceWorkerState state); |
232 void OnSetVersionAttributes(int thread_id, | 249 void OnSetVersionAttributes(int thread_id, |
233 int registration_handle_id, | 250 int registration_handle_id, |
234 int changed_mask, | 251 int changed_mask, |
235 const ServiceWorkerVersionAttributes& attributes); | 252 const ServiceWorkerVersionAttributes& attributes); |
236 void OnUpdateFound(int thread_id, | 253 void OnUpdateFound(int thread_id, |
237 int registration_handle_id); | 254 int registration_handle_id); |
238 void OnSetControllerServiceWorker(int thread_id, | 255 void OnSetControllerServiceWorker(int thread_id, |
(...skipping 19 matching lines...) Expand all Loading... |
258 const ServiceWorkerRegistrationObjectInfo& info); | 275 const ServiceWorkerRegistrationObjectInfo& info); |
259 std::unique_ptr<ServiceWorkerHandleReference> Adopt( | 276 std::unique_ptr<ServiceWorkerHandleReference> Adopt( |
260 const ServiceWorkerObjectInfo& info); | 277 const ServiceWorkerObjectInfo& info); |
261 | 278 |
262 RegistrationCallbackMap pending_registration_callbacks_; | 279 RegistrationCallbackMap pending_registration_callbacks_; |
263 UpdateCallbackMap pending_update_callbacks_; | 280 UpdateCallbackMap pending_update_callbacks_; |
264 UnregistrationCallbackMap pending_unregistration_callbacks_; | 281 UnregistrationCallbackMap pending_unregistration_callbacks_; |
265 GetRegistrationCallbackMap pending_get_registration_callbacks_; | 282 GetRegistrationCallbackMap pending_get_registration_callbacks_; |
266 GetRegistrationsCallbackMap pending_get_registrations_callbacks_; | 283 GetRegistrationsCallbackMap pending_get_registrations_callbacks_; |
267 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; | 284 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; |
| 285 EnableNavigationPreloadCallbackMap enable_navigation_preload_callbacks_; |
268 | 286 |
269 ProviderClientMap provider_clients_; | 287 ProviderClientMap provider_clients_; |
270 ProviderContextMap provider_contexts_; | 288 ProviderContextMap provider_contexts_; |
271 | 289 |
272 WorkerObjectMap service_workers_; | 290 WorkerObjectMap service_workers_; |
273 RegistrationObjectMap registrations_; | 291 RegistrationObjectMap registrations_; |
274 | 292 |
275 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 293 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
276 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 294 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
277 | 295 |
278 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 296 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
279 }; | 297 }; |
280 | 298 |
281 } // namespace content | 299 } // namespace content |
282 | 300 |
283 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 301 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |