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 <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // |adopt_handle| is true, a ServiceWorkerHandleReference will be | 111 // |adopt_handle| is true, a ServiceWorkerHandleReference will be |
112 // adopted for the specified Service Worker. | 112 // adopted for the specified Service Worker. |
113 // | 113 // |
114 // TODO(dominicc): The lifetime of WebServiceWorkerImpl is too tricky; this | 114 // TODO(dominicc): The lifetime of WebServiceWorkerImpl is too tricky; this |
115 // method can return an existing WebServiceWorkerImpl, in which case | 115 // method can return an existing WebServiceWorkerImpl, in which case |
116 // it is owned by a WebCore::ServiceWorker and the lifetime is not | 116 // it is owned by a WebCore::ServiceWorker and the lifetime is not |
117 // being transferred to the owner; or it can create a | 117 // being transferred to the owner; or it can create a |
118 // WebServiceWorkerImpl, in which case ownership is transferred to | 118 // WebServiceWorkerImpl, in which case ownership is transferred to |
119 // the caller who must bounce it to a method that will associate it | 119 // the caller who must bounce it to a method that will associate it |
120 // with a WebCore::ServiceWorker. | 120 // with a WebCore::ServiceWorker. |
121 WebServiceWorkerImpl* GetServiceWorker( | 121 WebServiceWorkerImpl* GetServiceWorker(const ServiceWorkerObjectInfo& info, |
122 const ServiceWorkerObjectInfo& info, | 122 int provider_id, |
123 bool adopt_handle); | 123 bool adopt_handle); |
124 | 124 |
125 // Creates a WebServiceWorkerRegistrationImpl for the specified registration | 125 // Creates a WebServiceWorkerRegistrationImpl for the specified registration |
126 // and transfers its ownership to the caller. If |adopt_handle| is true, a | 126 // and transfers its ownership to the caller. If |adopt_handle| is true, a |
127 // ServiceWorkerRegistrationHandleReference will be adopted for the | 127 // ServiceWorkerRegistrationHandleReference will be adopted for the |
128 // registration. | 128 // registration. |
129 WebServiceWorkerRegistrationImpl* CreateServiceWorkerRegistration( | 129 WebServiceWorkerRegistrationImpl* CreateServiceWorkerRegistration( |
130 const ServiceWorkerRegistrationObjectInfo& info, | 130 const ServiceWorkerRegistrationObjectInfo& info, |
131 bool adopt_handle); | 131 bool adopt_handle); |
132 | 132 |
133 // |thread_safe_sender| needs to be passed in because if the call leads to | 133 // |thread_safe_sender| needs to be passed in because if the call leads to |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const ServiceWorkerRegistrationObjectInfo& info, | 172 const ServiceWorkerRegistrationObjectInfo& info, |
173 const ServiceWorkerVersionAttributes& attrs); | 173 const ServiceWorkerVersionAttributes& attrs); |
174 void OnAssociateRegistration(int thread_id, | 174 void OnAssociateRegistration(int thread_id, |
175 int provider_id, | 175 int provider_id, |
176 const ServiceWorkerRegistrationObjectInfo& info, | 176 const ServiceWorkerRegistrationObjectInfo& info, |
177 const ServiceWorkerVersionAttributes& attrs); | 177 const ServiceWorkerVersionAttributes& attrs); |
178 void OnDisassociateRegistration(int thread_id, | 178 void OnDisassociateRegistration(int thread_id, |
179 int provider_id); | 179 int provider_id); |
180 void OnRegistered(int thread_id, | 180 void OnRegistered(int thread_id, |
181 int request_id, | 181 int request_id, |
| 182 int provider_id, |
182 const ServiceWorkerRegistrationObjectInfo& info, | 183 const ServiceWorkerRegistrationObjectInfo& info, |
183 const ServiceWorkerVersionAttributes& attrs); | 184 const ServiceWorkerVersionAttributes& attrs); |
184 void OnUnregistered(int thread_id, | 185 void OnUnregistered(int thread_id, |
185 int request_id, | 186 int request_id, |
186 bool is_success); | 187 bool is_success); |
187 void OnDidGetRegistration(int thread_id, | 188 void OnDidGetRegistration(int thread_id, |
188 int request_id, | 189 int request_id, |
| 190 int provider_id, |
189 const ServiceWorkerRegistrationObjectInfo& info, | 191 const ServiceWorkerRegistrationObjectInfo& info, |
190 const ServiceWorkerVersionAttributes& attrs); | 192 const ServiceWorkerVersionAttributes& attrs); |
191 void OnDidGetRegistrations( | 193 void OnDidGetRegistrations( |
192 int thread_id, | 194 int thread_id, |
193 int request_id, | 195 int request_id, |
| 196 int provider_id, |
194 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos, | 197 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos, |
195 const std::vector<ServiceWorkerVersionAttributes>& attrs); | 198 const std::vector<ServiceWorkerVersionAttributes>& attrs); |
196 void OnDidGetRegistrationForReady( | 199 void OnDidGetRegistrationForReady( |
197 int thread_id, | 200 int thread_id, |
198 int request_id, | 201 int request_id, |
| 202 int provider_id, |
199 const ServiceWorkerRegistrationObjectInfo& info, | 203 const ServiceWorkerRegistrationObjectInfo& info, |
200 const ServiceWorkerVersionAttributes& attrs); | 204 const ServiceWorkerVersionAttributes& attrs); |
201 void OnRegistrationError(int thread_id, | 205 void OnRegistrationError(int thread_id, |
202 int request_id, | 206 int request_id, |
203 blink::WebServiceWorkerError::ErrorType error_type, | 207 blink::WebServiceWorkerError::ErrorType error_type, |
204 const base::string16& message); | 208 const base::string16& message); |
205 void OnUnregistrationError(int thread_id, | 209 void OnUnregistrationError(int thread_id, |
206 int request_id, | 210 int request_id, |
207 blink::WebServiceWorkerError::ErrorType error_type, | 211 blink::WebServiceWorkerError::ErrorType error_type, |
208 const base::string16& message); | 212 const base::string16& message); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 WebServiceWorkerRegistrationImpl* registration); | 246 WebServiceWorkerRegistrationImpl* registration); |
243 void RemoveServiceWorkerRegistration( | 247 void RemoveServiceWorkerRegistration( |
244 int registration_handle_id); | 248 int registration_handle_id); |
245 | 249 |
246 // Returns an existing registration or new one filled in with version | 250 // Returns an existing registration or new one filled in with version |
247 // attributes. This function assumes given |info| and |attrs| retain handle | 251 // attributes. This function assumes given |info| and |attrs| retain handle |
248 // references and always adopts them. | 252 // references and always adopts them. |
249 // TODO(nhiroki): This assumption seems to impair readability. We could | 253 // TODO(nhiroki): This assumption seems to impair readability. We could |
250 // explictly pass ServiceWorker(Registration)HandleReference instead. | 254 // explictly pass ServiceWorker(Registration)HandleReference instead. |
251 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration( | 255 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration( |
| 256 int provider_id, |
252 const ServiceWorkerRegistrationObjectInfo& info, | 257 const ServiceWorkerRegistrationObjectInfo& info, |
253 const ServiceWorkerVersionAttributes& attrs); | 258 const ServiceWorkerVersionAttributes& attrs); |
254 | 259 |
255 RegistrationCallbackMap pending_registration_callbacks_; | 260 RegistrationCallbackMap pending_registration_callbacks_; |
256 UnregistrationCallbackMap pending_unregistration_callbacks_; | 261 UnregistrationCallbackMap pending_unregistration_callbacks_; |
257 GetRegistrationCallbackMap pending_get_registration_callbacks_; | 262 GetRegistrationCallbackMap pending_get_registration_callbacks_; |
258 GetRegistrationsCallbackMap pending_get_registrations_callbacks_; | 263 GetRegistrationsCallbackMap pending_get_registrations_callbacks_; |
259 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; | 264 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; |
260 | 265 |
261 ProviderClientMap provider_clients_; | 266 ProviderClientMap provider_clients_; |
262 ProviderContextMap provider_contexts_; | 267 ProviderContextMap provider_contexts_; |
263 | 268 |
264 WorkerObjectMap service_workers_; | 269 WorkerObjectMap service_workers_; |
265 RegistrationObjectMap registrations_; | 270 RegistrationObjectMap registrations_; |
266 | 271 |
267 // A map for ServiceWorkers that are associated to a particular document | 272 // A map for ServiceWorkers that are associated to a particular document |
268 // (e.g. as .current). | 273 // (e.g. as .current). |
269 WorkerToProviderMap worker_to_provider_; | 274 WorkerToProviderMap worker_to_provider_; |
270 | 275 |
271 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 276 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
272 | 277 |
273 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 278 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
274 }; | 279 }; |
275 | 280 |
276 } // namespace content | 281 } // namespace content |
277 | 282 |
278 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 283 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |