Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.h

Issue 1146913004: Service Worker: Add ServiceWorkerContainer.getRegistrations() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 const GURL& document_url,
88 WebServiceWorkerGetRegistrationsCallbacks* callbacks);
81 89
82 void GetRegistrationForReady( 90 void GetRegistrationForReady(
83 int provider_id, 91 int provider_id,
84 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks); 92 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks);
85 93
86 // Called when a new provider context for a document is created. Usually 94 // 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 95 // this happens when a new document is being loaded, and is called much
88 // earlier than AddScriptClient. 96 // earlier than AddScriptClient.
89 // (This is attached only to the document thread's ServiceWorkerDispatcher) 97 // (This is attached only to the document thread's ServiceWorkerDispatcher)
90 void AddProviderContext(ServiceWorkerProviderContext* provider_context); 98 void AddProviderContext(ServiceWorkerProviderContext* provider_context);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // instance if thread-local instance doesn't exist. 138 // instance if thread-local instance doesn't exist.
131 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); 139 static ServiceWorkerDispatcher* GetThreadSpecificInstance();
132 140
133 private: 141 private:
134 typedef IDMap<WebServiceWorkerRegistrationCallbacks, 142 typedef IDMap<WebServiceWorkerRegistrationCallbacks,
135 IDMapOwnPointer> RegistrationCallbackMap; 143 IDMapOwnPointer> RegistrationCallbackMap;
136 typedef IDMap<WebServiceWorkerUnregistrationCallbacks, 144 typedef IDMap<WebServiceWorkerUnregistrationCallbacks,
137 IDMapOwnPointer> UnregistrationCallbackMap; 145 IDMapOwnPointer> UnregistrationCallbackMap;
138 typedef IDMap<WebServiceWorkerGetRegistrationCallbacks, 146 typedef IDMap<WebServiceWorkerGetRegistrationCallbacks,
139 IDMapOwnPointer> GetRegistrationCallbackMap; 147 IDMapOwnPointer> GetRegistrationCallbackMap;
148 typedef IDMap<WebServiceWorkerGetRegistrationsCallbacks,
149 IDMapOwnPointer> GetRegistrationsCallbackMap;
140 typedef IDMap<WebServiceWorkerGetRegistrationForReadyCallbacks, 150 typedef IDMap<WebServiceWorkerGetRegistrationForReadyCallbacks,
141 IDMapOwnPointer> GetRegistrationForReadyCallbackMap; 151 IDMapOwnPointer> GetRegistrationForReadyCallbackMap;
142 152
143 typedef std::map<int, blink::WebServiceWorkerProviderClient*> 153 typedef std::map<int, blink::WebServiceWorkerProviderClient*>
144 ProviderClientMap; 154 ProviderClientMap;
145 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; 155 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap;
146 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; 156 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap;
147 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; 157 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap;
148 typedef std::map<int, WebServiceWorkerRegistrationImpl*> 158 typedef std::map<int, WebServiceWorkerRegistrationImpl*>
149 RegistrationObjectMap; 159 RegistrationObjectMap;
(...skipping 20 matching lines...) Expand all
170 int request_id, 180 int request_id,
171 const ServiceWorkerRegistrationObjectInfo& info, 181 const ServiceWorkerRegistrationObjectInfo& info,
172 const ServiceWorkerVersionAttributes& attrs); 182 const ServiceWorkerVersionAttributes& attrs);
173 void OnUnregistered(int thread_id, 183 void OnUnregistered(int thread_id,
174 int request_id, 184 int request_id,
175 bool is_success); 185 bool is_success);
176 void OnDidGetRegistration(int thread_id, 186 void OnDidGetRegistration(int thread_id,
177 int request_id, 187 int request_id,
178 const ServiceWorkerRegistrationObjectInfo& info, 188 const ServiceWorkerRegistrationObjectInfo& info,
179 const ServiceWorkerVersionAttributes& attrs); 189 const ServiceWorkerVersionAttributes& attrs);
190 void OnDidGetRegistrations(
191 int thread_id,
192 int request_id,
193 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos,
194 const std::vector<ServiceWorkerVersionAttributes>& attrs);
180 void OnDidGetRegistrationForReady( 195 void OnDidGetRegistrationForReady(
181 int thread_id, 196 int thread_id,
182 int request_id, 197 int request_id,
183 const ServiceWorkerRegistrationObjectInfo& info, 198 const ServiceWorkerRegistrationObjectInfo& info,
184 const ServiceWorkerVersionAttributes& attrs); 199 const ServiceWorkerVersionAttributes& attrs);
185 void OnRegistrationError(int thread_id, 200 void OnRegistrationError(int thread_id,
186 int request_id, 201 int request_id,
187 blink::WebServiceWorkerError::ErrorType error_type, 202 blink::WebServiceWorkerError::ErrorType error_type,
188 const base::string16& message); 203 const base::string16& message);
189 void OnUnregistrationError(int thread_id, 204 void OnUnregistrationError(int thread_id,
190 int request_id, 205 int request_id,
191 blink::WebServiceWorkerError::ErrorType error_type, 206 blink::WebServiceWorkerError::ErrorType error_type,
192 const base::string16& message); 207 const base::string16& message);
193 void OnGetRegistrationError( 208 void OnGetRegistrationError(
194 int thread_id, 209 int thread_id,
195 int request_id, 210 int request_id,
196 blink::WebServiceWorkerError::ErrorType error_type, 211 blink::WebServiceWorkerError::ErrorType error_type,
197 const base::string16& message); 212 const base::string16& message);
213 void OnGetRegistrationsError(
214 int thread_id,
215 int request_id,
216 blink::WebServiceWorkerError::ErrorType error_type,
217 const base::string16& message);
198 void OnServiceWorkerStateChanged(int thread_id, 218 void OnServiceWorkerStateChanged(int thread_id,
199 int handle_id, 219 int handle_id,
200 blink::WebServiceWorkerState state); 220 blink::WebServiceWorkerState state);
201 void OnSetVersionAttributes(int thread_id, 221 void OnSetVersionAttributes(int thread_id,
202 int provider_id, 222 int provider_id,
203 int registration_handle_id, 223 int registration_handle_id,
204 int changed_mask, 224 int changed_mask,
205 const ServiceWorkerVersionAttributes& attributes); 225 const ServiceWorkerVersionAttributes& attributes);
206 void OnUpdateFound(int thread_id, 226 void OnUpdateFound(int thread_id,
207 int registration_handle_id); 227 int registration_handle_id);
(...skipping 24 matching lines...) Expand all
232 // references and always adopts them. 252 // references and always adopts them.
233 // TODO(nhiroki): This assumption seems to impair readability. We could 253 // TODO(nhiroki): This assumption seems to impair readability. We could
234 // explictly pass ServiceWorker(Registration)HandleReference instead. 254 // explictly pass ServiceWorker(Registration)HandleReference instead.
235 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration( 255 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration(
236 const ServiceWorkerRegistrationObjectInfo& info, 256 const ServiceWorkerRegistrationObjectInfo& info,
237 const ServiceWorkerVersionAttributes& attrs); 257 const ServiceWorkerVersionAttributes& attrs);
238 258
239 RegistrationCallbackMap pending_registration_callbacks_; 259 RegistrationCallbackMap pending_registration_callbacks_;
240 UnregistrationCallbackMap pending_unregistration_callbacks_; 260 UnregistrationCallbackMap pending_unregistration_callbacks_;
241 GetRegistrationCallbackMap pending_get_registration_callbacks_; 261 GetRegistrationCallbackMap pending_get_registration_callbacks_;
262 GetRegistrationsCallbackMap pending_get_registrations_callbacks_;
242 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; 263 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_;
243 264
244 ProviderClientMap provider_clients_; 265 ProviderClientMap provider_clients_;
245 ProviderContextMap provider_contexts_; 266 ProviderContextMap provider_contexts_;
246 267
247 WorkerObjectMap service_workers_; 268 WorkerObjectMap service_workers_;
248 RegistrationObjectMap registrations_; 269 RegistrationObjectMap registrations_;
249 270
250 // A map for ServiceWorkers that are associated to a particular document 271 // A map for ServiceWorkers that are associated to a particular document
251 // (e.g. as .current). 272 // (e.g. as .current).
252 WorkerToProviderMap worker_to_provider_; 273 WorkerToProviderMap worker_to_provider_;
253 274
254 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 275 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
255 276
256 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); 277 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher);
257 }; 278 };
258 279
259 } // namespace content 280 } // namespace content
260 281
261 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ 282 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698