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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // method can return an existing WebServiceWorkerImpl, in which case | 89 // method can return an existing WebServiceWorkerImpl, in which case |
90 // it is owned by a WebCore::ServiceWorker and the lifetime is not | 90 // it is owned by a WebCore::ServiceWorker and the lifetime is not |
91 // being transferred to the owner; or it can create a | 91 // being transferred to the owner; or it can create a |
92 // WebServiceWorkerImpl, in which case ownership is transferred to | 92 // WebServiceWorkerImpl, in which case ownership is transferred to |
93 // the caller who must bounce it to a method that will associate it | 93 // the caller who must bounce it to a method that will associate it |
94 // with a WebCore::ServiceWorker. | 94 // with a WebCore::ServiceWorker. |
95 WebServiceWorkerImpl* GetServiceWorker( | 95 WebServiceWorkerImpl* GetServiceWorker( |
96 const ServiceWorkerObjectInfo& info, | 96 const ServiceWorkerObjectInfo& info, |
97 bool adopt_handle); | 97 bool adopt_handle); |
98 | 98 |
99 // If an existing WebServiceWorkerRegistrationImpl exists for the | 99 // Finds a WebServiceWorkerRegistrationImpl for the specified registration. |
100 // registration, it is returned; otherwise a WebServiceWorkerRegistrationImpl | 100 // If it's not found, returns NULL. If |adopt_handle| is true, |
101 // is created and its ownership is transferred to the caller. If | 101 // a ServiceWorkerRegistrationHandleReference will be adopted for the |
102 // |adopt_handle| is true, a ServiceWorkerRegistrationHandleReference will be | 102 // registration. |
103 // adopted for the specified registration. | 103 WebServiceWorkerRegistrationImpl* FindServiceWorkerRegistration( |
104 WebServiceWorkerRegistrationImpl* GetServiceWorkerRegistration( | |
105 const ServiceWorkerRegistrationObjectInfo& info, | 104 const ServiceWorkerRegistrationObjectInfo& info, |
106 bool adopt_handle); | 105 bool adopt_handle); |
107 | 106 |
| 107 // Creates a WebServiceWorkerRegistrationImpl for the specified registration |
| 108 // and transfers its ownership to the caller. If |adopt_handle| is true, a |
| 109 // ServiceWorkerRegistrationHandleReference will be adopted for the |
| 110 // registration. |
| 111 WebServiceWorkerRegistrationImpl* CreateServiceWorkerRegistration( |
| 112 const ServiceWorkerRegistrationObjectInfo& info, |
| 113 bool adopt_handle); |
| 114 |
108 // |thread_safe_sender| needs to be passed in because if the call leads to | 115 // |thread_safe_sender| needs to be passed in because if the call leads to |
109 // construction it will be needed. | 116 // construction it will be needed. |
110 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( | 117 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( |
111 ThreadSafeSender* thread_safe_sender); | 118 ThreadSafeSender* thread_safe_sender); |
112 | 119 |
113 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new | 120 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new |
114 // instance if thread-local instance doesn't exist. | 121 // instance if thread-local instance doesn't exist. |
115 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); | 122 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); |
116 | 123 |
117 private: | 124 private: |
118 typedef IDMap<WebServiceWorkerRegistrationCallbacks, | 125 typedef IDMap<WebServiceWorkerRegistrationCallbacks, |
119 IDMapOwnPointer> RegistrationCallbackMap; | 126 IDMapOwnPointer> RegistrationCallbackMap; |
120 typedef IDMap<WebServiceWorkerUnregistrationCallbacks, | 127 typedef IDMap<WebServiceWorkerUnregistrationCallbacks, |
121 IDMapOwnPointer> UnregistrationCallbackMap; | 128 IDMapOwnPointer> UnregistrationCallbackMap; |
122 typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap; | 129 typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap; |
123 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; | 130 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; |
124 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; | 131 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; |
125 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; | 132 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; |
126 typedef std::map<int, WebServiceWorkerRegistrationImpl*> | 133 typedef std::map<int, WebServiceWorkerRegistrationImpl*> |
127 RegistrationObjectMap; | 134 RegistrationObjectMap; |
128 | 135 |
129 friend class WebServiceWorkerImpl; | 136 friend class WebServiceWorkerImpl; |
130 friend class WebServiceWorkerRegistrationImpl; | 137 friend class WebServiceWorkerRegistrationImpl; |
131 | 138 |
132 // WorkerTaskRunner::Observer implementation. | 139 // WorkerTaskRunner::Observer implementation. |
133 virtual void OnWorkerRunLoopStopped() OVERRIDE; | 140 virtual void OnWorkerRunLoopStopped() OVERRIDE; |
134 | 141 |
| 142 void OnAssociateRegistration(int thread_id, |
| 143 int provider_id, |
| 144 const ServiceWorkerRegistrationObjectInfo& info, |
| 145 const ServiceWorkerVersionAttributes& attrs); |
| 146 void OnDisassociateRegistration(int thread_id, |
| 147 int provider_id); |
135 void OnRegistered(int thread_id, | 148 void OnRegistered(int thread_id, |
136 int request_id, | 149 int request_id, |
137 const ServiceWorkerRegistrationObjectInfo& info, | 150 const ServiceWorkerRegistrationObjectInfo& info, |
138 const ServiceWorkerVersionAttributes& attrs); | 151 const ServiceWorkerVersionAttributes& attrs); |
139 void OnUnregistered(int thread_id, | 152 void OnUnregistered(int thread_id, |
140 int request_id); | 153 int request_id); |
141 void OnRegistrationError(int thread_id, | 154 void OnRegistrationError(int thread_id, |
142 int request_id, | 155 int request_id, |
143 blink::WebServiceWorkerError::ErrorType error_type, | 156 blink::WebServiceWorkerError::ErrorType error_type, |
144 const base::string16& message); | 157 const base::string16& message); |
(...skipping 25 matching lines...) Expand all Loading... |
170 int registration_handle_id, | 183 int registration_handle_id, |
171 const ServiceWorkerObjectInfo& info); | 184 const ServiceWorkerObjectInfo& info); |
172 void SetWaitingServiceWorker( | 185 void SetWaitingServiceWorker( |
173 int provider_id, | 186 int provider_id, |
174 int registration_handle_id, | 187 int registration_handle_id, |
175 const ServiceWorkerObjectInfo& info); | 188 const ServiceWorkerObjectInfo& info); |
176 void SetActiveServiceWorker( | 189 void SetActiveServiceWorker( |
177 int provider_id, | 190 int provider_id, |
178 int registration_handle_id, | 191 int registration_handle_id, |
179 const ServiceWorkerObjectInfo& info); | 192 const ServiceWorkerObjectInfo& info); |
| 193 void SetReadyRegistration( |
| 194 int provider_id, |
| 195 int registration_handle_id); |
180 | 196 |
181 // Keeps map from handle_id to ServiceWorker object. | 197 // Keeps map from handle_id to ServiceWorker object. |
182 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker); | 198 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker); |
183 void RemoveServiceWorker(int handle_id); | 199 void RemoveServiceWorker(int handle_id); |
184 | 200 |
185 // Keeps map from registration_handle_id to ServiceWorkerRegistration object. | 201 // Keeps map from registration_handle_id to ServiceWorkerRegistration object. |
186 void AddServiceWorkerRegistration( | 202 void AddServiceWorkerRegistration( |
187 int registration_handle_id, | 203 int registration_handle_id, |
188 WebServiceWorkerRegistrationImpl* registration); | 204 WebServiceWorkerRegistrationImpl* registration); |
189 void RemoveServiceWorkerRegistration( | 205 void RemoveServiceWorkerRegistration( |
(...skipping 11 matching lines...) Expand all Loading... |
201 WorkerToProviderMap worker_to_provider_; | 217 WorkerToProviderMap worker_to_provider_; |
202 | 218 |
203 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 219 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
204 | 220 |
205 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 221 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
206 }; | 222 }; |
207 | 223 |
208 } // namespace content | 224 } // namespace content |
209 | 225 |
210 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 226 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |