| 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 27 matching lines...) Expand all Loading... |
| 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/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 #include "wtf/WeakPtr.h" | 46 #include "wtf/WeakPtr.h" |
| 47 | 47 |
| 48 namespace WebCore { | 48 namespace blink { |
| 49 class ResourceResponse; | 49 class ResourceResponse; |
| 50 } | 50 } |
| 51 | 51 |
| 52 namespace blink { | 52 namespace blink { |
| 53 class WebApplicationCacheHost; | 53 class WebApplicationCacheHost; |
| 54 class WebApplicationCacheHostClient; | 54 class WebApplicationCacheHostClient; |
| 55 class WebWorkerClient; | 55 class WebWorkerClient; |
| 56 class WebSecurityOrigin; | 56 class WebSecurityOrigin; |
| 57 class WebString; | 57 class WebString; |
| 58 class WebURL; | 58 class WebURL; |
| 59 class WebView; | 59 class WebView; |
| 60 class WebWorker; | 60 class WebWorker; |
| 61 class WebSharedWorkerClient; | 61 class WebSharedWorkerClient; |
| 62 | 62 |
| 63 // This class is used by the worker process code to talk to the WebCore::SharedW
orker implementation. | 63 // This class is used by the worker process code to talk to the blink::SharedWor
ker implementation. |
| 64 // It can't use it directly since it uses WebKit types, so this class converts t
he data types. | 64 // It can't use it directly since it uses WebKit types, so this class converts t
he data types. |
| 65 // When the WebCore::SharedWorker object wants to call WebCore::WorkerReportingP
roxy, this class will | 65 // When the blink::SharedWorker object wants to call blink::WorkerReportingProxy
, this class will |
| 66 // convert to Chrome data types first and then call the supplied WebCommonWorker
Client. | 66 // convert to Chrome data types first and then call the supplied WebCommonWorker
Client. |
| 67 class WebSharedWorkerImpl FINAL | 67 class WebSharedWorkerImpl FINAL |
| 68 : public WebCore::WorkerReportingProxy | 68 : public blink::WorkerReportingProxy |
| 69 , public WebCore::WorkerLoaderProxy | 69 , public blink::WorkerLoaderProxy |
| 70 , public WebFrameClient | 70 , public WebFrameClient |
| 71 , public WebSharedWorker { | 71 , public WebSharedWorker { |
| 72 public: | 72 public: |
| 73 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); | 73 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); |
| 74 | 74 |
| 75 // WebCore::WorkerReportingProxy methods: | 75 // blink::WorkerReportingProxy methods: |
| 76 virtual void reportException( | 76 virtual void reportException( |
| 77 const WTF::String&, int, int, const WTF::String&) OVERRIDE; | 77 const WTF::String&, int, int, const WTF::String&) OVERRIDE; |
| 78 virtual void reportConsoleMessage( | 78 virtual void reportConsoleMessage( |
| 79 WebCore::MessageSource, WebCore::MessageLevel, | 79 blink::MessageSource, blink::MessageLevel, |
| 80 const WTF::String&, int, const WTF::String&) OVERRIDE; | 80 const WTF::String&, int, const WTF::String&) OVERRIDE; |
| 81 virtual void postMessageToPageInspector(const WTF::String&) OVERRIDE; | 81 virtual void postMessageToPageInspector(const WTF::String&) OVERRIDE; |
| 82 virtual void updateInspectorStateCookie(const WTF::String&) OVERRIDE; | 82 virtual void updateInspectorStateCookie(const WTF::String&) OVERRIDE; |
| 83 virtual void workerGlobalScopeStarted(WebCore::WorkerGlobalScope*) OVERRIDE; | 83 virtual void workerGlobalScopeStarted(blink::WorkerGlobalScope*) OVERRIDE; |
| 84 virtual void workerGlobalScopeClosed() OVERRIDE; | 84 virtual void workerGlobalScopeClosed() OVERRIDE; |
| 85 virtual void workerGlobalScopeDestroyed() OVERRIDE; | 85 virtual void workerGlobalScopeDestroyed() OVERRIDE; |
| 86 virtual void willDestroyWorkerGlobalScope() OVERRIDE { } | 86 virtual void willDestroyWorkerGlobalScope() OVERRIDE { } |
| 87 | 87 |
| 88 // WebCore::WorkerLoaderProxy methods: | 88 // blink::WorkerLoaderProxy methods: |
| 89 virtual void postTaskToLoader(PassOwnPtr<WebCore::ExecutionContextTask>) OVE
RRIDE; | 89 virtual void postTaskToLoader(PassOwnPtr<blink::ExecutionContextTask>) OVERR
IDE; |
| 90 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<WebCore::ExecutionContex
tTask>) OVERRIDE; | 90 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<blink::ExecutionContextT
ask>) OVERRIDE; |
| 91 | 91 |
| 92 // WebFrameClient methods to support resource loading thru the 'shadow page'
. | 92 // WebFrameClient methods to support resource loading thru the 'shadow page'
. |
| 93 virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*,
WebApplicationCacheHostClient*) OVERRIDE; | 93 virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*,
WebApplicationCacheHostClient*) OVERRIDE; |
| 94 virtual void didFinishDocumentLoad(WebLocalFrame*) OVERRIDE; | 94 virtual void didFinishDocumentLoad(WebLocalFrame*) OVERRIDE; |
| 95 | 95 |
| 96 // WebSharedWorker methods: | 96 // WebSharedWorker methods: |
| 97 virtual void startWorkerContext(const WebURL&, const WebString& name, const
WebString& contentSecurityPolicy, WebContentSecurityPolicyType) OVERRIDE; | 97 virtual void startWorkerContext(const WebURL&, const WebString& name, const
WebString& contentSecurityPolicy, WebContentSecurityPolicyType) OVERRIDE; |
| 98 virtual void connect(WebMessagePortChannel*) OVERRIDE; | 98 virtual void connect(WebMessagePortChannel*) OVERRIDE; |
| 99 virtual void terminateWorkerContext() OVERRIDE; | 99 virtual void terminateWorkerContext() OVERRIDE; |
| 100 virtual void clientDestroyed() OVERRIDE; | 100 virtual void clientDestroyed() OVERRIDE; |
| 101 | 101 |
| 102 virtual void pauseWorkerContextOnStart() OVERRIDE; | 102 virtual void pauseWorkerContextOnStart() OVERRIDE; |
| 103 virtual void resumeWorkerContext() OVERRIDE; | 103 virtual void resumeWorkerContext() OVERRIDE; |
| 104 virtual void attachDevTools() OVERRIDE; | 104 virtual void attachDevTools() OVERRIDE; |
| 105 virtual void reattachDevTools(const WebString& savedState) OVERRIDE; | 105 virtual void reattachDevTools(const WebString& savedState) OVERRIDE; |
| 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<WebCore::WorkerThread> thread) { m_workerThr
ead = thread; } | 116 void setWorkerThread(PassRefPtr<blink::WorkerThread> thread) { m_workerThrea
d = thread; } |
| 117 WebCore::WorkerThread* workerThread() { return m_workerThread.get(); } | 117 blink::WorkerThread* workerThread() { return m_workerThread.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(const WebURL&); | 123 void initializeLoader(const WebURL&); |
| 124 | 124 |
| 125 void didReceiveScriptLoaderResponse(); | 125 void didReceiveScriptLoaderResponse(); |
| 126 void onScriptLoaderFinished(); | 126 void onScriptLoaderFinished(); |
| 127 | 127 |
| 128 static void connectTask(WebCore::ExecutionContext*, PassOwnPtr<WebMessagePor
tChannel>); | 128 static void connectTask(blink::ExecutionContext*, PassOwnPtr<WebMessagePortC
hannel>); |
| 129 // Tasks that are run on the main thread. | 129 // Tasks that are run on the main thread. |
| 130 void workerGlobalScopeClosedOnMainThread(); | 130 void workerGlobalScopeClosedOnMainThread(); |
| 131 void workerGlobalScopeDestroyedOnMainThread(); | 131 void workerGlobalScopeDestroyedOnMainThread(); |
| 132 | 132 |
| 133 // 'shadow page' - created to proxy loading requests from the worker. | 133 // 'shadow page' - created to proxy loading requests from the worker. |
| 134 RefPtrWillBePersistent<WebCore::ExecutionContext> m_loadingDocument; | 134 RefPtrWillBePersistent<blink::ExecutionContext> m_loadingDocument; |
| 135 WebView* m_webView; | 135 WebView* m_webView; |
| 136 WebFrame* m_mainFrame; | 136 WebFrame* m_mainFrame; |
| 137 bool m_askedToTerminate; | 137 bool m_askedToTerminate; |
| 138 | 138 |
| 139 RefPtr<WebCore::WorkerThread> m_workerThread; | 139 RefPtr<blink::WorkerThread> m_workerThread; |
| 140 | 140 |
| 141 // This one's initialized and bound to the main thread. | 141 // This one's initialized and bound to the main thread. |
| 142 RefPtr<WeakReference<WebSharedWorkerClient> > m_client; | 142 RefPtr<WeakReference<WebSharedWorkerClient> > m_client; |
| 143 | 143 |
| 144 // Usually WeakPtr is created by WeakPtrFactory exposed by Client | 144 // Usually WeakPtr is created by WeakPtrFactory exposed by Client |
| 145 // class itself, but here it's implemented by Chrome so we create | 145 // class itself, but here it's implemented by Chrome so we create |
| 146 // our own WeakPtr. | 146 // our own WeakPtr. |
| 147 WeakPtr<WebSharedWorkerClient> m_clientWeakPtr; | 147 WeakPtr<WebSharedWorkerClient> m_clientWeakPtr; |
| 148 | 148 |
| 149 bool m_pauseWorkerContextOnStart; | 149 bool m_pauseWorkerContextOnStart; |
| 150 bool m_attachDevToolsOnStart; | 150 bool m_attachDevToolsOnStart; |
| 151 | 151 |
| 152 // Kept around only while main script loading is ongoing. | 152 // Kept around only while main script loading is ongoing. |
| 153 OwnPtr<Loader> m_mainScriptLoader; | 153 OwnPtr<Loader> m_mainScriptLoader; |
| 154 WebURL m_url; | 154 WebURL m_url; |
| 155 WebString m_name; | 155 WebString m_name; |
| 156 WebString m_contentSecurityPolicy; | 156 WebString m_contentSecurityPolicy; |
| 157 WebContentSecurityPolicyType m_policyType; | 157 WebContentSecurityPolicyType m_policyType; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 } // namespace blink | 160 } // namespace blink |
| 161 | 161 |
| 162 #endif | 162 #endif |
| OLD | NEW |