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 MessageLoopProxy; | 17 class MessageLoopProxy; |
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 } | 24 } |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 | 27 |
27 class ServiceWorkerProviderContext; | 28 class ServiceWorkerProviderContext; |
28 class ServiceWorkerScriptContext; | 29 class ServiceWorkerScriptContext; |
29 class ThreadSafeSender; | 30 class ThreadSafeSender; |
30 | 31 |
31 // This class provides access to/from an embedded worker's WorkerGlobalScope. | 32 // This class provides access to/from an embedded worker's WorkerGlobalScope. |
32 // All methods other than the constructor (it's created on the main thread) | 33 // Unless otherwise noted, all methods are called on the worker thread. |
33 // and createServiceWorkerNetworkProvider (also called on the main thread) | |
34 // 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 |
39 // WebServiceWorkerContextClient if we want to separate them more cleanly, | 38 // WebServiceWorkerContextClient if we want to separate them more cleanly, |
40 // or ServiceWorkerScriptContext should be merged into this class | 39 // or ServiceWorkerScriptContext should be merged into this class |
41 // if we consider EW == SW script context. | 40 // if we consider EW == SW script context. |
42 class EmbeddedWorkerContextClient | 41 class EmbeddedWorkerContextClient |
43 : public blink::WebServiceWorkerContextClient { | 42 : public blink::WebServiceWorkerContextClient { |
44 public: | 43 public: |
45 // Returns a thread-specific client instance. This does NOT create a | 44 // Returns a thread-specific client instance. This does NOT create a |
46 // new instance. | 45 // new instance. |
47 static EmbeddedWorkerContextClient* ThreadSpecificInstance(); | 46 static EmbeddedWorkerContextClient* ThreadSpecificInstance(); |
48 | 47 |
| 48 // Called on the main thread. |
49 EmbeddedWorkerContextClient(int embedded_worker_id, | 49 EmbeddedWorkerContextClient(int embedded_worker_id, |
50 int64 service_worker_version_id, | 50 int64 service_worker_version_id, |
51 const GURL& service_worker_scope, | 51 const GURL& service_worker_scope, |
52 const GURL& script_url, | 52 const GURL& script_url, |
53 int worker_devtools_agent_route_id); | 53 int worker_devtools_agent_route_id); |
54 | 54 |
55 virtual ~EmbeddedWorkerContextClient(); | 55 virtual ~EmbeddedWorkerContextClient(); |
56 | 56 |
57 bool OnMessageReceived(const IPC::Message& msg); | 57 bool OnMessageReceived(const IPC::Message& msg); |
58 | 58 |
59 void Send(IPC::Message* message); | 59 void Send(IPC::Message* message); |
60 | 60 |
61 // WebServiceWorkerContextClient overrides, some of them are just dispatched | 61 // WebServiceWorkerContextClient overrides, some of them are just dispatched |
62 // on to script_context_. | 62 // on to script_context_. |
63 virtual blink::WebURL scope() const; | 63 virtual blink::WebURL scope() const; |
64 virtual blink::WebServiceWorkerCacheStorage* cacheStorage(); | 64 virtual blink::WebServiceWorkerCacheStorage* cacheStorage(); |
65 virtual void didPauseAfterDownload(); | 65 virtual void didPauseAfterDownload(); |
66 virtual void getClients(blink::WebServiceWorkerClientsCallbacks*); | 66 virtual void getClients(blink::WebServiceWorkerClientsCallbacks*); |
67 virtual void openWindow(const blink::WebURL&, | 67 virtual void openWindow(const blink::WebURL&, |
68 blink::WebServiceWorkerClientCallbacks*); | 68 blink::WebServiceWorkerClientCallbacks*); |
69 virtual void workerReadyForInspection(); | 69 virtual void workerReadyForInspection(); |
| 70 |
| 71 // Called on the main thread. |
70 virtual void workerContextFailedToStart(); | 72 virtual void workerContextFailedToStart(); |
| 73 |
71 virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy); | 74 virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy); |
72 virtual void didEvaluateWorkerScript(bool success); | 75 virtual void didEvaluateWorkerScript(bool success); |
73 virtual void willDestroyWorkerContext(); | 76 virtual void willDestroyWorkerContext(); |
74 virtual void workerContextDestroyed(); | 77 virtual void workerContextDestroyed(); |
75 virtual void reportException(const blink::WebString& error_message, | 78 virtual void reportException(const blink::WebString& error_message, |
76 int line_number, | 79 int line_number, |
77 int column_number, | 80 int column_number, |
78 const blink::WebString& source_url); | 81 const blink::WebString& source_url); |
79 virtual void reportConsoleMessage(int source, | 82 virtual void reportConsoleMessage(int source, |
80 int level, | 83 int level, |
(...skipping 12 matching lines...) Expand all Loading... |
93 int request_id, | 96 int request_id, |
94 const blink::WebServiceWorkerResponse& response); | 97 const blink::WebServiceWorkerResponse& response); |
95 virtual void didHandleNotificationClickEvent( | 98 virtual void didHandleNotificationClickEvent( |
96 int request_id, | 99 int request_id, |
97 blink::WebServiceWorkerEventResult result); | 100 blink::WebServiceWorkerEventResult result); |
98 virtual void didHandlePushEvent(int request_id, | 101 virtual void didHandlePushEvent(int request_id, |
99 blink::WebServiceWorkerEventResult result); | 102 blink::WebServiceWorkerEventResult result); |
100 virtual void didHandleSyncEvent(int request_id); | 103 virtual void didHandleSyncEvent(int request_id); |
101 virtual void didHandleCrossOriginConnectEvent(int request_id, | 104 virtual void didHandleCrossOriginConnectEvent(int request_id, |
102 bool accept_connection); | 105 bool accept_connection); |
| 106 |
| 107 // Called on the main thread. |
103 virtual blink::WebServiceWorkerNetworkProvider* | 108 virtual blink::WebServiceWorkerNetworkProvider* |
104 createServiceWorkerNetworkProvider(blink::WebDataSource* data_source); | 109 createServiceWorkerNetworkProvider(blink::WebDataSource* data_source); |
| 110 virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider(); |
| 111 |
105 virtual void postMessageToClient( | 112 virtual void postMessageToClient( |
106 int client_id, | 113 int client_id, |
107 const blink::WebString& message, | 114 const blink::WebString& message, |
108 blink::WebMessagePortChannelArray* channels); | 115 blink::WebMessagePortChannelArray* channels); |
109 virtual void postMessageToCrossOriginClient( | 116 virtual void postMessageToCrossOriginClient( |
110 const blink::WebCrossOriginServiceWorkerClient& client, | 117 const blink::WebCrossOriginServiceWorkerClient& client, |
111 const blink::WebString& message, | 118 const blink::WebString& message, |
112 blink::WebMessagePortChannelArray* channels); | 119 blink::WebMessagePortChannelArray* channels); |
113 virtual void focus(int client_id, | 120 virtual void focus(int client_id, |
114 blink::WebServiceWorkerClientFocusCallback*); | 121 blink::WebServiceWorkerClientFocusCallback*); |
(...skipping 29 matching lines...) Expand all Loading... |
144 scoped_refptr<ServiceWorkerProviderContext> provider_context_; | 151 scoped_refptr<ServiceWorkerProviderContext> provider_context_; |
145 | 152 |
146 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; | 153 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; |
147 | 154 |
148 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); | 155 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); |
149 }; | 156 }; |
150 | 157 |
151 } // namespace content | 158 } // namespace content |
152 | 159 |
153 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ | 160 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ |
OLD | NEW |