| 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/WorkerThread.h" | 39 #include "core/workers/WorkerScript.h" |
| 40 #include "public/web/WebContentSecurityPolicy.h" | 40 #include "public/web/WebContentSecurityPolicy.h" |
| 41 #include "public/web/WebDevToolsAgentClient.h" | 41 #include "public/web/WebDevToolsAgentClient.h" |
| 42 #include "public/web/WebFrameClient.h" | 42 #include "public/web/WebFrameClient.h" |
| 43 #include "public/web/WebSharedWorkerClient.h" | 43 #include "public/web/WebSharedWorkerClient.h" |
| 44 #include "wtf/PassOwnPtr.h" | 44 #include "wtf/PassOwnPtr.h" |
| 45 #include "wtf/RefPtr.h" | 45 #include "wtf/RefPtr.h" |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 class ConsoleMessage; | 49 class ConsoleMessage; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 75 | 75 |
| 76 // WorkerReportingProxy methods: | 76 // WorkerReportingProxy methods: |
| 77 void reportException( | 77 void reportException( |
| 78 const WTF::String&, int, int, const WTF::String&, int) override; | 78 const WTF::String&, int, int, const WTF::String&, int) override; |
| 79 void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) override; | 79 void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) override; |
| 80 void postMessageToPageInspector(const WTF::String&) override; | 80 void postMessageToPageInspector(const WTF::String&) override; |
| 81 void postWorkerConsoleAgentEnabled() override { } | 81 void postWorkerConsoleAgentEnabled() override { } |
| 82 void didEvaluateWorkerScript(bool success) override { } | 82 void didEvaluateWorkerScript(bool success) override { } |
| 83 void workerGlobalScopeStarted(WorkerGlobalScope*) override; | 83 void workerGlobalScopeStarted(WorkerGlobalScope*) override; |
| 84 void workerGlobalScopeClosed() override; | 84 void workerGlobalScopeClosed() override; |
| 85 void workerThreadTerminated() override; | 85 void workerScriptTerminated() override; |
| 86 void willDestroyWorkerGlobalScope() override { } | 86 void willDestroyWorkerGlobalScope() override { } |
| 87 | 87 |
| 88 // WebFrameClient methods to support resource loading thru the 'shadow page'
. | 88 // WebFrameClient methods to support resource loading thru the 'shadow page'
. |
| 89 WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostC
lient*) override; | 89 WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostC
lient*) override; |
| 90 void willSendRequest(WebLocalFrame*, unsigned identifier, WebURLRequest&, co
nst WebURLResponse& redirectResponse) override; | 90 void willSendRequest(WebLocalFrame*, unsigned identifier, WebURLRequest&, co
nst WebURLResponse& redirectResponse) override; |
| 91 void didFinishDocumentLoad(WebLocalFrame*, bool documentIsEmpty) override; | 91 void didFinishDocumentLoad(WebLocalFrame*, bool documentIsEmpty) override; |
| 92 bool isControlledByServiceWorker(WebDataSource&) override; | 92 bool isControlledByServiceWorker(WebDataSource&) override; |
| 93 int64_t serviceWorkerID(WebDataSource&) override; | 93 int64_t serviceWorkerID(WebDataSource&) override; |
| 94 | 94 |
| 95 // WebDevToolsAgentClient overrides. | 95 // WebDevToolsAgentClient overrides. |
| 96 void sendProtocolMessage(int sessionId, int callId, const WebString&, const
WebString&) override; | 96 void sendProtocolMessage(int sessionId, int callId, const WebString&, const
WebString&) override; |
| 97 void resumeStartup() override; | 97 void resumeStartup() override; |
| 98 | 98 |
| 99 // WebSharedWorker methods: | 99 // WebSharedWorker methods: |
| 100 void startWorkerContext(const WebURL&, const WebString& name, const WebStrin
g& contentSecurityPolicy, WebContentSecurityPolicyType) override; | 100 void startWorkerContext(const WebURL&, const WebString& name, const WebStrin
g& contentSecurityPolicy, WebContentSecurityPolicyType) override; |
| 101 void connect(WebMessagePortChannel*) override; | 101 void connect(WebMessagePortChannel*) override; |
| 102 void terminateWorkerContext() override; | 102 void terminateWorkerContext() override; |
| 103 | 103 |
| 104 void pauseWorkerContextOnStart() override; | 104 void pauseWorkerContextOnStart() override; |
| 105 void attachDevTools(const WebString& hostId, int sessionId) override; | 105 void attachDevTools(const WebString& hostId, int sessionId) override; |
| 106 void reattachDevTools(const WebString& hostId, int sesionId, const WebString
& savedState) override; | 106 void reattachDevTools(const WebString& hostId, int sesionId, const WebString
& savedState) override; |
| 107 void detachDevTools() override; | 107 void detachDevTools() override; |
| 108 void dispatchDevToolsMessage(int sessionId, const WebString&) override; | 108 void dispatchDevToolsMessage(int sessionId, const WebString&) override; |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 ~WebSharedWorkerImpl() override; | 111 ~WebSharedWorkerImpl() override; |
| 112 | 112 |
| 113 void setWorkerThread(PassRefPtr<WorkerThread> thread) { m_workerThread = thr
ead; } | 113 void setWorkerScript(PassRefPtr<WorkerScript> script) { m_workerScript = scr
ipt; } |
| 114 WorkerThread* workerThread() { return m_workerThread.get(); } | 114 WorkerScript* workerScript() { return m_workerScript.get(); } |
| 115 | 115 |
| 116 // Shuts down the worker thread. | 116 // Shuts down the worker thread. |
| 117 void terminateWorkerThread(); | 117 void terminateWorkerScript(); |
| 118 | 118 |
| 119 // Creates the shadow loader used for worker network requests. | 119 // Creates the shadow loader used for worker network requests. |
| 120 void initializeLoader(); | 120 void initializeLoader(); |
| 121 | 121 |
| 122 void loadShadowPage(); | 122 void loadShadowPage(); |
| 123 void didReceiveScriptLoaderResponse(); | 123 void didReceiveScriptLoaderResponse(); |
| 124 void onScriptLoaderFinished(); | 124 void onScriptLoaderFinished(); |
| 125 | 125 |
| 126 static void connectTask(PassOwnPtr<WebMessagePortChannel>, ExecutionContext*
); | 126 static void connectTask(PassOwnPtr<WebMessagePortChannel>, ExecutionContext*
); |
| 127 // Tasks that are run on the main thread. | 127 // Tasks that are run on the main thread. |
| 128 void workerGlobalScopeClosedOnMainThread(); | 128 void workerGlobalScopeClosedOnMainThread(); |
| 129 void workerThreadTerminatedOnMainThread(); | 129 void workerScriptTerminatedOnMainThread(); |
| 130 | 130 |
| 131 void postMessageToPageInspectorOnMainThread(const String& message); | 131 void postMessageToPageInspectorOnMainThread(const String& message); |
| 132 | 132 |
| 133 // WorkerLoaderProxyProvider | 133 // WorkerLoaderProxyProvider |
| 134 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>); | 134 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>); |
| 135 bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>); | 135 bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>); |
| 136 | 136 |
| 137 // 'shadow page' - created to proxy loading requests from the worker. | 137 // 'shadow page' - created to proxy loading requests from the worker. |
| 138 RefPtrWillBePersistent<ExecutionContext> m_loadingDocument; | 138 RefPtrWillBePersistent<ExecutionContext> m_loadingDocument; |
| 139 WebView* m_webView; | 139 WebView* m_webView; |
| 140 RefPtrWillBePersistent<WebLocalFrameImpl> m_mainFrame; | 140 RefPtrWillBePersistent<WebLocalFrameImpl> m_mainFrame; |
| 141 bool m_askedToTerminate; | 141 bool m_askedToTerminate; |
| 142 | 142 |
| 143 // This one is bound to and used only on the main thread. | 143 // This one is bound to and used only on the main thread. |
| 144 OwnPtr<WebServiceWorkerNetworkProvider> m_networkProvider; | 144 OwnPtr<WebServiceWorkerNetworkProvider> m_networkProvider; |
| 145 | 145 |
| 146 OwnPtrWillBePersistent<WorkerInspectorProxy> m_workerInspectorProxy; | 146 OwnPtrWillBePersistent<WorkerInspectorProxy> m_workerInspectorProxy; |
| 147 | 147 |
| 148 RefPtr<WorkerThread> m_workerThread; | 148 RefPtr<WorkerScript> m_workerScript; |
| 149 | 149 |
| 150 WebSharedWorkerClient* m_client; | 150 WebSharedWorkerClient* m_client; |
| 151 | 151 |
| 152 bool m_pauseWorkerContextOnStart; | 152 bool m_pauseWorkerContextOnStart; |
| 153 bool m_isPausedOnStart; | 153 bool m_isPausedOnStart; |
| 154 | 154 |
| 155 // Kept around only while main script loading is ongoing. | 155 // Kept around only while main script loading is ongoing. |
| 156 RefPtr<WorkerScriptLoader> m_mainScriptLoader; | 156 RefPtr<WorkerScriptLoader> m_mainScriptLoader; |
| 157 | 157 |
| 158 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 158 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 159 | 159 |
| 160 WebURL m_url; | 160 WebURL m_url; |
| 161 WebString m_name; | 161 WebString m_name; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 } // namespace blink | 164 } // namespace blink |
| 165 | 165 |
| 166 #endif // WebSharedWorkerImpl_h | 166 #endif // WebSharedWorkerImpl_h |
| OLD | NEW |