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 26 matching lines...) Expand all Loading... | |
37 struct ServiceWorkerRegistrationObjectInfo; | 37 struct ServiceWorkerRegistrationObjectInfo; |
38 struct ServiceWorkerVersionAttributes; | 38 struct ServiceWorkerVersionAttributes; |
39 | 39 |
40 // This class manages communication with the browser process about | 40 // This class manages communication with the browser process about |
41 // registration of the service worker, exposed to renderer and worker | 41 // registration of the service worker, exposed to renderer and worker |
42 // scripts through methods like navigator.registerServiceWorker(). | 42 // scripts through methods like navigator.registerServiceWorker(). |
43 class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { | 43 class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { |
44 public: | 44 public: |
45 typedef blink::WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks | 45 typedef blink::WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks |
46 WebServiceWorkerRegistrationCallbacks; | 46 WebServiceWorkerRegistrationCallbacks; |
47 #ifdef SERVICEWORKER_UNREGISTER_DISABLE_NEW_FEATURE | |
48 typedef WebServiceWorkerRegistrationCallbacks | |
49 WebServiceWorkerUnRegistrationCallbacks; | |
50 #else | |
51 typedef | |
52 blink::WebServiceWorkerProvider::WebServiceWorkerUnRegistrationCallbacks | |
53 WebServiceWorkerUnRegistrationCallbacks; | |
54 #endif | |
nhiroki
2014/08/29 03:20:07
Probably you only need to add line 51-53 because y
| |
47 | 55 |
48 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); | 56 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); |
49 virtual ~ServiceWorkerDispatcher(); | 57 virtual ~ServiceWorkerDispatcher(); |
50 | 58 |
51 void OnMessageReceived(const IPC::Message& msg); | 59 void OnMessageReceived(const IPC::Message& msg); |
52 bool Send(IPC::Message* msg); | 60 bool Send(IPC::Message* msg); |
53 | 61 |
54 // Corresponds to navigator.serviceWorker.register() | 62 // Corresponds to navigator.serviceWorker.register() |
55 void RegisterServiceWorker( | 63 void RegisterServiceWorker( |
56 int provider_id, | 64 int provider_id, |
57 const GURL& pattern, | 65 const GURL& pattern, |
58 const GURL& script_url, | 66 const GURL& script_url, |
59 WebServiceWorkerRegistrationCallbacks* callbacks); | 67 WebServiceWorkerRegistrationCallbacks* callbacks); |
60 // Corresponds to navigator.serviceWorker.unregister() | 68 // Corresponds to navigator.serviceWorker.unregister() |
61 void UnregisterServiceWorker( | 69 void UnregisterServiceWorker( |
62 int provider_id, | 70 int provider_id, |
63 const GURL& pattern, | 71 const GURL& pattern, |
64 WebServiceWorkerRegistrationCallbacks* callbacks); | 72 WebServiceWorkerUnRegistrationCallbacks* callbacks); |
65 | 73 |
66 // Called when a new provider context for a document is created. Usually | 74 // Called when a new provider context for a document is created. Usually |
67 // this happens when a new document is being loaded, and is called much | 75 // this happens when a new document is being loaded, and is called much |
68 // earlier than AddScriptClient. | 76 // earlier than AddScriptClient. |
69 // (This is attached only to the document thread's ServiceWorkerDispatcher) | 77 // (This is attached only to the document thread's ServiceWorkerDispatcher) |
70 void AddProviderContext(ServiceWorkerProviderContext* provider_context); | 78 void AddProviderContext(ServiceWorkerProviderContext* provider_context); |
71 void RemoveProviderContext(ServiceWorkerProviderContext* provider_context); | 79 void RemoveProviderContext(ServiceWorkerProviderContext* provider_context); |
72 | 80 |
73 // Called when navigator.serviceWorker is instantiated or detached | 81 // Called when navigator.serviceWorker is instantiated or detached |
74 // for a document whose provider can be identified by |provider_id|. | 82 // for a document whose provider can be identified by |provider_id|. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 // construction it will be needed. | 114 // construction it will be needed. |
107 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( | 115 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( |
108 ThreadSafeSender* thread_safe_sender); | 116 ThreadSafeSender* thread_safe_sender); |
109 | 117 |
110 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new | 118 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new |
111 // instance if thread-local instance doesn't exist. | 119 // instance if thread-local instance doesn't exist. |
112 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); | 120 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); |
113 | 121 |
114 private: | 122 private: |
115 typedef IDMap<WebServiceWorkerRegistrationCallbacks, | 123 typedef IDMap<WebServiceWorkerRegistrationCallbacks, |
116 IDMapOwnPointer> CallbackMap; | 124 IDMapOwnPointer> RegistrationCallbackMap; |
125 typedef IDMap<WebServiceWorkerUnRegistrationCallbacks, | |
126 IDMapOwnPointer> UnRegistrationCallbackMap; | |
117 typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap; | 127 typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap; |
118 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; | 128 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; |
119 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; | 129 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; |
120 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; | 130 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; |
121 typedef std::map<int, WebServiceWorkerRegistrationImpl*> | 131 typedef std::map<int, WebServiceWorkerRegistrationImpl*> |
122 RegistrationObjectMap; | 132 RegistrationObjectMap; |
123 | 133 |
124 friend class WebServiceWorkerImpl; | 134 friend class WebServiceWorkerImpl; |
125 friend class WebServiceWorkerRegistrationImpl; | 135 friend class WebServiceWorkerRegistrationImpl; |
126 | 136 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker); | 180 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker); |
171 void RemoveServiceWorker(int handle_id); | 181 void RemoveServiceWorker(int handle_id); |
172 | 182 |
173 // Keeps map from registration_handle_id to ServiceWorkerRegistration object. | 183 // Keeps map from registration_handle_id to ServiceWorkerRegistration object. |
174 void AddServiceWorkerRegistration( | 184 void AddServiceWorkerRegistration( |
175 int registration_handle_id, | 185 int registration_handle_id, |
176 WebServiceWorkerRegistrationImpl* registration); | 186 WebServiceWorkerRegistrationImpl* registration); |
177 void RemoveServiceWorkerRegistration( | 187 void RemoveServiceWorkerRegistration( |
178 int registration_handle_id); | 188 int registration_handle_id); |
179 | 189 |
180 CallbackMap pending_callbacks_; | 190 RegistrationCallbackMap pending_registration_callbacks_; |
191 UnRegistrationCallbackMap pending_unregistration_callbacks_; | |
181 ScriptClientMap script_clients_; | 192 ScriptClientMap script_clients_; |
182 ProviderContextMap provider_contexts_; | 193 ProviderContextMap provider_contexts_; |
183 WorkerObjectMap service_workers_; | 194 WorkerObjectMap service_workers_; |
184 RegistrationObjectMap registrations_; | 195 RegistrationObjectMap registrations_; |
185 | 196 |
186 // A map for ServiceWorkers that are associated to a particular document | 197 // A map for ServiceWorkers that are associated to a particular document |
187 // (e.g. as .current). | 198 // (e.g. as .current). |
188 WorkerToProviderMap worker_to_provider_; | 199 WorkerToProviderMap worker_to_provider_; |
189 | 200 |
190 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 201 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
191 | 202 |
192 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 203 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
193 }; | 204 }; |
194 | 205 |
195 } // namespace content | 206 } // namespace content |
196 | 207 |
197 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 208 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |