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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 const blink::WebString& message, | 145 const blink::WebString& message, |
143 blink::WebMessagePortChannelArray* channels); | 146 blink::WebMessagePortChannelArray* channels); |
144 virtual void focus(const blink::WebString& uuid, | 147 virtual void focus(const blink::WebString& uuid, |
145 blink::WebServiceWorkerClientCallbacks*); | 148 blink::WebServiceWorkerClientCallbacks*); |
146 virtual void skipWaiting( | 149 virtual void skipWaiting( |
147 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); | 150 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); |
148 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); | 151 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); |
149 virtual void stashMessagePort(blink::WebMessagePortChannel* channel, | 152 virtual void stashMessagePort(blink::WebMessagePortChannel* channel, |
150 const blink::WebString& name); | 153 const blink::WebString& name); |
151 | 154 |
| 155 virtual void DispatchSyncEvent(const SyncCallback& callback); |
| 156 |
152 private: | 157 private: |
153 struct WorkerContextData; | 158 struct WorkerContextData; |
154 | 159 |
155 // Get routing_id for sending message to the ServiceWorkerVersion | 160 // Get routing_id for sending message to the ServiceWorkerVersion |
156 // in the browser process. | 161 // in the browser process. |
157 int GetRoutingID() const { return embedded_worker_id_; } | 162 int GetRoutingID() const { return embedded_worker_id_; } |
158 | 163 |
159 void Send(IPC::Message* message); | 164 void Send(IPC::Message* message); |
160 void SendWorkerStarted(); | 165 void SendWorkerStarted(); |
161 void SetRegistrationInServiceWorkerGlobalScope(); | 166 void SetRegistrationInServiceWorkerGlobalScope(); |
162 | 167 |
163 void OnActivateEvent(int request_id); | 168 void OnActivateEvent(int request_id); |
164 void OnInstallEvent(int request_id); | 169 void OnInstallEvent(int request_id); |
165 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); | 170 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); |
166 void OnSyncEvent(int request_id); | |
167 void OnNotificationClickEvent( | 171 void OnNotificationClickEvent( |
168 int request_id, | 172 int request_id, |
169 int64_t persistent_notification_id, | 173 int64_t persistent_notification_id, |
170 const PlatformNotificationData& notification_data); | 174 const PlatformNotificationData& notification_data); |
171 void OnPushEvent(int request_id, const std::string& data); | 175 void OnPushEvent(int request_id, const std::string& data); |
172 void OnGeofencingEvent(int request_id, | 176 void OnGeofencingEvent(int request_id, |
173 blink::WebGeofencingEventType event_type, | 177 blink::WebGeofencingEventType event_type, |
174 const std::string& region_id, | 178 const std::string& region_id, |
175 const blink::WebCircularGeofencingRegion& region); | 179 const blink::WebCircularGeofencingRegion& region); |
176 void OnCrossOriginConnectEvent(int request_id, | 180 void OnCrossOriginConnectEvent(int request_id, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // Initialized on the worker thread in workerContextStarted and | 230 // Initialized on the worker thread in workerContextStarted and |
227 // destructed on the worker thread in willDestroyWorkerContext. | 231 // destructed on the worker thread in willDestroyWorkerContext. |
228 scoped_ptr<WorkerContextData> context_; | 232 scoped_ptr<WorkerContextData> context_; |
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 |