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

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

Issue 2451373003: service worker: Implement NavigationPreloadManager.setHeaderValue (Closed)
Patch Set: minimize deltas, rm uneeded change Created 4 years, 1 month 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/id_map.h" 14 #include "base/id_map.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "content/common/service_worker/service_worker_types.h"
18 #include "content/public/child/worker_thread.h" 19 #include "content/public/child/worker_thread.h"
19 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerError.h" 20 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerError.h"
20 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerProvider.h" 21 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerProvider.h"
21 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerRegistration.h" 22 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerRegistration.h"
22 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerState.h" 23 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerState.h"
23 24
24 class GURL; 25 class GURL;
25 26
26 namespace base { 27 namespace base {
27 class SingleThreadTaskRunner; 28 class SingleThreadTaskRunner;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 typedef 65 typedef
65 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationsCallbacks 66 blink::WebServiceWorkerProvider::WebServiceWorkerGetRegistrationsCallbacks
66 WebServiceWorkerGetRegistrationsCallbacks; 67 WebServiceWorkerGetRegistrationsCallbacks;
67 typedef blink::WebServiceWorkerProvider:: 68 typedef blink::WebServiceWorkerProvider::
68 WebServiceWorkerGetRegistrationForReadyCallbacks 69 WebServiceWorkerGetRegistrationForReadyCallbacks
69 WebServiceWorkerGetRegistrationForReadyCallbacks; 70 WebServiceWorkerGetRegistrationForReadyCallbacks;
70 using WebEnableNavigationPreloadCallbacks = 71 using WebEnableNavigationPreloadCallbacks =
71 blink::WebServiceWorkerRegistration::WebEnableNavigationPreloadCallbacks; 72 blink::WebServiceWorkerRegistration::WebEnableNavigationPreloadCallbacks;
72 using WebGetNavigationPreloadStateCallbacks = blink:: 73 using WebGetNavigationPreloadStateCallbacks = blink::
73 WebServiceWorkerRegistration::WebGetNavigationPreloadStateCallbacks; 74 WebServiceWorkerRegistration::WebGetNavigationPreloadStateCallbacks;
75 using WebSetNavigationPreloadHeaderCallbacks = blink::
76 WebServiceWorkerRegistration::WebSetNavigationPreloadHeaderCallbacks;
74 77
75 ServiceWorkerDispatcher( 78 ServiceWorkerDispatcher(
76 ThreadSafeSender* thread_safe_sender, 79 ThreadSafeSender* thread_safe_sender,
77 base::SingleThreadTaskRunner* main_thread_task_runner); 80 base::SingleThreadTaskRunner* main_thread_task_runner);
78 ~ServiceWorkerDispatcher() override; 81 ~ServiceWorkerDispatcher() override;
79 82
80 void OnMessageReceived(const IPC::Message& msg); 83 void OnMessageReceived(const IPC::Message& msg);
81 84
82 // Corresponds to navigator.serviceWorker.register(). 85 // Corresponds to navigator.serviceWorker.register().
83 void RegisterServiceWorker( 86 void RegisterServiceWorker(
(...skipping 27 matching lines...) Expand all
111 void EnableNavigationPreload( 114 void EnableNavigationPreload(
112 int provider_id, 115 int provider_id,
113 int64_t registration_id, 116 int64_t registration_id,
114 bool enable, 117 bool enable,
115 std::unique_ptr<WebEnableNavigationPreloadCallbacks> callbacks); 118 std::unique_ptr<WebEnableNavigationPreloadCallbacks> callbacks);
116 // Corresponds to NavigationPreloadManager.getState. 119 // Corresponds to NavigationPreloadManager.getState.
117 void GetNavigationPreloadState( 120 void GetNavigationPreloadState(
118 int provider_id, 121 int provider_id,
119 int64_t registration_id, 122 int64_t registration_id,
120 std::unique_ptr<WebGetNavigationPreloadStateCallbacks> callbacks); 123 std::unique_ptr<WebGetNavigationPreloadStateCallbacks> callbacks);
124 // Corresponds to NavigationPreloadManager.setHeaderValue.
125 void SetNavigationPreloadHeader(
126 int provider_id,
127 int64_t registration_id,
128 const std::string& value,
129 std::unique_ptr<WebSetNavigationPreloadHeaderCallbacks> callbacks);
121 130
122 // Called when a new provider context for a document is created. Usually 131 // Called when a new provider context for a document is created. Usually
123 // this happens when a new document is being loaded, and is called much 132 // this happens when a new document is being loaded, and is called much
124 // earlier than AddScriptClient. 133 // earlier than AddScriptClient.
125 // (This is attached only to the document thread's ServiceWorkerDispatcher) 134 // (This is attached only to the document thread's ServiceWorkerDispatcher)
126 void AddProviderContext(ServiceWorkerProviderContext* provider_context); 135 void AddProviderContext(ServiceWorkerProviderContext* provider_context);
127 void RemoveProviderContext(ServiceWorkerProviderContext* provider_context); 136 void RemoveProviderContext(ServiceWorkerProviderContext* provider_context);
128 137
129 // Called when navigator.serviceWorker is instantiated or detached 138 // Called when navigator.serviceWorker is instantiated or detached
130 // for a document whose provider can be identified by |provider_id|. 139 // for a document whose provider can be identified by |provider_id|.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 typedef IDMap<WebServiceWorkerGetRegistrationCallbacks, 182 typedef IDMap<WebServiceWorkerGetRegistrationCallbacks,
174 IDMapOwnPointer> GetRegistrationCallbackMap; 183 IDMapOwnPointer> GetRegistrationCallbackMap;
175 typedef IDMap<WebServiceWorkerGetRegistrationsCallbacks, 184 typedef IDMap<WebServiceWorkerGetRegistrationsCallbacks,
176 IDMapOwnPointer> GetRegistrationsCallbackMap; 185 IDMapOwnPointer> GetRegistrationsCallbackMap;
177 typedef IDMap<WebServiceWorkerGetRegistrationForReadyCallbacks, 186 typedef IDMap<WebServiceWorkerGetRegistrationForReadyCallbacks,
178 IDMapOwnPointer> GetRegistrationForReadyCallbackMap; 187 IDMapOwnPointer> GetRegistrationForReadyCallbackMap;
179 using EnableNavigationPreloadCallbackMap = 188 using EnableNavigationPreloadCallbackMap =
180 IDMap<WebEnableNavigationPreloadCallbacks, IDMapOwnPointer>; 189 IDMap<WebEnableNavigationPreloadCallbacks, IDMapOwnPointer>;
181 using GetNavigationPreloadStateCallbackMap = 190 using GetNavigationPreloadStateCallbackMap =
182 IDMap<WebGetNavigationPreloadStateCallbacks, IDMapOwnPointer>; 191 IDMap<WebGetNavigationPreloadStateCallbacks, IDMapOwnPointer>;
192 using SetNavigationPreloadHeaderCallbackMap =
193 IDMap<WebSetNavigationPreloadHeaderCallbacks, IDMapOwnPointer>;
183 194
184 typedef std::map<int, blink::WebServiceWorkerProviderClient*> 195 typedef std::map<int, blink::WebServiceWorkerProviderClient*>
185 ProviderClientMap; 196 ProviderClientMap;
186 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; 197 typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap;
187 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; 198 typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap;
188 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap; 199 typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap;
189 typedef std::map<int, WebServiceWorkerRegistrationImpl*> 200 typedef std::map<int, WebServiceWorkerRegistrationImpl*>
190 RegistrationObjectMap; 201 RegistrationObjectMap;
191 202
192 friend class ServiceWorkerDispatcherTest; 203 friend class ServiceWorkerDispatcherTest;
(...skipping 27 matching lines...) Expand all
220 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos, 231 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos,
221 const std::vector<ServiceWorkerVersionAttributes>& attrs); 232 const std::vector<ServiceWorkerVersionAttributes>& attrs);
222 void OnDidGetRegistrationForReady( 233 void OnDidGetRegistrationForReady(
223 int thread_id, 234 int thread_id,
224 int request_id, 235 int request_id,
225 const ServiceWorkerRegistrationObjectInfo& info, 236 const ServiceWorkerRegistrationObjectInfo& info,
226 const ServiceWorkerVersionAttributes& attrs); 237 const ServiceWorkerVersionAttributes& attrs);
227 void OnDidEnableNavigationPreload(int thread_id, int request_id); 238 void OnDidEnableNavigationPreload(int thread_id, int request_id);
228 void OnDidGetNavigationPreloadState(int thread_id, 239 void OnDidGetNavigationPreloadState(int thread_id,
229 int request_id, 240 int request_id,
230 bool enabled); 241 const NavigationPreloadState& state);
242 void OnDidSetNavigationPreloadHeader(int thread_id, int request_id);
231 void OnRegistrationError(int thread_id, 243 void OnRegistrationError(int thread_id,
232 int request_id, 244 int request_id,
233 blink::WebServiceWorkerError::ErrorType error_type, 245 blink::WebServiceWorkerError::ErrorType error_type,
234 const base::string16& message); 246 const base::string16& message);
235 void OnUpdateError(int thread_id, 247 void OnUpdateError(int thread_id,
236 int request_id, 248 int request_id,
237 blink::WebServiceWorkerError::ErrorType error_type, 249 blink::WebServiceWorkerError::ErrorType error_type,
238 const base::string16& message); 250 const base::string16& message);
239 void OnUnregistrationError(int thread_id, 251 void OnUnregistrationError(int thread_id,
240 int request_id, 252 int request_id,
(...skipping 12 matching lines...) Expand all
253 void OnEnableNavigationPreloadError( 265 void OnEnableNavigationPreloadError(
254 int thread_id, 266 int thread_id,
255 int request_id, 267 int request_id,
256 blink::WebServiceWorkerError::ErrorType error_type, 268 blink::WebServiceWorkerError::ErrorType error_type,
257 const std::string& message); 269 const std::string& message);
258 void OnGetNavigationPreloadStateError( 270 void OnGetNavigationPreloadStateError(
259 int thread_id, 271 int thread_id,
260 int request_id, 272 int request_id,
261 blink::WebServiceWorkerError::ErrorType error_type, 273 blink::WebServiceWorkerError::ErrorType error_type,
262 const std::string& message); 274 const std::string& message);
275 void OnSetNavigationPreloadHeaderError(
276 int thread_id,
277 int request_id,
278 blink::WebServiceWorkerError::ErrorType error_type,
279 const std::string& message);
263 void OnServiceWorkerStateChanged(int thread_id, 280 void OnServiceWorkerStateChanged(int thread_id,
264 int handle_id, 281 int handle_id,
265 blink::WebServiceWorkerState state); 282 blink::WebServiceWorkerState state);
266 void OnSetVersionAttributes(int thread_id, 283 void OnSetVersionAttributes(int thread_id,
267 int registration_handle_id, 284 int registration_handle_id,
268 int changed_mask, 285 int changed_mask,
269 const ServiceWorkerVersionAttributes& attributes); 286 const ServiceWorkerVersionAttributes& attributes);
270 void OnUpdateFound(int thread_id, 287 void OnUpdateFound(int thread_id,
271 int registration_handle_id); 288 int registration_handle_id);
272 void OnSetControllerServiceWorker(int thread_id, 289 void OnSetControllerServiceWorker(int thread_id,
(...skipping 21 matching lines...) Expand all
294 const ServiceWorkerObjectInfo& info); 311 const ServiceWorkerObjectInfo& info);
295 312
296 RegistrationCallbackMap pending_registration_callbacks_; 313 RegistrationCallbackMap pending_registration_callbacks_;
297 UpdateCallbackMap pending_update_callbacks_; 314 UpdateCallbackMap pending_update_callbacks_;
298 UnregistrationCallbackMap pending_unregistration_callbacks_; 315 UnregistrationCallbackMap pending_unregistration_callbacks_;
299 GetRegistrationCallbackMap pending_get_registration_callbacks_; 316 GetRegistrationCallbackMap pending_get_registration_callbacks_;
300 GetRegistrationsCallbackMap pending_get_registrations_callbacks_; 317 GetRegistrationsCallbackMap pending_get_registrations_callbacks_;
301 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_; 318 GetRegistrationForReadyCallbackMap get_for_ready_callbacks_;
302 EnableNavigationPreloadCallbackMap enable_navigation_preload_callbacks_; 319 EnableNavigationPreloadCallbackMap enable_navigation_preload_callbacks_;
303 GetNavigationPreloadStateCallbackMap get_navigation_preload_state_callbacks_; 320 GetNavigationPreloadStateCallbackMap get_navigation_preload_state_callbacks_;
321 SetNavigationPreloadHeaderCallbackMap
322 set_navigation_preload_header_callbacks_;
304 323
305 ProviderClientMap provider_clients_; 324 ProviderClientMap provider_clients_;
306 ProviderContextMap provider_contexts_; 325 ProviderContextMap provider_contexts_;
307 326
308 WorkerObjectMap service_workers_; 327 WorkerObjectMap service_workers_;
309 RegistrationObjectMap registrations_; 328 RegistrationObjectMap registrations_;
310 329
311 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 330 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
312 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 331 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
313 332
314 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); 333 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher);
315 }; 334 };
316 335
317 } // namespace content 336 } // namespace content
318 337
319 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ 338 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698