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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 namespace content { | 52 namespace content { |
53 | 53 |
54 struct PlatformNotificationData; | 54 struct PlatformNotificationData; |
55 struct PushEventPayload; | 55 struct PushEventPayload; |
56 struct ServiceWorkerClientInfo; | 56 struct ServiceWorkerClientInfo; |
57 class ServiceWorkerProviderContext; | 57 class ServiceWorkerProviderContext; |
58 class ServiceWorkerContextClient; | 58 class ServiceWorkerContextClient; |
59 class ThreadSafeSender; | 59 class ThreadSafeSender; |
60 class WebServiceWorkerRegistrationImpl; | 60 class WebServiceWorkerRegistrationImpl; |
| 61 class EmbeddedWorkerInstanceClientImpl; |
61 | 62 |
62 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. | 63 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. |
63 // Unless otherwise noted, all methods are called on the worker thread. | 64 // Unless otherwise noted, all methods are called on the worker thread. |
64 class ServiceWorkerContextClient | 65 class ServiceWorkerContextClient |
65 : public blink::WebServiceWorkerContextClient { | 66 : public blink::WebServiceWorkerContextClient { |
66 public: | 67 public: |
67 using SyncCallback = | 68 using SyncCallback = |
68 base::Callback<void(blink::mojom::ServiceWorkerEventStatus, | 69 base::Callback<void(blink::mojom::ServiceWorkerEventStatus, |
69 double /* dispatch_event_time */)>; | 70 double /* dispatch_event_time */)>; |
70 | 71 |
71 // Returns a thread-specific client instance. This does NOT create a | 72 // Returns a thread-specific client instance. This does NOT create a |
72 // new instance. | 73 // new instance. |
73 static ServiceWorkerContextClient* ThreadSpecificInstance(); | 74 static ServiceWorkerContextClient* ThreadSpecificInstance(); |
74 | 75 |
75 // Called on the main thread. | 76 // Called on the main thread. |
76 ServiceWorkerContextClient(int embedded_worker_id, | 77 ServiceWorkerContextClient( |
77 int64_t service_worker_version_id, | 78 int embedded_worker_id, |
78 const GURL& service_worker_scope, | 79 int64_t service_worker_version_id, |
79 const GURL& script_url, | 80 const GURL& service_worker_scope, |
80 int worker_devtools_agent_route_id); | 81 const GURL& script_url, |
| 82 int worker_devtools_agent_route_id, |
| 83 std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker); |
81 ~ServiceWorkerContextClient() override; | 84 ~ServiceWorkerContextClient() override; |
82 | 85 |
83 void OnMessageReceived(int thread_id, | 86 void OnMessageReceived(int thread_id, |
84 int embedded_worker_id, | 87 int embedded_worker_id, |
85 const IPC::Message& message); | 88 const IPC::Message& message); |
86 | 89 |
87 // Called some time after the worker has started. | 90 // Called some time after the worker has started. |
88 void BindInterfaceProviders( | 91 void BindInterfaceProviders( |
89 shell::mojom::InterfaceProviderRequest request, | 92 shell::mojom::InterfaceProviderRequest request, |
90 shell::mojom::InterfaceProviderPtr remote_interfaces); | 93 shell::mojom::InterfaceProviderPtr remote_interfaces); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 const int worker_devtools_agent_route_id_; | 254 const int worker_devtools_agent_route_id_; |
252 scoped_refptr<ThreadSafeSender> sender_; | 255 scoped_refptr<ThreadSafeSender> sender_; |
253 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 256 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
254 scoped_refptr<base::TaskRunner> worker_task_runner_; | 257 scoped_refptr<base::TaskRunner> worker_task_runner_; |
255 | 258 |
256 scoped_refptr<ServiceWorkerProviderContext> provider_context_; | 259 scoped_refptr<ServiceWorkerProviderContext> provider_context_; |
257 | 260 |
258 // Not owned; this object is destroyed when proxy_ becomes invalid. | 261 // Not owned; this object is destroyed when proxy_ becomes invalid. |
259 blink::WebServiceWorkerContextProxy* proxy_; | 262 blink::WebServiceWorkerContextProxy* proxy_; |
260 | 263 |
| 264 // Renderer-side object corresponding to WebEmbeddedWorkerInstance |
| 265 std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client_; |
| 266 |
261 // Initialized on the worker thread in workerContextStarted and | 267 // Initialized on the worker thread in workerContextStarted and |
262 // destructed on the worker thread in willDestroyWorkerContext. | 268 // destructed on the worker thread in willDestroyWorkerContext. |
263 std::unique_ptr<WorkerContextData> context_; | 269 std::unique_ptr<WorkerContextData> context_; |
264 | 270 |
265 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); | 271 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); |
266 }; | 272 }; |
267 | 273 |
268 } // namespace content | 274 } // namespace content |
269 | 275 |
270 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ | 276 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ |
OLD | NEW |