| 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 26 matching lines...) Expand all Loading... |
| 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/WorkerScriptLoaderClient.h" | 39 #include "core/workers/WorkerScriptLoaderClient.h" |
| 40 #include "core/workers/WorkerThread.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 #include "wtf/WeakPtr.h" | |
| 48 | 47 |
| 49 namespace blink { | 48 namespace blink { |
| 50 | 49 |
| 51 class ConsoleMessage; | 50 class ConsoleMessage; |
| 52 class WebApplicationCacheHost; | 51 class WebApplicationCacheHost; |
| 53 class WebApplicationCacheHostClient; | 52 class WebApplicationCacheHostClient; |
| 54 class WebString; | 53 class WebString; |
| 55 class WebURL; | 54 class WebURL; |
| 56 class WebView; | 55 class WebView; |
| 57 class WebSharedWorkerClient; | 56 class WebSharedWorkerClient; |
| 58 class WorkerInspectorProxy; | 57 class WorkerInspectorProxy; |
| 59 | 58 |
| 60 // This class is used by the worker process code to talk to the SharedWorker imp
lementation. | 59 // This class is used by the worker process code to talk to the SharedWorker imp
lementation. |
| 61 // It can't use it directly since it uses WebKit types, so this class converts t
he data types. | 60 // It can't use it directly since it uses WebKit types, so this class converts t
he data types. |
| 62 // When the SharedWorker object wants to call WorkerReportingProxy, this class w
ill | 61 // When the SharedWorker object wants to call WorkerReportingProxy, this class w
ill |
| 63 // convert to Chrome data types first and then call the supplied WebCommonWorker
Client. | 62 // convert to Chrome data types first and then call the supplied WebCommonWorker
Client. |
| 64 class WebSharedWorkerImpl final | 63 class WebSharedWorkerImpl final |
| 65 : public WorkerReportingProxy | 64 : public WorkerReportingProxy |
| 66 , public WorkerLoaderProxy | |
| 67 , public WebFrameClient | 65 , public WebFrameClient |
| 68 , public WebSharedWorker | 66 , public WebSharedWorker |
| 69 , public WebDevToolsAgentClient { | 67 , public WebDevToolsAgentClient |
| 68 , private WorkerLoaderProxyProvider { |
| 70 public: | 69 public: |
| 71 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); | 70 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); |
| 72 | 71 |
| 73 // WorkerReportingProxy methods: | 72 // WorkerReportingProxy methods: |
| 74 virtual void reportException( | 73 virtual void reportException( |
| 75 const WTF::String&, int, int, const WTF::String&, int) override; | 74 const WTF::String&, int, int, const WTF::String&, int) override; |
| 76 virtual void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) ov
erride; | 75 virtual void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) ov
erride; |
| 77 virtual void postMessageToPageInspector(const WTF::String&) override; | 76 virtual void postMessageToPageInspector(const WTF::String&) override; |
| 78 virtual void postWorkerConsoleAgentEnabled() override { } | 77 virtual void postWorkerConsoleAgentEnabled() override { } |
| 79 virtual void didEvaluateWorkerScript(bool success) override { }; | 78 virtual void didEvaluateWorkerScript(bool success) override { }; |
| 80 virtual void workerGlobalScopeStarted(WorkerGlobalScope*) override; | 79 virtual void workerGlobalScopeStarted(WorkerGlobalScope*) override; |
| 81 virtual void workerGlobalScopeClosed() override; | 80 virtual void workerGlobalScopeClosed() override; |
| 82 virtual void workerThreadTerminated() override; | 81 virtual void workerThreadTerminated() override; |
| 83 virtual void willDestroyWorkerGlobalScope() override { } | 82 virtual void willDestroyWorkerGlobalScope() override { } |
| 84 | 83 |
| 85 // WorkerLoaderProxy methods: | |
| 86 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override; | |
| 87 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) o
verride; | |
| 88 | |
| 89 // WebFrameClient methods to support resource loading thru the 'shadow page'
. | 84 // WebFrameClient methods to support resource loading thru the 'shadow page'
. |
| 90 virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*,
WebApplicationCacheHostClient*) override; | 85 virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*,
WebApplicationCacheHostClient*) override; |
| 91 virtual void didFinishDocumentLoad(WebLocalFrame*) override; | 86 virtual void didFinishDocumentLoad(WebLocalFrame*) override; |
| 92 | 87 |
| 93 // WebDevToolsAgentClient overrides. | 88 // WebDevToolsAgentClient overrides. |
| 94 virtual void sendProtocolMessage(int callId, const WebString&, const WebStri
ng&) override; | 89 virtual void sendProtocolMessage(int callId, const WebString&, const WebStri
ng&) override; |
| 95 virtual void resumeStartup() override; | 90 virtual void resumeStartup() override; |
| 96 | 91 |
| 97 // WebSharedWorker methods: | 92 // WebSharedWorker methods: |
| 98 virtual void startWorkerContext(const WebURL&, const WebString& name, const
WebString& contentSecurityPolicy, WebContentSecurityPolicyType) override; | 93 virtual void startWorkerContext(const WebURL&, const WebString& name, const
WebString& contentSecurityPolicy, WebContentSecurityPolicyType) override; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 126 void didReceiveScriptLoaderResponse(); | 121 void didReceiveScriptLoaderResponse(); |
| 127 void onScriptLoaderFinished(); | 122 void onScriptLoaderFinished(); |
| 128 | 123 |
| 129 static void connectTask(ExecutionContext*, PassOwnPtr<WebMessagePortChannel>
); | 124 static void connectTask(ExecutionContext*, PassOwnPtr<WebMessagePortChannel>
); |
| 130 // Tasks that are run on the main thread. | 125 // Tasks that are run on the main thread. |
| 131 void workerGlobalScopeClosedOnMainThread(); | 126 void workerGlobalScopeClosedOnMainThread(); |
| 132 void workerThreadTerminatedOnMainThread(); | 127 void workerThreadTerminatedOnMainThread(); |
| 133 | 128 |
| 134 void postMessageToPageInspectorOnMainThread(const String& message); | 129 void postMessageToPageInspectorOnMainThread(const String& message); |
| 135 | 130 |
| 131 // WorkerLoaderProxyProvider |
| 132 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>); |
| 133 bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>); |
| 134 |
| 136 // 'shadow page' - created to proxy loading requests from the worker. | 135 // 'shadow page' - created to proxy loading requests from the worker. |
| 137 RefPtrWillBePersistent<ExecutionContext> m_loadingDocument; | 136 RefPtrWillBePersistent<ExecutionContext> m_loadingDocument; |
| 138 WebView* m_webView; | 137 WebView* m_webView; |
| 139 WebFrame* m_mainFrame; | 138 WebFrame* m_mainFrame; |
| 140 bool m_askedToTerminate; | 139 bool m_askedToTerminate; |
| 141 | 140 |
| 142 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; | 141 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; |
| 143 | 142 |
| 144 RefPtr<WorkerThread> m_workerThread; | 143 RefPtr<WorkerThread> m_workerThread; |
| 145 | 144 |
| 146 // This one's initialized and bound to the main thread. | 145 // This one's initialized and bound to the main thread. |
| 147 RefPtr<WeakReference<WebSharedWorkerClient>> m_client; | 146 RefPtr<WeakReference<WebSharedWorkerClient>> m_client; |
| 148 | 147 |
| 149 // Usually WeakPtr is created by WeakPtrFactory exposed by Client | 148 // Usually WeakPtr is created by WeakPtrFactory exposed by Client |
| 150 // class itself, but here it's implemented by Chrome so we create | 149 // class itself, but here it's implemented by Chrome so we create |
| 151 // our own WeakPtr. | 150 // our own WeakPtr. |
| 152 WeakPtr<WebSharedWorkerClient> m_clientWeakPtr; | 151 WeakPtr<WebSharedWorkerClient> m_clientWeakPtr; |
| 153 | 152 |
| 154 bool m_pauseWorkerContextOnStart; | 153 bool m_pauseWorkerContextOnStart; |
| 155 bool m_isPausedOnStart; | 154 bool m_isPausedOnStart; |
| 156 | 155 |
| 157 // Kept around only while main script loading is ongoing. | 156 // Kept around only while main script loading is ongoing. |
| 158 OwnPtr<Loader> m_mainScriptLoader; | 157 OwnPtr<Loader> m_mainScriptLoader; |
| 158 |
| 159 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 160 |
| 159 WebURL m_url; | 161 WebURL m_url; |
| 160 WebString m_name; | 162 WebString m_name; |
| 161 WebString m_contentSecurityPolicy; | 163 WebString m_contentSecurityPolicy; |
| 162 WebContentSecurityPolicyType m_policyType; | 164 WebContentSecurityPolicyType m_policyType; |
| 163 }; | 165 }; |
| 164 | 166 |
| 165 } // namespace blink | 167 } // namespace blink |
| 166 | 168 |
| 167 #endif | 169 #endif // WebSharedWorkerImpl_h |
| OLD | NEW |