| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 class ServiceWorkerContextClient; | 61 class ServiceWorkerContextClient; |
| 62 class ThreadSafeSender; | 62 class ThreadSafeSender; |
| 63 class EmbeddedWorkerInstanceClientImpl; | 63 class EmbeddedWorkerInstanceClientImpl; |
| 64 | 64 |
| 65 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. | 65 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. |
| 66 // Unless otherwise noted, all methods are called on the worker thread. | 66 // Unless otherwise noted, all methods are called on the worker thread. |
| 67 class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient, | 67 class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient, |
| 68 public mojom::ServiceWorkerEventDispatcher { | 68 public mojom::ServiceWorkerEventDispatcher { |
| 69 public: | 69 public: |
| 70 using SyncCallback = | 70 using SyncCallback = |
| 71 base::Callback<void(ServiceWorkerStatusCode, | 71 base::OnceCallback<void(ServiceWorkerStatusCode, |
| 72 base::Time /* dispatch_event_time */)>; | 72 base::Time /* dispatch_event_time */)>; |
| 73 using FetchCallback = | 73 using FetchCallback = |
| 74 base::Callback<void(ServiceWorkerStatusCode, | 74 base::OnceCallback<void(ServiceWorkerStatusCode, |
| 75 base::Time /* dispatch_event_time */)>; | 75 base::Time /* dispatch_event_time */)>; |
| 76 | 76 |
| 77 // Returns a thread-specific client instance. This does NOT create a | 77 // Returns a thread-specific client instance. This does NOT create a |
| 78 // new instance. | 78 // new instance. |
| 79 static ServiceWorkerContextClient* ThreadSpecificInstance(); | 79 static ServiceWorkerContextClient* ThreadSpecificInstance(); |
| 80 | 80 |
| 81 // Called on the main thread. | 81 // Called on the main thread. |
| 82 ServiceWorkerContextClient( | 82 ServiceWorkerContextClient( |
| 83 int embedded_worker_id, | 83 int embedded_worker_id, |
| 84 int64_t service_worker_version_id, | 84 int64_t service_worker_version_id, |
| 85 const GURL& service_worker_scope, | 85 const GURL& service_worker_scope, |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // in the browser process. | 224 // in the browser process. |
| 225 int GetRoutingID() const { return embedded_worker_id_; } | 225 int GetRoutingID() const { return embedded_worker_id_; } |
| 226 | 226 |
| 227 void Send(IPC::Message* message); | 227 void Send(IPC::Message* message); |
| 228 void SendWorkerStarted(); | 228 void SendWorkerStarted(); |
| 229 void SetRegistrationInServiceWorkerGlobalScope( | 229 void SetRegistrationInServiceWorkerGlobalScope( |
| 230 const ServiceWorkerRegistrationObjectInfo& info, | 230 const ServiceWorkerRegistrationObjectInfo& info, |
| 231 const ServiceWorkerVersionAttributes& attrs); | 231 const ServiceWorkerVersionAttributes& attrs); |
| 232 | 232 |
| 233 // mojom::ServiceWorkerEventDispatcher | 233 // mojom::ServiceWorkerEventDispatcher |
| 234 void DispatchActivateEvent( | 234 void DispatchActivateEvent(DispatchActivateEventCallback callback) override; |
| 235 const DispatchActivateEventCallback& callback) override; | |
| 236 void DispatchBackgroundFetchAbortEvent( | 235 void DispatchBackgroundFetchAbortEvent( |
| 237 const std::string& tag, | 236 const std::string& tag, |
| 238 const DispatchBackgroundFetchAbortEventCallback& callback) override; | 237 DispatchBackgroundFetchAbortEventCallback callback) override; |
| 239 void DispatchBackgroundFetchClickEvent( | 238 void DispatchBackgroundFetchClickEvent( |
| 240 const std::string& tag, | 239 const std::string& tag, |
| 241 mojom::BackgroundFetchState state, | 240 mojom::BackgroundFetchState state, |
| 242 const DispatchBackgroundFetchClickEventCallback& callback) override; | 241 DispatchBackgroundFetchClickEventCallback callback) override; |
| 243 void DispatchBackgroundFetchFailEvent( | 242 void DispatchBackgroundFetchFailEvent( |
| 244 const std::string& tag, | 243 const std::string& tag, |
| 245 const std::vector<BackgroundFetchSettledFetch>& fetches, | 244 const std::vector<BackgroundFetchSettledFetch>& fetches, |
| 246 const DispatchBackgroundFetchFailEventCallback& callback) override; | 245 DispatchBackgroundFetchFailEventCallback callback) override; |
| 247 void DispatchBackgroundFetchedEvent( | 246 void DispatchBackgroundFetchedEvent( |
| 248 const std::string& tag, | 247 const std::string& tag, |
| 249 const std::vector<BackgroundFetchSettledFetch>& fetches, | 248 const std::vector<BackgroundFetchSettledFetch>& fetches, |
| 250 const DispatchBackgroundFetchedEventCallback& callback) override; | 249 DispatchBackgroundFetchedEventCallback callback) override; |
| 251 void DispatchExtendableMessageEvent( | 250 void DispatchExtendableMessageEvent( |
| 252 mojom::ExtendableMessageEventPtr event, | 251 mojom::ExtendableMessageEventPtr event, |
| 253 const DispatchExtendableMessageEventCallback& callback) override; | 252 DispatchExtendableMessageEventCallback callback) override; |
| 254 void DispatchFetchEvent( | 253 void DispatchFetchEvent( |
| 255 int fetch_event_id, | 254 int fetch_event_id, |
| 256 const ServiceWorkerFetchRequest& request, | 255 const ServiceWorkerFetchRequest& request, |
| 257 mojom::FetchEventPreloadHandlePtr preload_handle, | 256 mojom::FetchEventPreloadHandlePtr preload_handle, |
| 258 mojom::ServiceWorkerFetchResponseCallbackPtr response_callback, | 257 mojom::ServiceWorkerFetchResponseCallbackPtr response_callback, |
| 259 const DispatchFetchEventCallback& callback) override; | 258 DispatchFetchEventCallback callback) override; |
| 260 void DispatchNotificationClickEvent( | 259 void DispatchNotificationClickEvent( |
| 261 const std::string& notification_id, | 260 const std::string& notification_id, |
| 262 const PlatformNotificationData& notification_data, | 261 const PlatformNotificationData& notification_data, |
| 263 int action_index, | 262 int action_index, |
| 264 const base::Optional<base::string16>& reply, | 263 const base::Optional<base::string16>& reply, |
| 265 const DispatchNotificationClickEventCallback& callback) override; | 264 DispatchNotificationClickEventCallback callback) override; |
| 266 void DispatchNotificationCloseEvent( | 265 void DispatchNotificationCloseEvent( |
| 267 const std::string& notification_id, | 266 const std::string& notification_id, |
| 268 const PlatformNotificationData& notification_data, | 267 const PlatformNotificationData& notification_data, |
| 269 const DispatchNotificationCloseEventCallback& callback) override; | 268 DispatchNotificationCloseEventCallback callback) override; |
| 270 void DispatchPushEvent(const PushEventPayload& payload, | 269 void DispatchPushEvent(const PushEventPayload& payload, |
| 271 const DispatchPushEventCallback& callback) override; | 270 DispatchPushEventCallback callback) override; |
| 272 void DispatchSyncEvent( | 271 void DispatchSyncEvent( |
| 273 const std::string& tag, | 272 const std::string& tag, |
| 274 blink::mojom::BackgroundSyncEventLastChance last_chance, | 273 blink::mojom::BackgroundSyncEventLastChance last_chance, |
| 275 const DispatchSyncEventCallback& callback) override; | 274 DispatchSyncEventCallback callback) override; |
| 276 void DispatchPaymentRequestEvent( | 275 void DispatchPaymentRequestEvent( |
| 277 int payment_request_id, | 276 int payment_request_id, |
| 278 payments::mojom::PaymentAppRequestPtr app_request, | 277 payments::mojom::PaymentAppRequestPtr app_request, |
| 279 payments::mojom::PaymentAppResponseCallbackPtr response_callback, | 278 payments::mojom::PaymentAppResponseCallbackPtr response_callback, |
| 280 const DispatchPaymentRequestEventCallback& callback) override; | 279 DispatchPaymentRequestEventCallback callback) override; |
| 281 void Ping(const PingCallback& callback) override; | 280 void Ping(PingCallback callback) override; |
| 282 | 281 |
| 283 void OnInstallEvent(int request_id); | 282 void OnInstallEvent(int request_id); |
| 284 void OnNotificationClickEvent( | 283 void OnNotificationClickEvent( |
| 285 int request_id, | 284 int request_id, |
| 286 const std::string& notification_id, | 285 const std::string& notification_id, |
| 287 const PlatformNotificationData& notification_data, | 286 const PlatformNotificationData& notification_data, |
| 288 int action_index, | 287 int action_index, |
| 289 const base::NullableString16& reply); | 288 const base::NullableString16& reply); |
| 290 void OnNotificationCloseEvent( | 289 void OnNotificationCloseEvent( |
| 291 int request_id, | 290 int request_id, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // Initialized on the worker thread in workerContextStarted and | 351 // Initialized on the worker thread in workerContextStarted and |
| 353 // destructed on the worker thread in willDestroyWorkerContext. | 352 // destructed on the worker thread in willDestroyWorkerContext. |
| 354 std::unique_ptr<WorkerContextData> context_; | 353 std::unique_ptr<WorkerContextData> context_; |
| 355 | 354 |
| 356 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); | 355 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); |
| 357 }; | 356 }; |
| 358 | 357 |
| 359 } // namespace content | 358 } // namespace content |
| 360 | 359 |
| 361 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ | 360 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ |
| OLD | NEW |