| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 class WebServiceWorkerRegistrationImpl; | 60 class WebServiceWorkerRegistrationImpl; |
| 61 | 61 |
| 62 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. | 62 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. |
| 63 // Unless otherwise noted, all methods are called on the worker thread. | 63 // Unless otherwise noted, all methods are called on the worker thread. |
| 64 class ServiceWorkerContextClient | 64 class ServiceWorkerContextClient |
| 65 : public blink::WebServiceWorkerContextClient { | 65 : public blink::WebServiceWorkerContextClient { |
| 66 public: | 66 public: |
| 67 using SyncCallback = | 67 using SyncCallback = |
| 68 base::Callback<void(blink::mojom::ServiceWorkerEventStatus, | 68 base::Callback<void(blink::mojom::ServiceWorkerEventStatus, |
| 69 base::Time /* dispatch_event_time */)>; | 69 base::Time /* dispatch_event_time */)>; |
| 70 using FetchCallback = |
| 71 base::Callback<void(blink::mojom::ServiceWorkerEventStatus, |
| 72 base::Time /* dispatch_event_time */)>; |
| 70 | 73 |
| 71 // Returns a thread-specific client instance. This does NOT create a | 74 // Returns a thread-specific client instance. This does NOT create a |
| 72 // new instance. | 75 // new instance. |
| 73 static ServiceWorkerContextClient* ThreadSpecificInstance(); | 76 static ServiceWorkerContextClient* ThreadSpecificInstance(); |
| 74 | 77 |
| 75 // Called on the main thread. | 78 // Called on the main thread. |
| 76 ServiceWorkerContextClient(int embedded_worker_id, | 79 ServiceWorkerContextClient(int embedded_worker_id, |
| 77 int64_t service_worker_version_id, | 80 int64_t service_worker_version_id, |
| 78 const GURL& service_worker_scope, | 81 const GURL& service_worker_scope, |
| 79 const GURL& script_url, | 82 const GURL& script_url, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 const blink::WebVector<blink::WebURL>& sub_scopes, | 190 const blink::WebVector<blink::WebURL>& sub_scopes, |
| 188 const blink::WebVector<blink::WebSecurityOrigin>& origins) override; | 191 const blink::WebVector<blink::WebSecurityOrigin>& origins) override; |
| 189 | 192 |
| 190 virtual void DispatchSyncEvent( | 193 virtual void DispatchSyncEvent( |
| 191 const std::string& tag, | 194 const std::string& tag, |
| 192 blink::WebServiceWorkerContextProxy::LastChanceOption last_chance, | 195 blink::WebServiceWorkerContextProxy::LastChanceOption last_chance, |
| 193 const SyncCallback& callback); | 196 const SyncCallback& callback); |
| 194 | 197 |
| 195 private: | 198 private: |
| 196 struct WorkerContextData; | 199 struct WorkerContextData; |
| 200 class FetchEventDispatcherImpl; |
| 197 | 201 |
| 198 // Get routing_id for sending message to the ServiceWorkerVersion | 202 // Get routing_id for sending message to the ServiceWorkerVersion |
| 199 // in the browser process. | 203 // in the browser process. |
| 200 int GetRoutingID() const { return embedded_worker_id_; } | 204 int GetRoutingID() const { return embedded_worker_id_; } |
| 201 | 205 |
| 202 void Send(IPC::Message* message); | 206 void Send(IPC::Message* message); |
| 203 void SendWorkerStarted(); | 207 void SendWorkerStarted(); |
| 204 void SetRegistrationInServiceWorkerGlobalScope( | 208 void SetRegistrationInServiceWorkerGlobalScope( |
| 205 const ServiceWorkerRegistrationObjectInfo& info, | 209 const ServiceWorkerRegistrationObjectInfo& info, |
| 206 const ServiceWorkerVersionAttributes& attrs); | 210 const ServiceWorkerVersionAttributes& attrs); |
| 207 | 211 |
| 208 void OnActivateEvent(int request_id); | 212 void OnActivateEvent(int request_id); |
| 209 void OnExtendableMessageEvent( | 213 void OnExtendableMessageEvent( |
| 210 int request_id, | 214 int request_id, |
| 211 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params); | 215 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params); |
| 212 void OnInstallEvent(int request_id); | 216 void OnInstallEvent(int request_id); |
| 213 void OnFetchEvent(int response_id, | 217 void DispatchFetchEvent(int response_id, |
| 214 int event_finish_id, | 218 const ServiceWorkerFetchRequest& request, |
| 215 const ServiceWorkerFetchRequest& request); | 219 const FetchCallback& callback); |
| 216 void OnNotificationClickEvent( | 220 void OnNotificationClickEvent( |
| 217 int request_id, | 221 int request_id, |
| 218 const std::string& notification_id, | 222 const std::string& notification_id, |
| 219 const PlatformNotificationData& notification_data, | 223 const PlatformNotificationData& notification_data, |
| 220 int action_index); | 224 int action_index); |
| 221 void OnPushEvent(int request_id, const PushEventPayload& payload); | 225 void OnPushEvent(int request_id, const PushEventPayload& payload); |
| 222 void OnNotificationCloseEvent( | 226 void OnNotificationCloseEvent( |
| 223 int request_id, | 227 int request_id, |
| 224 const std::string& notification_id, | 228 const std::string& notification_id, |
| 225 const PlatformNotificationData& notification_data); | 229 const PlatformNotificationData& notification_data); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 // Initialized on the worker thread in workerContextStarted and | 265 // Initialized on the worker thread in workerContextStarted and |
| 262 // destructed on the worker thread in willDestroyWorkerContext. | 266 // destructed on the worker thread in willDestroyWorkerContext. |
| 263 std::unique_ptr<WorkerContextData> context_; | 267 std::unique_ptr<WorkerContextData> context_; |
| 264 | 268 |
| 265 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); | 269 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); |
| 266 }; | 270 }; |
| 267 | 271 |
| 268 } // namespace content | 272 } // namespace content |
| 269 | 273 |
| 270 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ | 274 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ |
| OLD | NEW |