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 createServiceWorkerNetworkProvider (also called 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 base::MessageLoopProxy* main_thread_proxy() const { | 74 base::MessageLoopProxy* main_thread_proxy() const { |
68 return main_thread_proxy_; | 75 return main_thread_proxy_; |
69 } | 76 } |
70 | 77 |
71 private: | 78 private: |
72 void OnSendMessageToWorker(int thread_id, | 79 void OnSendMessageToWorker(int thread_id, |
(...skipping 12 matching lines...) Expand all Loading... |
85 scoped_ptr<ServiceWorkerScriptContext> script_context_; | 92 scoped_ptr<ServiceWorkerScriptContext> script_context_; |
86 | 93 |
87 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; | 94 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; |
88 | 95 |
89 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); | 96 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); |
90 }; | 97 }; |
91 | 98 |
92 } // namespace content | 99 } // namespace content |
93 | 100 |
94 #endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ | 101 #endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ |
OLD | NEW |