OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ | 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ |
6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ | 6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "content/common/service_worker/service_worker_types.h" | 11 #include "content/common/service_worker/service_worker_types.h" |
12 #include "ipc/ipc_listener.h" | 12 #include "ipc/ipc_listener.h" |
13 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" | 13 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class SingleThreadTaskRunner; | 17 class SingleThreadTaskRunner; |
18 class TaskRunner; | 18 class TaskRunner; |
19 } | 19 } |
20 | 20 |
21 namespace blink { | 21 namespace blink { |
22 class WebDataSource; | 22 class WebDataSource; |
23 class WebServiceWorkerProvider; | 23 class WebServiceWorkerProvider; |
24 } | 24 } |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 | 27 |
28 class ServiceWorkerMessageSender; | |
29 class ServiceWorkerProviderContext; | 28 class ServiceWorkerProviderContext; |
30 class ServiceWorkerScriptContext; | 29 class ServiceWorkerScriptContext; |
31 class ThreadSafeSender; | 30 class ThreadSafeSender; |
32 | 31 |
33 // This class provides access to/from an embedded worker's WorkerGlobalScope. | 32 // This class provides access to/from an embedded worker's WorkerGlobalScope. |
34 // Unless otherwise noted, all methods are called on the worker thread. | 33 // Unless otherwise noted, all methods are called on the worker thread. |
35 // | 34 // |
36 // TODO(kinuko): Currently EW/SW separation is made a little hazily. | 35 // TODO(kinuko): Currently EW/SW separation is made a little hazily. |
37 // This should implement WebEmbeddedWorkerContextClient | 36 // This should implement WebEmbeddedWorkerContextClient |
38 // or sort of it (which doesn't exist yet) rather than | 37 // or sort of it (which doesn't exist yet) rather than |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 virtual void skipWaiting( | 127 virtual void skipWaiting( |
129 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); | 128 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); |
130 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); | 129 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); |
131 | 130 |
132 // TODO: Implement DevTools related method overrides. | 131 // TODO: Implement DevTools related method overrides. |
133 | 132 |
134 int embedded_worker_id() const { return embedded_worker_id_; } | 133 int embedded_worker_id() const { return embedded_worker_id_; } |
135 base::SingleThreadTaskRunner* main_thread_task_runner() const { | 134 base::SingleThreadTaskRunner* main_thread_task_runner() const { |
136 return main_thread_task_runner_.get(); | 135 return main_thread_task_runner_.get(); |
137 } | 136 } |
138 ServiceWorkerMessageSender* sender() { return sender_.get(); } | 137 ThreadSafeSender* thread_safe_sender() { return sender_.get(); } |
139 | 138 |
140 private: | 139 private: |
141 void OnMessageToWorker(int thread_id, | 140 void OnMessageToWorker(int thread_id, |
142 int embedded_worker_id, | 141 int embedded_worker_id, |
143 const IPC::Message& message); | 142 const IPC::Message& message); |
144 void SendWorkerStarted(); | 143 void SendWorkerStarted(); |
145 void SetRegistrationInServiceWorkerGlobalScope(); | 144 void SetRegistrationInServiceWorkerGlobalScope(); |
146 | 145 |
147 const int embedded_worker_id_; | 146 const int embedded_worker_id_; |
148 const int64 service_worker_version_id_; | 147 const int64 service_worker_version_id_; |
149 const GURL service_worker_scope_; | 148 const GURL service_worker_scope_; |
150 const GURL script_url_; | 149 const GURL script_url_; |
151 const int worker_devtools_agent_route_id_; | 150 const int worker_devtools_agent_route_id_; |
152 scoped_refptr<ServiceWorkerMessageSender> sender_; | 151 scoped_refptr<ThreadSafeSender> sender_; |
153 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 152 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
154 scoped_refptr<base::TaskRunner> worker_task_runner_; | 153 scoped_refptr<base::TaskRunner> worker_task_runner_; |
155 | 154 |
156 scoped_ptr<ServiceWorkerScriptContext> script_context_; | 155 scoped_ptr<ServiceWorkerScriptContext> script_context_; |
157 scoped_refptr<ServiceWorkerProviderContext> provider_context_; | 156 scoped_refptr<ServiceWorkerProviderContext> provider_context_; |
158 | 157 |
159 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; | 158 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; |
160 | 159 |
161 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); | 160 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); |
162 }; | 161 }; |
163 | 162 |
164 } // namespace content | 163 } // namespace content |
165 | 164 |
166 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ | 165 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ |
OLD | NEW |