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 10 matching lines...) Expand all Loading... |
21 namespace blink { | 21 namespace blink { |
22 class WebURL; | 22 class WebURL; |
23 } | 23 } |
24 | 24 |
25 namespace IPC { | 25 namespace IPC { |
26 class Message; | 26 class Message; |
27 } | 27 } |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 | 30 |
31 class ServiceWorkerMessageFilter; | 31 class ServiceWorkerMessageSender; |
32 class ServiceWorkerProviderContext; | 32 class ServiceWorkerProviderContext; |
33 class ThreadSafeSender; | 33 class ThreadSafeSender; |
34 class WebServiceWorkerImpl; | 34 class WebServiceWorkerImpl; |
35 class WebServiceWorkerRegistrationImpl; | 35 class WebServiceWorkerRegistrationImpl; |
36 struct ServiceWorkerObjectInfo; | 36 struct ServiceWorkerObjectInfo; |
37 struct ServiceWorkerRegistrationObjectInfo; | 37 struct ServiceWorkerRegistrationObjectInfo; |
38 struct ServiceWorkerVersionAttributes; | 38 struct ServiceWorkerVersionAttributes; |
39 struct TransferredMessagePort; | 39 struct TransferredMessagePort; |
40 | 40 |
41 // This class manages communication with the browser process about | 41 // This class manages communication with the browser process about |
42 // registration of the service worker, exposed to renderer and worker | 42 // registration of the service worker, exposed to renderer and worker |
43 // scripts through methods like navigator.registerServiceWorker(). | 43 // scripts through methods like navigator.registerServiceWorker(). |
44 class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { | 44 class CONTENT_EXPORT ServiceWorkerDispatcher |
| 45 : public WorkerTaskRunner::Observer { |
45 public: | 46 public: |
46 typedef blink::WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks | 47 typedef blink::WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks |
47 WebServiceWorkerRegistrationCallbacks; | 48 WebServiceWorkerRegistrationCallbacks; |
48 typedef | 49 typedef |
49 blink::WebServiceWorkerProvider::WebServiceWorkerUnregistrationCallbacks | 50 blink::WebServiceWorkerProvider::WebServiceWorkerUnregistrationCallbacks |
50 WebServiceWorkerUnregistrationCallbacks; | 51 WebServiceWorkerUnregistrationCallbacks; |
51 typedef | 52 typedef |
52 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationCallbacks | 53 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationCallbacks |
53 WebServiceWorkerGetRegistrationCallbacks; | 54 WebServiceWorkerGetRegistrationCallbacks; |
54 typedef blink::WebServiceWorkerProvider:: | 55 typedef blink::WebServiceWorkerProvider:: |
55 WebServiceWorkerGetRegistrationForReadyCallbacks | 56 WebServiceWorkerGetRegistrationForReadyCallbacks |
56 WebServiceWorkerGetRegistrationForReadyCallbacks; | 57 WebServiceWorkerGetRegistrationForReadyCallbacks; |
57 | 58 |
58 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); | 59 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); |
| 60 explicit ServiceWorkerDispatcher(ServiceWorkerMessageSender* sender); |
59 ~ServiceWorkerDispatcher() override; | 61 ~ServiceWorkerDispatcher() override; |
60 | 62 |
61 void OnMessageReceived(const IPC::Message& msg); | 63 void OnMessageReceived(const IPC::Message& msg); |
62 bool Send(IPC::Message* msg); | |
63 | 64 |
64 // Corresponds to navigator.serviceWorker.register() | 65 // Corresponds to navigator.serviceWorker.register() |
65 void RegisterServiceWorker( | 66 void RegisterServiceWorker( |
66 int provider_id, | 67 int provider_id, |
67 const GURL& pattern, | 68 const GURL& pattern, |
68 const GURL& script_url, | 69 const GURL& script_url, |
69 WebServiceWorkerRegistrationCallbacks* callbacks); | 70 WebServiceWorkerRegistrationCallbacks* callbacks); |
70 // Corresponds to navigator.serviceWorker.unregister() | 71 // Corresponds to navigator.serviceWorker.unregister() |
71 void UnregisterServiceWorker( | 72 void UnregisterServiceWorker( |
72 int provider_id, | 73 int provider_id, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 IDMapOwnPointer> GetRegistrationForReadyCallbackMap; | 149 IDMapOwnPointer> GetRegistrationForReadyCallbackMap; |
149 | 150 |
150 typedef std::map<int, blink::WebServiceWorkerProviderClient*> | 151 typedef std::map<int, blink::WebServiceWorkerProviderClient*> |
151 ProviderClientMap; | 152 ProviderClientMap; |
152 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; | 153 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; |
153 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; | 154 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; |
154 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; | 155 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; |
155 typedef std::map<int, WebServiceWorkerRegistrationImpl*> | 156 typedef std::map<int, WebServiceWorkerRegistrationImpl*> |
156 RegistrationObjectMap; | 157 RegistrationObjectMap; |
157 | 158 |
| 159 friend class ServiceWorkerDispatcherTest; |
158 friend class WebServiceWorkerImpl; | 160 friend class WebServiceWorkerImpl; |
159 friend class WebServiceWorkerRegistrationImpl; | 161 friend class WebServiceWorkerRegistrationImpl; |
160 | 162 |
161 // WorkerTaskRunner::Observer implementation. | 163 // WorkerTaskRunner::Observer implementation. |
162 void OnWorkerRunLoopStopped() override; | 164 void OnWorkerRunLoopStopped() override; |
163 | 165 |
164 void OnAssociateRegistrationWithServiceWorker( | 166 void OnAssociateRegistrationWithServiceWorker( |
165 int thread_id, | 167 int thread_id, |
166 int provider_id, | 168 int provider_id, |
167 const ServiceWorkerRegistrationObjectInfo& info, | 169 const ServiceWorkerRegistrationObjectInfo& info, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 ProviderClientMap provider_clients_; | 247 ProviderClientMap provider_clients_; |
246 ProviderContextMap provider_contexts_; | 248 ProviderContextMap provider_contexts_; |
247 | 249 |
248 WorkerObjectMap service_workers_; | 250 WorkerObjectMap service_workers_; |
249 RegistrationObjectMap registrations_; | 251 RegistrationObjectMap registrations_; |
250 | 252 |
251 // A map for ServiceWorkers that are associated to a particular document | 253 // A map for ServiceWorkers that are associated to a particular document |
252 // (e.g. as .current). | 254 // (e.g. as .current). |
253 WorkerToProviderMap worker_to_provider_; | 255 WorkerToProviderMap worker_to_provider_; |
254 | 256 |
255 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 257 scoped_refptr<ServiceWorkerMessageSender> sender_; |
256 | 258 |
257 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 259 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
258 }; | 260 }; |
259 | 261 |
260 } // namespace content | 262 } // namespace content |
261 | 263 |
262 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 264 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |