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 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 | 30 |
31 class ServiceWorkerMessageFilter; | 31 class ServiceWorkerMessageFilter; |
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 ServiceWorkerVersionAttributes; | 38 struct ServiceWorkerVersionAttributes; |
38 | 39 |
39 // This class manages communication with the browser process about | 40 // This class manages communication with the browser process about |
40 // registration of the service worker, exposed to renderer and worker | 41 // registration of the service worker, exposed to renderer and worker |
41 // scripts through methods like navigator.registerServiceWorker(). | 42 // scripts through methods like navigator.registerServiceWorker(). |
42 class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { | 43 class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { |
43 public: | 44 public: |
44 typedef blink::WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks | 45 typedef blink::WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks |
45 WebServiceWorkerRegistrationCallbacks; | 46 WebServiceWorkerRegistrationCallbacks; |
46 | 47 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 WebServiceWorkerImpl* GetServiceWorker( | 92 WebServiceWorkerImpl* GetServiceWorker( |
92 const ServiceWorkerObjectInfo& info, | 93 const ServiceWorkerObjectInfo& info, |
93 bool adopt_handle); | 94 bool adopt_handle); |
94 | 95 |
95 // If an existing WebServiceWorkerRegistrationImpl exists for the | 96 // If an existing WebServiceWorkerRegistrationImpl exists for the |
96 // registration, it is returned; otherwise a WebServiceWorkerRegistrationImpl | 97 // registration, it is returned; otherwise a WebServiceWorkerRegistrationImpl |
97 // is created and its ownership is transferred to the caller. If | 98 // is created and its ownership is transferred to the caller. If |
98 // |adopt_handle| is true, a ServiceWorkerRegistrationHandleReference will be | 99 // |adopt_handle| is true, a ServiceWorkerRegistrationHandleReference will be |
99 // adopted for the specified registration. | 100 // adopted for the specified registration. |
100 WebServiceWorkerRegistrationImpl* GetServiceWorkerRegistration( | 101 WebServiceWorkerRegistrationImpl* GetServiceWorkerRegistration( |
101 int registration_handle_id, | 102 const ServiceWorkerRegistrationObjectInfo& info, |
102 const ServiceWorkerObjectInfo& info, | |
103 bool adopt_handle); | 103 bool adopt_handle); |
104 | 104 |
105 // |thread_safe_sender| needs to be passed in because if the call leads to | 105 // |thread_safe_sender| needs to be passed in because if the call leads to |
106 // construction it will be needed. | 106 // construction it will be needed. |
107 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( | 107 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( |
108 ThreadSafeSender* thread_safe_sender); | 108 ThreadSafeSender* thread_safe_sender); |
109 | 109 |
110 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new | 110 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new |
111 // instance if thread-local instance doesn't exist. | 111 // instance if thread-local instance doesn't exist. |
112 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); | 112 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); |
113 | 113 |
114 private: | 114 private: |
115 typedef IDMap<WebServiceWorkerRegistrationCallbacks, | 115 typedef IDMap<WebServiceWorkerRegistrationCallbacks, |
116 IDMapOwnPointer> CallbackMap; | 116 IDMapOwnPointer> CallbackMap; |
117 typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap; | 117 typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap; |
118 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; | 118 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; |
119 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; | 119 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; |
120 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; | 120 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; |
121 typedef std::map<int, WebServiceWorkerRegistrationImpl*> | 121 typedef std::map<int, WebServiceWorkerRegistrationImpl*> |
122 RegistrationObjectMap; | 122 RegistrationObjectMap; |
123 | 123 |
124 friend class WebServiceWorkerImpl; | 124 friend class WebServiceWorkerImpl; |
125 friend class WebServiceWorkerRegistrationImpl; | 125 friend class WebServiceWorkerRegistrationImpl; |
126 | 126 |
127 // WorkerTaskRunner::Observer implementation. | 127 // WorkerTaskRunner::Observer implementation. |
128 virtual void OnWorkerRunLoopStopped() OVERRIDE; | 128 virtual void OnWorkerRunLoopStopped() OVERRIDE; |
129 | 129 |
130 void OnRegistered(int thread_id, | 130 void OnRegistered(int thread_id, |
131 int request_id, | 131 int request_id, |
132 int registration_handle_id, | 132 const ServiceWorkerRegistrationObjectInfo& info); |
133 const ServiceWorkerObjectInfo& info); | |
134 void OnUnregistered(int thread_id, | 133 void OnUnregistered(int thread_id, |
135 int request_id); | 134 int request_id); |
136 void OnRegistrationError(int thread_id, | 135 void OnRegistrationError(int thread_id, |
137 int request_id, | 136 int request_id, |
138 blink::WebServiceWorkerError::ErrorType error_type, | 137 blink::WebServiceWorkerError::ErrorType error_type, |
139 const base::string16& message); | 138 const base::string16& message); |
140 void OnServiceWorkerStateChanged(int thread_id, | 139 void OnServiceWorkerStateChanged(int thread_id, |
141 int handle_id, | 140 int handle_id, |
142 blink::WebServiceWorkerState state); | 141 blink::WebServiceWorkerState state); |
143 void OnSetVersionAttributes(int thread_id, | 142 void OnSetVersionAttributes(int thread_id, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 WorkerToProviderMap worker_to_provider_; | 188 WorkerToProviderMap worker_to_provider_; |
190 | 189 |
191 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 190 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
192 | 191 |
193 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 192 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
194 }; | 193 }; |
195 | 194 |
196 } // namespace content | 195 } // namespace content |
197 | 196 |
198 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 197 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |