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