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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 // method can return an existing WebServiceWorkerImpl, in which case | 127 // method can return an existing WebServiceWorkerImpl, in which case |
128 // it is owned by a WebCore::ServiceWorker and the lifetime is not | 128 // it is owned by a WebCore::ServiceWorker and the lifetime is not |
129 // being transferred to the owner; or it can create a | 129 // being transferred to the owner; or it can create a |
130 // WebServiceWorkerImpl, in which case ownership is transferred to | 130 // WebServiceWorkerImpl, in which case ownership is transferred to |
131 // the caller who must bounce it to a method that will associate it | 131 // the caller who must bounce it to a method that will associate it |
132 // with a WebCore::ServiceWorker. | 132 // with a WebCore::ServiceWorker. |
133 WebServiceWorkerImpl* GetServiceWorker( | 133 WebServiceWorkerImpl* GetServiceWorker( |
134 const ServiceWorkerObjectInfo& info, | 134 const ServiceWorkerObjectInfo& info, |
135 bool adopt_handle); | 135 bool adopt_handle); |
136 | 136 |
137 // Creates a WebServiceWorkerRegistrationImpl for the specified registration | 137 // Returns a new registration filled in with version attributes. If |
138 // and transfers its ownership to the caller. If |adopt_handle| is true, a | 138 // |adopt_handle| is true, this assumes given |info| and |attrs| retain handle |
139 // ServiceWorkerRegistrationHandleReference will be adopted for the | 139 // references and adopts them. |
140 // registration. | 140 scoped_ptr<WebServiceWorkerRegistrationImpl> CreateRegistration( |
falken
2015/08/25 03:26:45
Have you considered splitting this into CreateRegi
nhiroki
2015/08/25 05:40:53
Good. Done. I'll do the same cleanup for GetServic
| |
141 WebServiceWorkerRegistrationImpl* CreateServiceWorkerRegistration( | |
142 const ServiceWorkerRegistrationObjectInfo& info, | 141 const ServiceWorkerRegistrationObjectInfo& info, |
142 const ServiceWorkerVersionAttributes& attrs, | |
143 bool adopt_handle); | 143 bool adopt_handle); |
144 | 144 |
145 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( | 145 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( |
146 ThreadSafeSender* thread_safe_sender, | 146 ThreadSafeSender* thread_safe_sender, |
147 base::SingleThreadTaskRunner* main_thread_task_runner); | 147 base::SingleThreadTaskRunner* main_thread_task_runner); |
148 | 148 |
149 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new | 149 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new |
150 // instance if thread-local instance doesn't exist. | 150 // instance if thread-local instance doesn't exist. |
151 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); | 151 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); |
152 | 152 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker); | 258 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker); |
259 void RemoveServiceWorker(int handle_id); | 259 void RemoveServiceWorker(int handle_id); |
260 | 260 |
261 // Keeps map from registration_handle_id to ServiceWorkerRegistration object. | 261 // Keeps map from registration_handle_id to ServiceWorkerRegistration object. |
262 void AddServiceWorkerRegistration( | 262 void AddServiceWorkerRegistration( |
263 int registration_handle_id, | 263 int registration_handle_id, |
264 WebServiceWorkerRegistrationImpl* registration); | 264 WebServiceWorkerRegistrationImpl* registration); |
265 void RemoveServiceWorkerRegistration( | 265 void RemoveServiceWorkerRegistration( |
266 int registration_handle_id); | 266 int registration_handle_id); |
267 | 267 |
268 // Returns an existing registration or new one filled in with version | |
269 // attributes. This function assumes given |info| and |attrs| retain handle | |
270 // references and always adopts them. | |
271 // TODO(nhiroki): This assumption seems to impair readability. We could | |
272 // explictly pass ServiceWorker(Registration)HandleReference instead. | |
273 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration( | |
274 const ServiceWorkerRegistrationObjectInfo& info, | |
275 const ServiceWorkerVersionAttributes& attrs); | |
276 | |
277 RegistrationCallbackMap pending_registration_callbacks_; | 268 RegistrationCallbackMap pending_registration_callbacks_; |
278 UpdateCallbackMap pending_update_callbacks_; | 269 UpdateCallbackMap pending_update_callbacks_; |
279 UnregistrationCallbackMap pending_unregistration_callbacks_; | 270 UnregistrationCallbackMap pending_unregistration_callbacks_; |
280 GetRegistrationCallbackMap pending_get_registration_callbacks_; | 271 GetRegistrationCallbackMap pending_get_registration_callbacks_; |
281 GetRegistrationsCallbackMap pending_get_registrations_callbacks_; | 272 GetRegistrationsCallbackMap pending_get_registrations_callbacks_; |
282 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; | 273 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; |
283 | 274 |
284 ProviderClientMap provider_clients_; | 275 ProviderClientMap provider_clients_; |
285 ProviderContextMap provider_contexts_; | 276 ProviderContextMap provider_contexts_; |
286 | 277 |
287 WorkerObjectMap service_workers_; | 278 WorkerObjectMap service_workers_; |
288 RegistrationObjectMap registrations_; | 279 RegistrationObjectMap registrations_; |
289 | 280 |
290 // A map for ServiceWorkers that are associated to a particular document | 281 // A map for ServiceWorkers that are associated to a particular document |
291 // (e.g. as .current). | 282 // (e.g. as .current). |
292 WorkerToProviderMap worker_to_provider_; | 283 WorkerToProviderMap worker_to_provider_; |
293 | 284 |
294 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 285 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
295 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 286 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
296 | 287 |
297 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 288 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
298 }; | 289 }; |
299 | 290 |
300 } // namespace content | 291 } // namespace content |
301 | 292 |
302 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 293 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |