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