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