| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "content/child/webmessageportchannel_impl.h" | 17 #include "content/child/webmessageportchannel_impl.h" |
| 18 #include "content/common/background_sync_service.mojom.h" |
| 18 #include "content/common/service_worker/service_worker_types.h" | 19 #include "content/common/service_worker/service_worker_types.h" |
| 19 #include "ipc/ipc_listener.h" | 20 #include "ipc/ipc_listener.h" |
| 20 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" | 21 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" |
| 21 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 22 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
| 22 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" | 23 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" |
| 23 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" | 24 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class SingleThreadTaskRunner; | 27 class SingleThreadTaskRunner; |
| 27 class TaskRunner; | 28 class TaskRunner; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 48 class ServiceWorkerProviderContext; | 49 class ServiceWorkerProviderContext; |
| 49 class ServiceWorkerContextClient; | 50 class ServiceWorkerContextClient; |
| 50 class ThreadSafeSender; | 51 class ThreadSafeSender; |
| 51 class WebServiceWorkerRegistrationImpl; | 52 class WebServiceWorkerRegistrationImpl; |
| 52 | 53 |
| 53 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. | 54 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. |
| 54 // Unless otherwise noted, all methods are called on the worker thread. | 55 // Unless otherwise noted, all methods are called on the worker thread. |
| 55 class ServiceWorkerContextClient | 56 class ServiceWorkerContextClient |
| 56 : public blink::WebServiceWorkerContextClient { | 57 : public blink::WebServiceWorkerContextClient { |
| 57 public: | 58 public: |
| 59 using SyncCallback = mojo::Callback<void(ServiceWorkerEventStatus)>; |
| 60 |
| 58 // Returns a thread-specific client instance. This does NOT create a | 61 // Returns a thread-specific client instance. This does NOT create a |
| 59 // new instance. | 62 // new instance. |
| 60 static ServiceWorkerContextClient* ThreadSpecificInstance(); | 63 static ServiceWorkerContextClient* ThreadSpecificInstance(); |
| 61 | 64 |
| 62 // Called on the main thread. | 65 // Called on the main thread. |
| 63 ServiceWorkerContextClient(int embedded_worker_id, | 66 ServiceWorkerContextClient(int embedded_worker_id, |
| 64 int64 service_worker_version_id, | 67 int64 service_worker_version_id, |
| 65 const GURL& service_worker_scope, | 68 const GURL& service_worker_scope, |
| 66 const GURL& script_url, | 69 const GURL& script_url, |
| 67 int worker_devtools_agent_route_id); | 70 int worker_devtools_agent_route_id); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 const blink::WebString& message, | 138 const blink::WebString& message, |
| 136 blink::WebMessagePortChannelArray* channels); | 139 blink::WebMessagePortChannelArray* channels); |
| 137 virtual void focus(const blink::WebString& uuid, | 140 virtual void focus(const blink::WebString& uuid, |
| 138 blink::WebServiceWorkerClientCallbacks*); | 141 blink::WebServiceWorkerClientCallbacks*); |
| 139 virtual void skipWaiting( | 142 virtual void skipWaiting( |
| 140 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); | 143 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); |
| 141 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); | 144 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); |
| 142 virtual void stashMessagePort(blink::WebMessagePortChannel* channel, | 145 virtual void stashMessagePort(blink::WebMessagePortChannel* channel, |
| 143 const blink::WebString& name); | 146 const blink::WebString& name); |
| 144 | 147 |
| 148 virtual void DispatchSyncEvent(const SyncCallback& callback); |
| 149 |
| 145 private: | 150 private: |
| 146 struct WorkerContextData; | 151 struct WorkerContextData; |
| 147 | 152 |
| 148 // Get routing_id for sending message to the ServiceWorkerVersion | 153 // Get routing_id for sending message to the ServiceWorkerVersion |
| 149 // in the browser process. | 154 // in the browser process. |
| 150 int GetRoutingID() const { return embedded_worker_id_; } | 155 int GetRoutingID() const { return embedded_worker_id_; } |
| 151 | 156 |
| 152 void Send(IPC::Message* message); | 157 void Send(IPC::Message* message); |
| 153 void SendWorkerStarted(); | 158 void SendWorkerStarted(); |
| 154 void SetRegistrationInServiceWorkerGlobalScope(); | 159 void SetRegistrationInServiceWorkerGlobalScope(); |
| 155 | 160 |
| 156 void OnActivateEvent(int request_id); | 161 void OnActivateEvent(int request_id); |
| 157 void OnInstallEvent(int request_id); | 162 void OnInstallEvent(int request_id); |
| 158 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); | 163 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); |
| 159 void OnSyncEvent(int request_id); | |
| 160 void OnNotificationClickEvent( | 164 void OnNotificationClickEvent( |
| 161 int request_id, | 165 int request_id, |
| 162 int64_t persistent_notification_id, | 166 int64_t persistent_notification_id, |
| 163 const PlatformNotificationData& notification_data); | 167 const PlatformNotificationData& notification_data); |
| 164 void OnPushEvent(int request_id, const std::string& data); | 168 void OnPushEvent(int request_id, const std::string& data); |
| 165 void OnGeofencingEvent(int request_id, | 169 void OnGeofencingEvent(int request_id, |
| 166 blink::WebGeofencingEventType event_type, | 170 blink::WebGeofencingEventType event_type, |
| 167 const std::string& region_id, | 171 const std::string& region_id, |
| 168 const blink::WebCircularGeofencingRegion& region); | 172 const blink::WebCircularGeofencingRegion& region); |
| 169 void OnCrossOriginConnectEvent(int request_id, | 173 void OnCrossOriginConnectEvent(int request_id, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 std::map<int, base::TimeTicks> install_start_timings_; | 230 std::map<int, base::TimeTicks> install_start_timings_; |
| 227 std::map<int, base::TimeTicks> notification_click_start_timings_; | 231 std::map<int, base::TimeTicks> notification_click_start_timings_; |
| 228 std::map<int, base::TimeTicks> push_start_timings_; | 232 std::map<int, base::TimeTicks> push_start_timings_; |
| 229 | 233 |
| 230 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); | 234 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); |
| 231 }; | 235 }; |
| 232 | 236 |
| 233 } // namespace content | 237 } // namespace content |
| 234 | 238 |
| 235 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ | 239 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ |
| OLD | NEW |