OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 #ifndef WebSharedWorkerImpl_h | 31 #ifndef WebSharedWorkerImpl_h |
32 #define WebSharedWorkerImpl_h | 32 #define WebSharedWorkerImpl_h |
33 | 33 |
34 #include "public/web/WebSharedWorker.h" | 34 #include "public/web/WebSharedWorker.h" |
35 | 35 |
36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
37 #include "core/workers/WorkerLoaderProxy.h" | 37 #include "core/workers/WorkerLoaderProxy.h" |
38 #include "core/workers/WorkerReportingProxy.h" | 38 #include "core/workers/WorkerReportingProxy.h" |
| 39 #include "core/workers/WorkerScript.h" |
39 #include "core/workers/WorkerScriptLoaderClient.h" | 40 #include "core/workers/WorkerScriptLoaderClient.h" |
40 #include "core/workers/WorkerThread.h" | |
41 #include "public/web/WebContentSecurityPolicy.h" | 41 #include "public/web/WebContentSecurityPolicy.h" |
42 #include "public/web/WebDevToolsAgentClient.h" | 42 #include "public/web/WebDevToolsAgentClient.h" |
43 #include "public/web/WebFrameClient.h" | 43 #include "public/web/WebFrameClient.h" |
44 #include "public/web/WebSharedWorkerClient.h" | 44 #include "public/web/WebSharedWorkerClient.h" |
45 #include "wtf/PassOwnPtr.h" | 45 #include "wtf/PassOwnPtr.h" |
46 #include "wtf/RefPtr.h" | 46 #include "wtf/RefPtr.h" |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 class ConsoleMessage; | 50 class ConsoleMessage; |
(...skipping 22 matching lines...) Expand all Loading... |
73 | 73 |
74 // WorkerReportingProxy methods: | 74 // WorkerReportingProxy methods: |
75 virtual void reportException( | 75 virtual void reportException( |
76 const WTF::String&, int, int, const WTF::String&, int) override; | 76 const WTF::String&, int, int, const WTF::String&, int) override; |
77 virtual void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) ov
erride; | 77 virtual void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) ov
erride; |
78 virtual void postMessageToPageInspector(const WTF::String&) override; | 78 virtual void postMessageToPageInspector(const WTF::String&) override; |
79 virtual void postWorkerConsoleAgentEnabled() override { } | 79 virtual void postWorkerConsoleAgentEnabled() override { } |
80 virtual void didEvaluateWorkerScript(bool success) override { }; | 80 virtual void didEvaluateWorkerScript(bool success) override { }; |
81 virtual void workerGlobalScopeStarted(WorkerGlobalScope*) override; | 81 virtual void workerGlobalScopeStarted(WorkerGlobalScope*) override; |
82 virtual void workerGlobalScopeClosed() override; | 82 virtual void workerGlobalScopeClosed() override; |
83 virtual void workerThreadTerminated() override; | 83 virtual void workerScriptTerminated() override; |
84 virtual void willDestroyWorkerGlobalScope() override { } | 84 virtual void willDestroyWorkerGlobalScope() override { } |
85 | 85 |
86 // WebFrameClient methods to support resource loading thru the 'shadow page'
. | 86 // WebFrameClient methods to support resource loading thru the 'shadow page'
. |
87 virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*,
WebApplicationCacheHostClient*) override; | 87 virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*,
WebApplicationCacheHostClient*) override; |
88 virtual void willSendRequest(WebLocalFrame*, unsigned identifier, WebURLRequ
est&, const WebURLResponse& redirectResponse) override; | 88 virtual void willSendRequest(WebLocalFrame*, unsigned identifier, WebURLRequ
est&, const WebURLResponse& redirectResponse) override; |
89 virtual void didFinishDocumentLoad(WebLocalFrame*) override; | 89 virtual void didFinishDocumentLoad(WebLocalFrame*) override; |
90 virtual bool isControlledByServiceWorker(WebDataSource&) override; | 90 virtual bool isControlledByServiceWorker(WebDataSource&) override; |
91 virtual int64_t serviceWorkerID(WebDataSource&) override; | 91 virtual int64_t serviceWorkerID(WebDataSource&) override; |
92 | 92 |
93 // WebDevToolsAgentClient overrides. | 93 // WebDevToolsAgentClient overrides. |
(...skipping 12 matching lines...) Expand all Loading... |
106 virtual void detachDevTools() override; | 106 virtual void detachDevTools() override; |
107 virtual void dispatchDevToolsMessage(const WebString&) override; | 107 virtual void dispatchDevToolsMessage(const WebString&) override; |
108 | 108 |
109 private: | 109 private: |
110 class Loader; | 110 class Loader; |
111 | 111 |
112 virtual ~WebSharedWorkerImpl(); | 112 virtual ~WebSharedWorkerImpl(); |
113 | 113 |
114 WebSharedWorkerClient* client() { return m_client->get(); } | 114 WebSharedWorkerClient* client() { return m_client->get(); } |
115 | 115 |
116 void setWorkerThread(PassRefPtr<WorkerThread> thread) { m_workerThread = thr
ead; } | 116 void setWorkerThread(PassRefPtr<WorkerScript> thread) { m_workerScript = thr
ead; } |
117 WorkerThread* workerThread() { return m_workerThread.get(); } | 117 WorkerScript* workerScript() { return m_workerScript.get(); } |
118 | 118 |
119 // Shuts down the worker thread. | 119 // Shuts down the worker thread. |
120 void stopWorkerThread(); | 120 void stopWorkerThread(); |
121 | 121 |
122 // Creates the shadow loader used for worker network requests. | 122 // Creates the shadow loader used for worker network requests. |
123 void initializeLoader(); | 123 void initializeLoader(); |
124 | 124 |
125 void loadShadowPage(); | 125 void loadShadowPage(); |
126 void didReceiveScriptLoaderResponse(); | 126 void didReceiveScriptLoaderResponse(); |
127 void onScriptLoaderFinished(); | 127 void onScriptLoaderFinished(); |
128 | 128 |
129 static void connectTask(PassOwnPtr<WebMessagePortChannel>, ExecutionContext*
); | 129 static void connectTask(PassOwnPtr<WebMessagePortChannel>, ExecutionContext*
); |
130 // Tasks that are run on the main thread. | 130 // Tasks that are run on the main thread. |
131 void workerGlobalScopeClosedOnMainThread(); | 131 void workerGlobalScopeClosedOnMainThread(); |
132 void workerThreadTerminatedOnMainThread(); | 132 void workerScriptTerminatedOnMainThread(); |
133 | 133 |
134 void postMessageToPageInspectorOnMainThread(const String& message); | 134 void postMessageToPageInspectorOnMainThread(const String& message); |
135 | 135 |
136 // WorkerLoaderProxyProvider | 136 // WorkerLoaderProxyProvider |
137 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>); | 137 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>); |
138 bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>); | 138 bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>); |
139 | 139 |
140 // 'shadow page' - created to proxy loading requests from the worker. | 140 // 'shadow page' - created to proxy loading requests from the worker. |
141 RefPtrWillBePersistent<ExecutionContext> m_loadingDocument; | 141 RefPtrWillBePersistent<ExecutionContext> m_loadingDocument; |
142 WebView* m_webView; | 142 WebView* m_webView; |
143 WebLocalFrameImpl* m_mainFrame; | 143 WebLocalFrameImpl* m_mainFrame; |
144 bool m_askedToTerminate; | 144 bool m_askedToTerminate; |
145 | 145 |
146 // This one is bound to and used only on the main thread. | 146 // This one is bound to and used only on the main thread. |
147 OwnPtr<WebServiceWorkerNetworkProvider> m_networkProvider; | 147 OwnPtr<WebServiceWorkerNetworkProvider> m_networkProvider; |
148 | 148 |
149 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; | 149 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; |
150 | 150 |
151 RefPtr<WorkerThread> m_workerThread; | 151 RefPtr<WorkerScript> m_workerScript; |
152 | 152 |
153 // This one's initialized and bound to the main thread. | 153 // This one's initialized and bound to the main thread. |
154 RefPtr<WeakReference<WebSharedWorkerClient>> m_client; | 154 RefPtr<WeakReference<WebSharedWorkerClient>> m_client; |
155 | 155 |
156 // Usually WeakPtr is created by WeakPtrFactory exposed by Client | 156 // Usually WeakPtr is created by WeakPtrFactory exposed by Client |
157 // class itself, but here it's implemented by Chrome so we create | 157 // class itself, but here it's implemented by Chrome so we create |
158 // our own WeakPtr. | 158 // our own WeakPtr. |
159 WeakPtr<WebSharedWorkerClient> m_clientWeakPtr; | 159 WeakPtr<WebSharedWorkerClient> m_clientWeakPtr; |
160 | 160 |
161 bool m_pauseWorkerContextOnStart; | 161 bool m_pauseWorkerContextOnStart; |
162 bool m_isPausedOnStart; | 162 bool m_isPausedOnStart; |
163 | 163 |
164 // Kept around only while main script loading is ongoing. | 164 // Kept around only while main script loading is ongoing. |
165 OwnPtr<Loader> m_mainScriptLoader; | 165 OwnPtr<Loader> m_mainScriptLoader; |
166 | 166 |
167 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 167 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
168 | 168 |
169 WebURL m_url; | 169 WebURL m_url; |
170 WebString m_name; | 170 WebString m_name; |
171 WebString m_contentSecurityPolicy; | 171 WebString m_contentSecurityPolicy; |
172 WebContentSecurityPolicyType m_policyType; | 172 WebContentSecurityPolicyType m_policyType; |
173 }; | 173 }; |
174 | 174 |
175 } // namespace blink | 175 } // namespace blink |
176 | 176 |
177 #endif // WebSharedWorkerImpl_h | 177 #endif // WebSharedWorkerImpl_h |
OLD | NEW |