OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ | 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ |
6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ | 6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 std::unique_ptr<blink::WebServiceWorkerClientCallbacks>) override; | 201 std::unique_ptr<blink::WebServiceWorkerClientCallbacks>) override; |
202 void Navigate( | 202 void Navigate( |
203 const blink::WebString& uuid, | 203 const blink::WebString& uuid, |
204 const blink::WebURL&, | 204 const blink::WebURL&, |
205 std::unique_ptr<blink::WebServiceWorkerClientCallbacks>) override; | 205 std::unique_ptr<blink::WebServiceWorkerClientCallbacks>) override; |
206 void SkipWaiting(std::unique_ptr<blink::WebServiceWorkerSkipWaitingCallbacks> | 206 void SkipWaiting(std::unique_ptr<blink::WebServiceWorkerSkipWaitingCallbacks> |
207 callbacks) override; | 207 callbacks) override; |
208 void Claim(std::unique_ptr<blink::WebServiceWorkerClientsClaimCallbacks> | 208 void Claim(std::unique_ptr<blink::WebServiceWorkerClientsClaimCallbacks> |
209 callbacks) override; | 209 callbacks) override; |
210 void RegisterForeignFetchScopes( | 210 void RegisterForeignFetchScopes( |
| 211 const int event_id, |
211 const blink::WebVector<blink::WebURL>& sub_scopes, | 212 const blink::WebVector<blink::WebURL>& sub_scopes, |
212 const blink::WebVector<blink::WebSecurityOrigin>& origins) override; | 213 const blink::WebVector<blink::WebSecurityOrigin>& origins) override; |
213 | 214 |
214 private: | 215 private: |
| 216 // The key is the unique id of every install event. |
| 217 using InstallEventMethodsMap = |
| 218 std::map<int, mojom::ServiceWorkerInstallEventMethodsAssociatedPtr>; |
| 219 |
215 struct WorkerContextData; | 220 struct WorkerContextData; |
216 class NavigationPreloadRequest; | 221 class NavigationPreloadRequest; |
217 | 222 |
218 // Get routing_id for sending message to the ServiceWorkerVersion | 223 // Get routing_id for sending message to the ServiceWorkerVersion |
219 // in the browser process. | 224 // in the browser process. |
220 int GetRoutingID() const { return embedded_worker_id_; } | 225 int GetRoutingID() const { return embedded_worker_id_; } |
221 | 226 |
222 void Send(IPC::Message* message); | 227 void Send(IPC::Message* message); |
223 void SendWorkerStarted(); | 228 void SendWorkerStarted(); |
224 void SetRegistrationInServiceWorkerGlobalScope( | 229 void SetRegistrationInServiceWorkerGlobalScope( |
225 const ServiceWorkerRegistrationObjectInfo& info, | 230 const ServiceWorkerRegistrationObjectInfo& info, |
226 const ServiceWorkerVersionAttributes& attrs); | 231 const ServiceWorkerVersionAttributes& attrs); |
227 | 232 |
228 // mojom::ServiceWorkerEventDispatcher | 233 // mojom::ServiceWorkerEventDispatcher |
| 234 void DispatchInstallEvent( |
| 235 mojom::ServiceWorkerInstallEventMethodsAssociatedPtrInfo client, |
| 236 const DispatchInstallEventCallback& callback) override; |
229 void DispatchActivateEvent( | 237 void DispatchActivateEvent( |
230 const DispatchActivateEventCallback& callback) override; | 238 const DispatchActivateEventCallback& callback) override; |
231 void DispatchBackgroundFetchAbortEvent( | 239 void DispatchBackgroundFetchAbortEvent( |
232 const std::string& tag, | 240 const std::string& tag, |
233 const DispatchBackgroundFetchAbortEventCallback& callback) override; | 241 const DispatchBackgroundFetchAbortEventCallback& callback) override; |
234 void DispatchBackgroundFetchClickEvent( | 242 void DispatchBackgroundFetchClickEvent( |
235 const std::string& tag, | 243 const std::string& tag, |
236 mojom::BackgroundFetchState state, | 244 mojom::BackgroundFetchState state, |
237 const DispatchBackgroundFetchClickEventCallback& callback) override; | 245 const DispatchBackgroundFetchClickEventCallback& callback) override; |
238 void DispatchBackgroundFetchFailEvent( | 246 void DispatchBackgroundFetchFailEvent( |
(...skipping 27 matching lines...) Expand all Loading... |
266 const std::string& tag, | 274 const std::string& tag, |
267 blink::mojom::BackgroundSyncEventLastChance last_chance, | 275 blink::mojom::BackgroundSyncEventLastChance last_chance, |
268 const DispatchSyncEventCallback& callback) override; | 276 const DispatchSyncEventCallback& callback) override; |
269 void DispatchPaymentRequestEvent( | 277 void DispatchPaymentRequestEvent( |
270 int payment_request_id, | 278 int payment_request_id, |
271 payments::mojom::PaymentAppRequestPtr app_request, | 279 payments::mojom::PaymentAppRequestPtr app_request, |
272 payments::mojom::PaymentAppResponseCallbackPtr response_callback, | 280 payments::mojom::PaymentAppResponseCallbackPtr response_callback, |
273 const DispatchPaymentRequestEventCallback& callback) override; | 281 const DispatchPaymentRequestEventCallback& callback) override; |
274 void Ping(const PingCallback& callback) override; | 282 void Ping(const PingCallback& callback) override; |
275 | 283 |
276 void OnInstallEvent(int request_id); | |
277 void OnNotificationClickEvent( | 284 void OnNotificationClickEvent( |
278 int request_id, | 285 int request_id, |
279 const std::string& notification_id, | 286 const std::string& notification_id, |
280 const PlatformNotificationData& notification_data, | 287 const PlatformNotificationData& notification_data, |
281 int action_index, | 288 int action_index, |
282 const base::NullableString16& reply); | 289 const base::NullableString16& reply); |
283 void OnNotificationCloseEvent( | 290 void OnNotificationCloseEvent( |
284 int request_id, | 291 int request_id, |
285 const std::string& notification_id, | 292 const std::string& notification_id, |
286 const PlatformNotificationData& notification_data); | 293 const PlatformNotificationData& notification_data); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // Not owned; this object is destroyed when proxy_ becomes invalid. | 338 // Not owned; this object is destroyed when proxy_ becomes invalid. |
332 blink::WebServiceWorkerContextProxy* proxy_; | 339 blink::WebServiceWorkerContextProxy* proxy_; |
333 | 340 |
334 // This is bound on the worker thread. | 341 // This is bound on the worker thread. |
335 mojom::ServiceWorkerEventDispatcherRequest pending_dispatcher_request_; | 342 mojom::ServiceWorkerEventDispatcherRequest pending_dispatcher_request_; |
336 | 343 |
337 // This is bound on the main thread. | 344 // This is bound on the main thread. |
338 scoped_refptr<mojom::ThreadSafeEmbeddedWorkerInstanceHostAssociatedPtr> | 345 scoped_refptr<mojom::ThreadSafeEmbeddedWorkerInstanceHostAssociatedPtr> |
339 instance_host_; | 346 instance_host_; |
340 | 347 |
| 348 // Maps every install event id with its corresponding |
| 349 // mojom::ServiceWorkerInstallEventMethodsAssociatedPt. |
| 350 InstallEventMethodsMap install_methods_map_; |
| 351 |
341 // Renderer-side object corresponding to WebEmbeddedWorkerInstance. | 352 // Renderer-side object corresponding to WebEmbeddedWorkerInstance. |
342 // This is valid from the ctor to workerContextDestroyed. | 353 // This is valid from the ctor to workerContextDestroyed. |
343 std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client_; | 354 std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client_; |
344 | 355 |
345 // Initialized on the worker thread in workerContextStarted and | 356 // Initialized on the worker thread in workerContextStarted and |
346 // destructed on the worker thread in willDestroyWorkerContext. | 357 // destructed on the worker thread in willDestroyWorkerContext. |
347 std::unique_ptr<WorkerContextData> context_; | 358 std::unique_ptr<WorkerContextData> context_; |
348 | 359 |
349 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); | 360 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); |
350 }; | 361 }; |
351 | 362 |
352 } // namespace content | 363 } // namespace content |
353 | 364 |
354 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ | 365 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ |
OLD | NEW |