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 |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/callback.h" | 16 #include "base/callback.h" |
17 #include "base/id_map.h" | 17 #include "base/id_map.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "components/payments/payment_app.mojom.h" |
22 #include "content/child/webmessageportchannel_impl.h" | 23 #include "content/child/webmessageportchannel_impl.h" |
23 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" | 24 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" |
24 #include "content/common/service_worker/service_worker_status_code.h" | 25 #include "content/common/service_worker/service_worker_status_code.h" |
25 #include "content/common/service_worker/service_worker_types.h" | 26 #include "content/common/service_worker/service_worker_types.h" |
26 #include "ipc/ipc_listener.h" | 27 #include "ipc/ipc_listener.h" |
27 #include "mojo/public/cpp/bindings/binding.h" | 28 #include "mojo/public/cpp/bindings/binding.h" |
28 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 29 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
29 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerError.h" | 30 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerError.h" |
30 #include "third_party/WebKit/public/platform/modules/serviceworker/service_worke
r_event_status.mojom.h" | 31 #include "third_party/WebKit/public/platform/modules/serviceworker/service_worke
r_event_status.mojom.h" |
31 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextClient.h" | 32 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextClient.h" |
(...skipping 29 matching lines...) Expand all Loading... |
61 class EmbeddedWorkerInstanceClientImpl; | 62 class EmbeddedWorkerInstanceClientImpl; |
62 | 63 |
63 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. | 64 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. |
64 // Unless otherwise noted, all methods are called on the worker thread. | 65 // Unless otherwise noted, all methods are called on the worker thread. |
65 class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient, | 66 class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient, |
66 public mojom::ServiceWorkerEventDispatcher { | 67 public mojom::ServiceWorkerEventDispatcher { |
67 public: | 68 public: |
68 using SyncCallback = | 69 using SyncCallback = |
69 base::Callback<void(ServiceWorkerStatusCode, | 70 base::Callback<void(ServiceWorkerStatusCode, |
70 base::Time /* dispatch_event_time */)>; | 71 base::Time /* dispatch_event_time */)>; |
| 72 using PaymentRequestEventCallback = |
| 73 base::Callback<void(ServiceWorkerStatusCode, |
| 74 base::Time /* dispatch_event_time */)>; |
71 using FetchCallback = | 75 using FetchCallback = |
72 base::Callback<void(ServiceWorkerStatusCode, | 76 base::Callback<void(ServiceWorkerStatusCode, |
73 base::Time /* dispatch_event_time */)>; | 77 base::Time /* dispatch_event_time */)>; |
74 | 78 |
75 // Returns a thread-specific client instance. This does NOT create a | 79 // Returns a thread-specific client instance. This does NOT create a |
76 // new instance. | 80 // new instance. |
77 static ServiceWorkerContextClient* ThreadSpecificInstance(); | 81 static ServiceWorkerContextClient* ThreadSpecificInstance(); |
78 | 82 |
79 // Called on the main thread. | 83 // Called on the main thread. |
80 ServiceWorkerContextClient( | 84 ServiceWorkerContextClient( |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 mojom::ExtendableMessageEventPtr event, | 221 mojom::ExtendableMessageEventPtr event, |
218 const DispatchExtendableMessageEventCallback& callback) override; | 222 const DispatchExtendableMessageEventCallback& callback) override; |
219 void DispatchFetchEvent(int fetch_event_id, | 223 void DispatchFetchEvent(int fetch_event_id, |
220 const ServiceWorkerFetchRequest& request, | 224 const ServiceWorkerFetchRequest& request, |
221 mojom::FetchEventPreloadHandlePtr preload_handle, | 225 mojom::FetchEventPreloadHandlePtr preload_handle, |
222 const DispatchFetchEventCallback& callback) override; | 226 const DispatchFetchEventCallback& callback) override; |
223 void DispatchSyncEvent( | 227 void DispatchSyncEvent( |
224 const std::string& tag, | 228 const std::string& tag, |
225 blink::mojom::BackgroundSyncEventLastChance last_chance, | 229 blink::mojom::BackgroundSyncEventLastChance last_chance, |
226 const DispatchSyncEventCallback& callback) override; | 230 const DispatchSyncEventCallback& callback) override; |
| 231 void DispatchPaymentRequestEvent( |
| 232 payments::mojom::PaymentAppRequestDataPtr data, |
| 233 const DispatchPaymentRequestEventCallback& callback) override; |
227 | 234 |
228 void OnActivateEvent(int request_id); | 235 void OnActivateEvent(int request_id); |
229 void OnInstallEvent(int request_id); | 236 void OnInstallEvent(int request_id); |
230 void OnNotificationClickEvent( | 237 void OnNotificationClickEvent( |
231 int request_id, | 238 int request_id, |
232 const std::string& notification_id, | 239 const std::string& notification_id, |
233 const PlatformNotificationData& notification_data, | 240 const PlatformNotificationData& notification_data, |
234 int action_index, | 241 int action_index, |
235 const base::NullableString16& reply); | 242 const base::NullableString16& reply); |
236 void OnPushEvent(int request_id, const PushEventPayload& payload); | 243 void OnPushEvent(int request_id, const PushEventPayload& payload); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // Initialized on the worker thread in workerContextStarted and | 297 // Initialized on the worker thread in workerContextStarted and |
291 // destructed on the worker thread in willDestroyWorkerContext. | 298 // destructed on the worker thread in willDestroyWorkerContext. |
292 std::unique_ptr<WorkerContextData> context_; | 299 std::unique_ptr<WorkerContextData> context_; |
293 | 300 |
294 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); | 301 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); |
295 }; | 302 }; |
296 | 303 |
297 } // namespace content | 304 } // namespace content |
298 | 305 |
299 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ | 306 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ |
OLD | NEW |