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

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

Issue 1307133003: ServiceWorker: Make APIs that return ServiceWorkerRegistration coin a new JS object (2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split CreateRegistration() Created 5 years, 3 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 19 matching lines...) Expand all
30 namespace IPC { 30 namespace IPC {
31 class Message; 31 class Message;
32 } 32 }
33 33
34 struct ServiceWorkerMsg_MessageToDocument_Params; 34 struct ServiceWorkerMsg_MessageToDocument_Params;
35 35
36 namespace content { 36 namespace content {
37 37
38 class ServiceWorkerMessageFilter; 38 class ServiceWorkerMessageFilter;
39 class ServiceWorkerProviderContext; 39 class ServiceWorkerProviderContext;
40 class ServiceWorkerRegistrationHandleReference;
40 class ThreadSafeSender; 41 class ThreadSafeSender;
41 class WebServiceWorkerImpl; 42 class WebServiceWorkerImpl;
42 class WebServiceWorkerRegistrationImpl; 43 class WebServiceWorkerRegistrationImpl;
43 struct ServiceWorkerObjectInfo; 44 struct ServiceWorkerObjectInfo;
44 struct ServiceWorkerRegistrationObjectInfo; 45 struct ServiceWorkerRegistrationObjectInfo;
45 struct ServiceWorkerVersionAttributes; 46 struct ServiceWorkerVersionAttributes;
46 47
47 // This class manages communication with the browser process about 48 // This class manages communication with the browser process about
48 // registration of the service worker, exposed to renderer and worker 49 // registration of the service worker, exposed to renderer and worker
49 // scripts through methods like navigator.registerServiceWorker(). 50 // scripts through methods like navigator.registerServiceWorker().
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // method can return an existing WebServiceWorkerImpl, in which case 128 // method can return an existing WebServiceWorkerImpl, in which case
128 // it is owned by a WebCore::ServiceWorker and the lifetime is not 129 // it is owned by a WebCore::ServiceWorker and the lifetime is not
129 // being transferred to the owner; or it can create a 130 // being transferred to the owner; or it can create a
130 // WebServiceWorkerImpl, in which case ownership is transferred to 131 // WebServiceWorkerImpl, in which case ownership is transferred to
131 // the caller who must bounce it to a method that will associate it 132 // the caller who must bounce it to a method that will associate it
132 // with a WebCore::ServiceWorker. 133 // with a WebCore::ServiceWorker.
133 WebServiceWorkerImpl* GetServiceWorker( 134 WebServiceWorkerImpl* GetServiceWorker(
134 const ServiceWorkerObjectInfo& info, 135 const ServiceWorkerObjectInfo& info,
135 bool adopt_handle); 136 bool adopt_handle);
136 137
137 // Creates a WebServiceWorkerRegistrationImpl for the specified registration 138 // Returns a new registration filled in with version attributes.
138 // and transfers its ownership to the caller. If |adopt_handle| is true, a 139 scoped_ptr<WebServiceWorkerRegistrationImpl> CreateRegistration(
139 // ServiceWorkerRegistrationHandleReference will be adopted for the
140 // registration.
141 WebServiceWorkerRegistrationImpl* CreateServiceWorkerRegistration(
142 const ServiceWorkerRegistrationObjectInfo& info, 140 const ServiceWorkerRegistrationObjectInfo& info,
143 bool adopt_handle); 141 const ServiceWorkerVersionAttributes& attrs);
142 scoped_ptr<WebServiceWorkerRegistrationImpl> AdoptRegistration(
143 const ServiceWorkerRegistrationObjectInfo& info,
144 const ServiceWorkerVersionAttributes& attrs);
144 145
145 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( 146 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance(
146 ThreadSafeSender* thread_safe_sender, 147 ThreadSafeSender* thread_safe_sender,
147 base::SingleThreadTaskRunner* main_thread_task_runner); 148 base::SingleThreadTaskRunner* main_thread_task_runner);
148 149
149 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new 150 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new
150 // instance if thread-local instance doesn't exist. 151 // instance if thread-local instance doesn't exist.
151 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); 152 static ServiceWorkerDispatcher* GetThreadSpecificInstance();
152 153
153 base::SingleThreadTaskRunner* main_thread_task_runner() { 154 base::SingleThreadTaskRunner* main_thread_task_runner() {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker); 259 void AddServiceWorker(int handle_id, WebServiceWorkerImpl* worker);
259 void RemoveServiceWorker(int handle_id); 260 void RemoveServiceWorker(int handle_id);
260 261
261 // Keeps map from registration_handle_id to ServiceWorkerRegistration object. 262 // Keeps map from registration_handle_id to ServiceWorkerRegistration object.
262 void AddServiceWorkerRegistration( 263 void AddServiceWorkerRegistration(
263 int registration_handle_id, 264 int registration_handle_id,
264 WebServiceWorkerRegistrationImpl* registration); 265 WebServiceWorkerRegistrationImpl* registration);
265 void RemoveServiceWorkerRegistration( 266 void RemoveServiceWorkerRegistration(
266 int registration_handle_id); 267 int registration_handle_id);
267 268
268 // Returns an existing registration or new one filled in with version 269 scoped_ptr<WebServiceWorkerRegistrationImpl> CreateRegistrationInternal(
269 // attributes. This function assumes given |info| and |attrs| retain handle 270 scoped_ptr<ServiceWorkerRegistrationHandleReference> handle_ref,
270 // references and always adopts them. 271 const ServiceWorkerVersionAttributes& attrs,
271 // TODO(nhiroki): This assumption seems to impair readability. We could 272 bool adopt_handle);
272 // explictly pass ServiceWorker(Registration)HandleReference instead.
273 WebServiceWorkerRegistrationImpl* FindOrCreateRegistration(
274 const ServiceWorkerRegistrationObjectInfo& info,
275 const ServiceWorkerVersionAttributes& attrs);
276 273
277 RegistrationCallbackMap pending_registration_callbacks_; 274 RegistrationCallbackMap pending_registration_callbacks_;
278 UpdateCallbackMap pending_update_callbacks_; 275 UpdateCallbackMap pending_update_callbacks_;
279 UnregistrationCallbackMap pending_unregistration_callbacks_; 276 UnregistrationCallbackMap pending_unregistration_callbacks_;
280 GetRegistrationCallbackMap pending_get_registration_callbacks_; 277 GetRegistrationCallbackMap pending_get_registration_callbacks_;
281 GetRegistrationsCallbackMap pending_get_registrations_callbacks_; 278 GetRegistrationsCallbackMap pending_get_registrations_callbacks_;
282 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; 279 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_;
283 280
284 ProviderClientMap provider_clients_; 281 ProviderClientMap provider_clients_;
285 ProviderContextMap provider_contexts_; 282 ProviderContextMap provider_contexts_;
286 283
287 WorkerObjectMap service_workers_; 284 WorkerObjectMap service_workers_;
288 RegistrationObjectMap registrations_; 285 RegistrationObjectMap registrations_;
289 286
290 // A map for ServiceWorkers that are associated to a particular document 287 // A map for ServiceWorkers that are associated to a particular document
291 // (e.g. as .current). 288 // (e.g. as .current).
292 WorkerToProviderMap worker_to_provider_; 289 WorkerToProviderMap worker_to_provider_;
293 290
294 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 291 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
295 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 292 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
296 293
297 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); 294 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher);
298 }; 295 };
299 296
300 } // namespace content 297 } // namespace content
301 298
302 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ 299 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698