OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef WebEmbeddedWorkerImpl_h | 31 #ifndef WebEmbeddedWorkerImpl_h |
32 #define WebEmbeddedWorkerImpl_h | 32 #define WebEmbeddedWorkerImpl_h |
33 | 33 |
| 34 #include "core/workers/WorkerLoaderProxy.h" |
| 35 |
34 #include "public/web/WebContentSecurityPolicy.h" | 36 #include "public/web/WebContentSecurityPolicy.h" |
35 #include "public/web/WebDevToolsAgentClient.h" | 37 #include "public/web/WebDevToolsAgentClient.h" |
36 #include "public/web/WebEmbeddedWorker.h" | 38 #include "public/web/WebEmbeddedWorker.h" |
37 #include "public/web/WebEmbeddedWorkerStartData.h" | 39 #include "public/web/WebEmbeddedWorkerStartData.h" |
38 #include "public/web/WebFrameClient.h" | 40 #include "public/web/WebFrameClient.h" |
39 | 41 |
40 namespace blink { | 42 namespace blink { |
41 | 43 |
42 class ServiceWorkerGlobalScopeProxy; | 44 class ServiceWorkerGlobalScopeProxy; |
43 class WebServiceWorkerNetworkProvider; | 45 class WebServiceWorkerNetworkProvider; |
44 class WebView; | 46 class WebView; |
45 class WorkerInspectorProxy; | 47 class WorkerInspectorProxy; |
46 class WorkerThread; | 48 class WorkerThread; |
47 | 49 |
48 class WebEmbeddedWorkerImpl final | 50 class WebEmbeddedWorkerImpl final |
49 : public WebEmbeddedWorker | 51 : public WebEmbeddedWorker |
50 , public WebFrameClient | 52 , public WebFrameClient |
51 , public WebDevToolsAgentClient { | 53 , public WebDevToolsAgentClient |
| 54 , private WorkerLoaderProxyProvider { |
52 WTF_MAKE_NONCOPYABLE(WebEmbeddedWorkerImpl); | 55 WTF_MAKE_NONCOPYABLE(WebEmbeddedWorkerImpl); |
53 public: | 56 public: |
54 WebEmbeddedWorkerImpl( | 57 WebEmbeddedWorkerImpl(PassOwnPtr<WebServiceWorkerContextClient>, PassOwnPtr<
WebWorkerPermissionClientProxy>); |
55 PassOwnPtr<WebServiceWorkerContextClient>, | |
56 PassOwnPtr<WebWorkerPermissionClientProxy>); | |
57 virtual ~WebEmbeddedWorkerImpl(); | 58 virtual ~WebEmbeddedWorkerImpl(); |
58 | 59 |
59 // Terminate all WebEmbeddedWorkerImpl for testing purposes. | 60 // Terminate all WebEmbeddedWorkerImpl for testing purposes. |
60 // Note that this only schedules termination and | 61 // Note that this only schedules termination and |
61 // does not synchronously wait for it to complete. | 62 // does not synchronously wait for it to complete. |
62 static void terminateAll(); | 63 static void terminateAll(); |
63 | 64 |
64 // WebEmbeddedWorker overrides. | 65 // WebEmbeddedWorker overrides. |
65 virtual void startWorkerContext(const WebEmbeddedWorkerStartData&) override; | 66 virtual void startWorkerContext(const WebEmbeddedWorkerStartData&) override; |
66 virtual void resumeAfterDownload() override; | 67 virtual void resumeAfterDownload() override; |
67 virtual void terminateWorkerContext() override; | 68 virtual void terminateWorkerContext() override; |
68 virtual void attachDevTools(const WebString& hostId) override; | 69 virtual void attachDevTools(const WebString& hostId) override; |
69 virtual void reattachDevTools(const WebString& hostId, const WebString& save
dState) override; | 70 virtual void reattachDevTools(const WebString& hostId, const WebString& save
dState) override; |
70 virtual void detachDevTools() override; | 71 virtual void detachDevTools() override; |
71 virtual void dispatchDevToolsMessage(const WebString&) override; | 72 virtual void dispatchDevToolsMessage(const WebString&) override; |
72 | 73 |
73 void postMessageToPageInspector(const WTF::String&); | 74 void postMessageToPageInspector(const WTF::String&); |
74 | 75 |
75 private: | 76 private: |
76 class Loader; | 77 class Loader; |
77 class LoaderProxy; | |
78 | 78 |
79 void prepareShadowPageForLoader(); | 79 void prepareShadowPageForLoader(); |
80 void loadShadowPage(); | 80 void loadShadowPage(); |
81 | 81 |
82 // WebFrameClient overrides. | 82 // WebFrameClient overrides. |
83 virtual void willSendRequest( | 83 virtual void willSendRequest( |
84 WebLocalFrame*, unsigned identifier, WebURLRequest&, | 84 WebLocalFrame*, unsigned identifier, WebURLRequest&, |
85 const WebURLResponse& redirectResponse) override; | 85 const WebURLResponse& redirectResponse) override; |
86 virtual void didFinishDocumentLoad(WebLocalFrame*) override; | 86 virtual void didFinishDocumentLoad(WebLocalFrame*) override; |
87 | 87 |
88 // WebDevToolsAgentClient overrides. | 88 // WebDevToolsAgentClient overrides. |
89 virtual void sendProtocolMessage(int callId, const WebString&, const WebStri
ng&) override; | 89 virtual void sendProtocolMessage(int callId, const WebString&, const WebStri
ng&) override; |
90 virtual void resumeStartup() override; | 90 virtual void resumeStartup() override; |
91 | 91 |
92 void onScriptLoaderFinished(); | 92 void onScriptLoaderFinished(); |
93 void startWorkerThread(); | 93 void startWorkerThread(); |
94 | 94 |
| 95 // WorkerLoaderProxyProvider |
| 96 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override; |
| 97 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) o
verride; |
| 98 |
95 WebEmbeddedWorkerStartData m_workerStartData; | 99 WebEmbeddedWorkerStartData m_workerStartData; |
96 | 100 |
97 OwnPtr<WebServiceWorkerContextClient> m_workerContextClient; | 101 OwnPtr<WebServiceWorkerContextClient> m_workerContextClient; |
98 | 102 |
99 // This is kept until startWorkerContext is called, and then passed on | 103 // This is kept until startWorkerContext is called, and then passed on |
100 // to WorkerContext. | 104 // to WorkerContext. |
101 OwnPtr<WebWorkerPermissionClientProxy> m_permissionClient; | 105 OwnPtr<WebWorkerPermissionClientProxy> m_permissionClient; |
102 | 106 |
103 // We retain ownership of this one which is for use on the | 107 // We retain ownership of this one which is for use on the |
104 // main thread only. | 108 // main thread only. |
105 OwnPtr<WebServiceWorkerNetworkProvider> m_networkProvider; | 109 OwnPtr<WebServiceWorkerNetworkProvider> m_networkProvider; |
106 | 110 |
107 // Kept around only while main script loading is ongoing. | 111 // Kept around only while main script loading is ongoing. |
108 OwnPtr<Loader> m_mainScriptLoader; | 112 OwnPtr<Loader> m_mainScriptLoader; |
109 | 113 |
110 RefPtr<WorkerThread> m_workerThread; | 114 RefPtr<WorkerThread> m_workerThread; |
111 OwnPtr<LoaderProxy> m_loaderProxy; | 115 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
112 OwnPtr<ServiceWorkerGlobalScopeProxy> m_workerGlobalScopeProxy; | 116 OwnPtr<ServiceWorkerGlobalScopeProxy> m_workerGlobalScopeProxy; |
113 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; | 117 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; |
114 | 118 |
115 // 'shadow page' - created to proxy loading requests from the worker. | 119 // 'shadow page' - created to proxy loading requests from the worker. |
116 // Both WebView and WebFrame objects are close()'ed (where they're | 120 // Both WebView and WebFrame objects are close()'ed (where they're |
117 // deref'ed) when this EmbeddedWorkerImpl is destructed, therefore they | 121 // deref'ed) when this EmbeddedWorkerImpl is destructed, therefore they |
118 // are guaranteed to exist while this object is around. | 122 // are guaranteed to exist while this object is around. |
119 WebView* m_webView; | 123 WebView* m_webView; |
120 WebFrame* m_mainFrame; | 124 WebFrame* m_mainFrame; |
121 | 125 |
(...skipping 10 matching lines...) Expand all Loading... |
132 DoPauseAfterDownload, | 136 DoPauseAfterDownload, |
133 IsPausedAfterDownload | 137 IsPausedAfterDownload |
134 } m_pauseAfterDownloadState; | 138 } m_pauseAfterDownloadState; |
135 | 139 |
136 WaitingForDebuggerState m_waitingForDebuggerState; | 140 WaitingForDebuggerState m_waitingForDebuggerState; |
137 }; | 141 }; |
138 | 142 |
139 } // namespace blink | 143 } // namespace blink |
140 | 144 |
141 #endif // WebEmbeddedWorkerImpl_h | 145 #endif // WebEmbeddedWorkerImpl_h |
OLD | NEW |