| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // method can return an existing WebServiceWorkerImpl, in which case | 105 // method can return an existing WebServiceWorkerImpl, in which case |
| 106 // it is owned by a WebCore::ServiceWorker and the lifetime is not | 106 // it is owned by a WebCore::ServiceWorker and the lifetime is not |
| 107 // being transferred to the owner; or it can create a | 107 // being transferred to the owner; or it can create a |
| 108 // WebServiceWorkerImpl, in which case ownership is transferred to | 108 // WebServiceWorkerImpl, in which case ownership is transferred to |
| 109 // the caller who must bounce it to a method that will associate it | 109 // the caller who must bounce it to a method that will associate it |
| 110 // with a WebCore::ServiceWorker. | 110 // with a WebCore::ServiceWorker. |
| 111 WebServiceWorkerImpl* GetServiceWorker( | 111 WebServiceWorkerImpl* GetServiceWorker( |
| 112 const ServiceWorkerObjectInfo& info, | 112 const ServiceWorkerObjectInfo& info, |
| 113 bool adopt_handle); | 113 bool adopt_handle); |
| 114 | 114 |
| 115 // Finds a WebServiceWorkerRegistrationImpl for the specified registration. | |
| 116 // If it's not found, returns NULL. If |adopt_handle| is true, | |
| 117 // a ServiceWorkerRegistrationHandleReference will be adopted for the | |
| 118 // registration. | |
| 119 WebServiceWorkerRegistrationImpl* FindServiceWorkerRegistration( | |
| 120 const ServiceWorkerRegistrationObjectInfo& info, | |
| 121 bool adopt_handle); | |
| 122 | |
| 123 // Creates a WebServiceWorkerRegistrationImpl for the specified registration | 115 // Creates a WebServiceWorkerRegistrationImpl for the specified registration |
| 124 // and transfers its ownership to the caller. If |adopt_handle| is true, a | 116 // and transfers its ownership to the caller. If |adopt_handle| is true, a |
| 125 // ServiceWorkerRegistrationHandleReference will be adopted for the | 117 // ServiceWorkerRegistrationHandleReference will be adopted for the |
| 126 // registration. | 118 // registration. |
| 127 WebServiceWorkerRegistrationImpl* CreateServiceWorkerRegistration( | 119 WebServiceWorkerRegistrationImpl* CreateServiceWorkerRegistration( |
| 128 const ServiceWorkerRegistrationObjectInfo& info, | 120 const ServiceWorkerRegistrationObjectInfo& info, |
| 129 bool adopt_handle); | 121 bool adopt_handle); |
| 130 | 122 |
| 131 // |sender| needs to be passed in because if the call leads to construction | 123 // |sender| needs to be passed in because if the call leads to construction |
| 132 // it will be needed. | 124 // it will be needed. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker); | 219 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker); |
| 228 void RemoveServiceWorker(int handle_id); | 220 void RemoveServiceWorker(int handle_id); |
| 229 | 221 |
| 230 // Keeps map from registration_handle_id to ServiceWorkerRegistration object. | 222 // Keeps map from registration_handle_id to ServiceWorkerRegistration object. |
| 231 void AddServiceWorkerRegistration( | 223 void AddServiceWorkerRegistration( |
| 232 int registration_handle_id, | 224 int registration_handle_id, |
| 233 WebServiceWorkerRegistrationImpl* registration); | 225 WebServiceWorkerRegistrationImpl* registration); |
| 234 void RemoveServiceWorkerRegistration( | 226 void RemoveServiceWorkerRegistration( |
| 235 int registration_handle_id); | 227 int registration_handle_id); |
| 236 | 228 |
| 229 // Returns an existing registration or new one filled in with version |
| 230 // attributes. This function assumes given |info| and |attrs| retain handle |
| 231 // references and always adopts them. |
| 232 // TODO(nhiroki): This assumption seems to impair readability. We could |
| 233 // explictly pass ServiceWorker(Registration)HandleReference instead. |
| 237 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration( | 234 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration( |
| 238 const ServiceWorkerRegistrationObjectInfo& info, | 235 const ServiceWorkerRegistrationObjectInfo& info, |
| 239 const ServiceWorkerVersionAttributes& attrs); | 236 const ServiceWorkerVersionAttributes& attrs); |
| 240 | 237 |
| 241 RegistrationCallbackMap pending_registration_callbacks_; | 238 RegistrationCallbackMap pending_registration_callbacks_; |
| 242 UnregistrationCallbackMap pending_unregistration_callbacks_; | 239 UnregistrationCallbackMap pending_unregistration_callbacks_; |
| 243 GetRegistrationCallbackMap pending_get_registration_callbacks_; | 240 GetRegistrationCallbackMap pending_get_registration_callbacks_; |
| 244 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; | 241 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; |
| 245 | 242 |
| 246 ProviderClientMap provider_clients_; | 243 ProviderClientMap provider_clients_; |
| 247 ProviderContextMap provider_contexts_; | 244 ProviderContextMap provider_contexts_; |
| 248 | 245 |
| 249 WorkerObjectMap service_workers_; | 246 WorkerObjectMap service_workers_; |
| 250 RegistrationObjectMap registrations_; | 247 RegistrationObjectMap registrations_; |
| 251 | 248 |
| 252 // A map for ServiceWorkers that are associated to a particular document | 249 // A map for ServiceWorkers that are associated to a particular document |
| 253 // (e.g. as .current). | 250 // (e.g. as .current). |
| 254 WorkerToProviderMap worker_to_provider_; | 251 WorkerToProviderMap worker_to_provider_; |
| 255 | 252 |
| 256 scoped_refptr<ServiceWorkerMessageSender> sender_; | 253 scoped_refptr<ServiceWorkerMessageSender> sender_; |
| 257 | 254 |
| 258 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 255 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
| 259 }; | 256 }; |
| 260 | 257 |
| 261 } // namespace content | 258 } // namespace content |
| 262 | 259 |
| 263 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 260 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
| OLD | NEW |