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_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ | 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ |
6 #define CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ | 6 #define CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_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 MessageLoopProxy; | 17 class MessageLoopProxy; |
18 class TaskRunner; | 18 class TaskRunner; |
19 } | 19 } |
20 | 20 |
| 21 namespace blink { |
| 22 class WebDataSource; |
| 23 } |
| 24 |
21 namespace content { | 25 namespace content { |
22 | 26 |
23 class ServiceWorkerScriptContext; | 27 class ServiceWorkerScriptContext; |
24 class ThreadSafeSender; | 28 class ThreadSafeSender; |
25 | 29 |
26 // This class provides access to/from an embedded worker's WorkerGlobalScope. | 30 // This class provides access to/from an embedded worker's WorkerGlobalScope. |
27 // All methods other than the constructor (it's created on the main thread) | 31 // All methods other than the constructor (it's created on the main thread) |
| 32 // and didCreateDataSource (which is also created on the main thread) |
28 // are called on the worker thread. | 33 // are called on the worker thread. |
29 // | 34 // |
30 // TODO(kinuko): Currently EW/SW separation is made a little hazily. | 35 // TODO(kinuko): Currently EW/SW separation is made a little hazily. |
31 // This should implement WebEmbeddedWorkerContextClient | 36 // This should implement WebEmbeddedWorkerContextClient |
32 // or sort of it (which doesn't exist yet) rather than | 37 // or sort of it (which doesn't exist yet) rather than |
33 // WebServiceWorkerContextClient if we want to separate them more cleanly, | 38 // WebServiceWorkerContextClient if we want to separate them more cleanly, |
34 // or ServiceWorkerScriptContext should be merged into this class | 39 // or ServiceWorkerScriptContext should be merged into this class |
35 // if we consider EW == SW script context. | 40 // if we consider EW == SW script context. |
36 class EmbeddedWorkerContextClient | 41 class EmbeddedWorkerContextClient |
37 : public blink::WebServiceWorkerContextClient { | 42 : public blink::WebServiceWorkerContextClient { |
(...skipping 15 matching lines...) Expand all Loading... |
53 // WebServiceWorkerContextClient overrides, some of them are just dispatched | 58 // WebServiceWorkerContextClient overrides, some of them are just dispatched |
54 // on to script_context_. | 59 // on to script_context_. |
55 virtual void workerContextFailedToStart(); | 60 virtual void workerContextFailedToStart(); |
56 virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy); | 61 virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy); |
57 virtual void workerContextDestroyed(); | 62 virtual void workerContextDestroyed(); |
58 virtual void didHandleInstallEvent(int request_id); | 63 virtual void didHandleInstallEvent(int request_id); |
59 virtual void didHandleFetchEvent(int request_id); | 64 virtual void didHandleFetchEvent(int request_id); |
60 virtual void didHandleFetchEvent( | 65 virtual void didHandleFetchEvent( |
61 int request_id, | 66 int request_id, |
62 const blink::WebServiceWorkerResponse& response); | 67 const blink::WebServiceWorkerResponse& response); |
| 68 virtual blink::WebServiceWorkerNetworkProvider* |
| 69 createServiceWorkerNetworkProvider(blink::WebDataSource* data_source); |
63 | 70 |
64 // TODO: Implement DevTools related method overrides. | 71 // TODO: Implement DevTools related method overrides. |
65 | 72 |
66 int embedded_worker_id() const { return embedded_worker_id_; } | 73 int embedded_worker_id() const { return embedded_worker_id_; } |
67 | 74 |
68 private: | 75 private: |
69 void OnSendMessageToWorker(int thread_id, | 76 void OnSendMessageToWorker(int thread_id, |
70 int embedded_worker_id, | 77 int embedded_worker_id, |
71 int request_id, | 78 int request_id, |
72 const IPC::Message& message); | 79 const IPC::Message& message); |
73 void SendWorkerStarted(); | 80 void SendWorkerStarted(); |
74 | 81 |
75 const int embedded_worker_id_; | 82 const int embedded_worker_id_; |
76 const int64 service_worker_version_id_; | 83 const int64 service_worker_version_id_; |
77 const GURL script_url_; | 84 const GURL script_url_; |
78 scoped_refptr<ThreadSafeSender> sender_; | 85 scoped_refptr<ThreadSafeSender> sender_; |
79 scoped_refptr<base::MessageLoopProxy> main_thread_proxy_; | 86 scoped_refptr<base::MessageLoopProxy> main_thread_proxy_; |
80 scoped_refptr<base::TaskRunner> worker_task_runner_; | 87 scoped_refptr<base::TaskRunner> worker_task_runner_; |
81 | 88 |
82 scoped_ptr<ServiceWorkerScriptContext> script_context_; | 89 scoped_ptr<ServiceWorkerScriptContext> script_context_; |
83 | 90 |
84 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; | 91 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; |
85 | 92 |
86 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); | 93 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); |
87 }; | 94 }; |
88 | 95 |
89 } // namespace content | 96 } // namespace content |
90 | 97 |
91 #endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ | 98 #endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ |
OLD | NEW |