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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 : public WorkerTaskRunner::Observer { | 45 : public WorkerTaskRunner::Observer { |
46 public: | 46 public: |
47 typedef blink::WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks | 47 typedef blink::WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks |
48 WebServiceWorkerRegistrationCallbacks; | 48 WebServiceWorkerRegistrationCallbacks; |
49 typedef | 49 typedef |
50 blink::WebServiceWorkerProvider::WebServiceWorkerUnregistrationCallbacks | 50 blink::WebServiceWorkerProvider::WebServiceWorkerUnregistrationCallbacks |
51 WebServiceWorkerUnregistrationCallbacks; | 51 WebServiceWorkerUnregistrationCallbacks; |
52 typedef | 52 typedef |
53 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationCallbacks | 53 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationCallbacks |
54 WebServiceWorkerGetRegistrationCallbacks; | 54 WebServiceWorkerGetRegistrationCallbacks; |
| 55 typedef |
| 56 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationsCallbacks |
| 57 WebServiceWorkerGetRegistrationsCallbacks; |
55 typedef blink::WebServiceWorkerProvider:: | 58 typedef blink::WebServiceWorkerProvider:: |
56 WebServiceWorkerGetRegistrationForReadyCallbacks | 59 WebServiceWorkerGetRegistrationForReadyCallbacks |
57 WebServiceWorkerGetRegistrationForReadyCallbacks; | 60 WebServiceWorkerGetRegistrationForReadyCallbacks; |
58 | 61 |
59 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); | 62 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); |
60 ~ServiceWorkerDispatcher() override; | 63 ~ServiceWorkerDispatcher() override; |
61 | 64 |
62 void OnMessageReceived(const IPC::Message& msg); | 65 void OnMessageReceived(const IPC::Message& msg); |
63 bool Send(IPC::Message* msg); | 66 bool Send(IPC::Message* msg); |
64 | 67 |
65 // Corresponds to navigator.serviceWorker.register() | 68 // Corresponds to navigator.serviceWorker.register() |
66 void RegisterServiceWorker( | 69 void RegisterServiceWorker( |
67 int provider_id, | 70 int provider_id, |
68 const GURL& pattern, | 71 const GURL& pattern, |
69 const GURL& script_url, | 72 const GURL& script_url, |
70 WebServiceWorkerRegistrationCallbacks* callbacks); | 73 WebServiceWorkerRegistrationCallbacks* callbacks); |
71 // Corresponds to navigator.serviceWorker.unregister() | 74 // Corresponds to navigator.serviceWorker.unregister() |
72 void UnregisterServiceWorker( | 75 void UnregisterServiceWorker( |
73 int provider_id, | 76 int provider_id, |
74 const GURL& pattern, | 77 const GURL& pattern, |
75 WebServiceWorkerUnregistrationCallbacks* callbacks); | 78 WebServiceWorkerUnregistrationCallbacks* callbacks); |
76 // Corresponds to navigator.serviceWorker.getRegistration() | 79 // Corresponds to navigator.serviceWorker.getRegistration() |
77 void GetRegistration( | 80 void GetRegistration( |
78 int provider_id, | 81 int provider_id, |
79 const GURL& document_url, | 82 const GURL& document_url, |
80 WebServiceWorkerRegistrationCallbacks* callbacks); | 83 WebServiceWorkerRegistrationCallbacks* callbacks); |
| 84 // Corresponds to navigator.serviceWorker.getRegistrations() |
| 85 void GetRegistrations( |
| 86 int provider_id, |
| 87 WebServiceWorkerGetRegistrationsCallbacks* callbacks); |
81 | 88 |
82 void GetRegistrationForReady( | 89 void GetRegistrationForReady( |
83 int provider_id, | 90 int provider_id, |
84 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks); | 91 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks); |
85 | 92 |
86 // Called when a new provider context for a document is created. Usually | 93 // Called when a new provider context for a document is created. Usually |
87 // this happens when a new document is being loaded, and is called much | 94 // this happens when a new document is being loaded, and is called much |
88 // earlier than AddScriptClient. | 95 // earlier than AddScriptClient. |
89 // (This is attached only to the document thread's ServiceWorkerDispatcher) | 96 // (This is attached only to the document thread's ServiceWorkerDispatcher) |
90 void AddProviderContext(ServiceWorkerProviderContext* provider_context); | 97 void AddProviderContext(ServiceWorkerProviderContext* provider_context); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // instance if thread-local instance doesn't exist. | 137 // instance if thread-local instance doesn't exist. |
131 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); | 138 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); |
132 | 139 |
133 private: | 140 private: |
134 typedef IDMap<WebServiceWorkerRegistrationCallbacks, | 141 typedef IDMap<WebServiceWorkerRegistrationCallbacks, |
135 IDMapOwnPointer> RegistrationCallbackMap; | 142 IDMapOwnPointer> RegistrationCallbackMap; |
136 typedef IDMap<WebServiceWorkerUnregistrationCallbacks, | 143 typedef IDMap<WebServiceWorkerUnregistrationCallbacks, |
137 IDMapOwnPointer> UnregistrationCallbackMap; | 144 IDMapOwnPointer> UnregistrationCallbackMap; |
138 typedef IDMap<WebServiceWorkerGetRegistrationCallbacks, | 145 typedef IDMap<WebServiceWorkerGetRegistrationCallbacks, |
139 IDMapOwnPointer> GetRegistrationCallbackMap; | 146 IDMapOwnPointer> GetRegistrationCallbackMap; |
| 147 typedef IDMap<WebServiceWorkerGetRegistrationsCallbacks, |
| 148 IDMapOwnPointer> GetRegistrationsCallbackMap; |
140 typedef IDMap<WebServiceWorkerGetRegistrationForReadyCallbacks, | 149 typedef IDMap<WebServiceWorkerGetRegistrationForReadyCallbacks, |
141 IDMapOwnPointer> GetRegistrationForReadyCallbackMap; | 150 IDMapOwnPointer> GetRegistrationForReadyCallbackMap; |
142 | 151 |
143 typedef std::map<int, blink::WebServiceWorkerProviderClient*> | 152 typedef std::map<int, blink::WebServiceWorkerProviderClient*> |
144 ProviderClientMap; | 153 ProviderClientMap; |
145 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; | 154 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; |
146 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; | 155 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; |
147 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; | 156 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; |
148 typedef std::map<int, WebServiceWorkerRegistrationImpl*> | 157 typedef std::map<int, WebServiceWorkerRegistrationImpl*> |
149 RegistrationObjectMap; | 158 RegistrationObjectMap; |
(...skipping 20 matching lines...) Expand all Loading... |
170 int request_id, | 179 int request_id, |
171 const ServiceWorkerRegistrationObjectInfo& info, | 180 const ServiceWorkerRegistrationObjectInfo& info, |
172 const ServiceWorkerVersionAttributes& attrs); | 181 const ServiceWorkerVersionAttributes& attrs); |
173 void OnUnregistered(int thread_id, | 182 void OnUnregistered(int thread_id, |
174 int request_id, | 183 int request_id, |
175 bool is_success); | 184 bool is_success); |
176 void OnDidGetRegistration(int thread_id, | 185 void OnDidGetRegistration(int thread_id, |
177 int request_id, | 186 int request_id, |
178 const ServiceWorkerRegistrationObjectInfo& info, | 187 const ServiceWorkerRegistrationObjectInfo& info, |
179 const ServiceWorkerVersionAttributes& attrs); | 188 const ServiceWorkerVersionAttributes& attrs); |
| 189 void OnDidGetRegistrations( |
| 190 int thread_id, |
| 191 int request_id, |
| 192 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos, |
| 193 const std::vector<ServiceWorkerVersionAttributes>& attrs); |
180 void OnDidGetRegistrationForReady( | 194 void OnDidGetRegistrationForReady( |
181 int thread_id, | 195 int thread_id, |
182 int request_id, | 196 int request_id, |
183 const ServiceWorkerRegistrationObjectInfo& info, | 197 const ServiceWorkerRegistrationObjectInfo& info, |
184 const ServiceWorkerVersionAttributes& attrs); | 198 const ServiceWorkerVersionAttributes& attrs); |
185 void OnRegistrationError(int thread_id, | 199 void OnRegistrationError(int thread_id, |
186 int request_id, | 200 int request_id, |
187 blink::WebServiceWorkerError::ErrorType error_type, | 201 blink::WebServiceWorkerError::ErrorType error_type, |
188 const base::string16& message); | 202 const base::string16& message); |
189 void OnUnregistrationError(int thread_id, | 203 void OnUnregistrationError(int thread_id, |
190 int request_id, | 204 int request_id, |
191 blink::WebServiceWorkerError::ErrorType error_type, | 205 blink::WebServiceWorkerError::ErrorType error_type, |
192 const base::string16& message); | 206 const base::string16& message); |
193 void OnGetRegistrationError( | 207 void OnGetRegistrationError( |
194 int thread_id, | 208 int thread_id, |
195 int request_id, | 209 int request_id, |
196 blink::WebServiceWorkerError::ErrorType error_type, | 210 blink::WebServiceWorkerError::ErrorType error_type, |
197 const base::string16& message); | 211 const base::string16& message); |
| 212 void OnGetRegistrationsError( |
| 213 int thread_id, |
| 214 int request_id, |
| 215 blink::WebServiceWorkerError::ErrorType error_type, |
| 216 const base::string16& message); |
198 void OnServiceWorkerStateChanged(int thread_id, | 217 void OnServiceWorkerStateChanged(int thread_id, |
199 int handle_id, | 218 int handle_id, |
200 blink::WebServiceWorkerState state); | 219 blink::WebServiceWorkerState state); |
201 void OnSetVersionAttributes(int thread_id, | 220 void OnSetVersionAttributes(int thread_id, |
202 int provider_id, | 221 int provider_id, |
203 int registration_handle_id, | 222 int registration_handle_id, |
204 int changed_mask, | 223 int changed_mask, |
205 const ServiceWorkerVersionAttributes& attributes); | 224 const ServiceWorkerVersionAttributes& attributes); |
206 void OnUpdateFound(int thread_id, | 225 void OnUpdateFound(int thread_id, |
207 int registration_handle_id); | 226 int registration_handle_id); |
(...skipping 24 matching lines...) Expand all Loading... |
232 // references and always adopts them. | 251 // references and always adopts them. |
233 // TODO(nhiroki): This assumption seems to impair readability. We could | 252 // TODO(nhiroki): This assumption seems to impair readability. We could |
234 // explictly pass ServiceWorker(Registration)HandleReference instead. | 253 // explictly pass ServiceWorker(Registration)HandleReference instead. |
235 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration( | 254 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration( |
236 const ServiceWorkerRegistrationObjectInfo& info, | 255 const ServiceWorkerRegistrationObjectInfo& info, |
237 const ServiceWorkerVersionAttributes& attrs); | 256 const ServiceWorkerVersionAttributes& attrs); |
238 | 257 |
239 RegistrationCallbackMap pending_registration_callbacks_; | 258 RegistrationCallbackMap pending_registration_callbacks_; |
240 UnregistrationCallbackMap pending_unregistration_callbacks_; | 259 UnregistrationCallbackMap pending_unregistration_callbacks_; |
241 GetRegistrationCallbackMap pending_get_registration_callbacks_; | 260 GetRegistrationCallbackMap pending_get_registration_callbacks_; |
| 261 GetRegistrationsCallbackMap pending_get_registrations_callbacks_; |
242 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; | 262 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; |
243 | 263 |
244 ProviderClientMap provider_clients_; | 264 ProviderClientMap provider_clients_; |
245 ProviderContextMap provider_contexts_; | 265 ProviderContextMap provider_contexts_; |
246 | 266 |
247 WorkerObjectMap service_workers_; | 267 WorkerObjectMap service_workers_; |
248 RegistrationObjectMap registrations_; | 268 RegistrationObjectMap registrations_; |
249 | 269 |
250 // A map for ServiceWorkers that are associated to a particular document | 270 // A map for ServiceWorkers that are associated to a particular document |
251 // (e.g. as .current). | 271 // (e.g. as .current). |
252 WorkerToProviderMap worker_to_provider_; | 272 WorkerToProviderMap worker_to_provider_; |
253 | 273 |
254 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 274 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
255 | 275 |
256 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 276 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
257 }; | 277 }; |
258 | 278 |
259 } // namespace content | 279 } // namespace content |
260 | 280 |
261 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 281 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |