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/WorkerScriptLoaderClient.h" | |
40 #include "core/workers/WorkerThread.h" | 39 #include "core/workers/WorkerThread.h" |
41 #include "public/web/WebContentSecurityPolicy.h" | 40 #include "public/web/WebContentSecurityPolicy.h" |
42 #include "public/web/WebDevToolsAgentClient.h" | 41 #include "public/web/WebDevToolsAgentClient.h" |
43 #include "public/web/WebFrameClient.h" | 42 #include "public/web/WebFrameClient.h" |
44 #include "public/web/WebSharedWorkerClient.h" | 43 #include "public/web/WebSharedWorkerClient.h" |
45 #include "wtf/PassOwnPtr.h" | 44 #include "wtf/PassOwnPtr.h" |
46 #include "wtf/RefPtr.h" | 45 #include "wtf/RefPtr.h" |
47 | 46 |
48 namespace blink { | 47 namespace blink { |
49 | 48 |
50 class ConsoleMessage; | 49 class ConsoleMessage; |
51 class WebApplicationCacheHost; | 50 class WebApplicationCacheHost; |
52 class WebApplicationCacheHostClient; | 51 class WebApplicationCacheHostClient; |
53 class WebLocalFrameImpl; | 52 class WebLocalFrameImpl; |
54 class WebServiceWorkerNetworkProvider; | 53 class WebServiceWorkerNetworkProvider; |
55 class WebSharedWorkerClient; | 54 class WebSharedWorkerClient; |
56 class WebString; | 55 class WebString; |
57 class WebURL; | 56 class WebURL; |
58 class WebView; | 57 class WebView; |
59 class WorkerInspectorProxy; | 58 class WorkerInspectorProxy; |
| 59 class WorkerScriptLoader; |
60 | 60 |
61 // This class is used by the worker process code to talk to the SharedWorker imp
lementation. | 61 // This class is used by the worker process code to talk to the SharedWorker |
62 // It can't use it directly since it uses WebKit types, so this class converts t
he data types. | 62 // implementation. |
63 // When the SharedWorker object wants to call WorkerReportingProxy, this class w
ill | 63 // It can't use it directly since it uses WebKit types, so this class converts |
64 // convert to Chrome data types first and then call the supplied WebCommonWorker
Client. | 64 // the data types. When the SharedWorker object wants to call |
| 65 // WorkerReportingProxy, this class will convert to Chrome data types first and |
| 66 // then call the supplied WebCommonWorkerClient. |
65 class WebSharedWorkerImpl final | 67 class WebSharedWorkerImpl final |
66 : public WorkerReportingProxy | 68 : public WorkerReportingProxy |
67 , public WebFrameClient | 69 , public WebFrameClient |
68 , public WebSharedWorker | 70 , public WebSharedWorker |
69 , public WebDevToolsAgentClient | 71 , public WebDevToolsAgentClient |
70 , private WorkerLoaderProxyProvider { | 72 , private WorkerLoaderProxyProvider { |
71 public: | 73 public: |
72 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); | 74 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); |
73 | 75 |
74 // WorkerReportingProxy methods: | 76 // WorkerReportingProxy methods: |
75 virtual void reportException( | 77 void reportException( |
76 const WTF::String&, int, int, const WTF::String&, int) override; | 78 const WTF::String&, int, int, const WTF::String&, int) override; |
77 virtual void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) ov
erride; | 79 void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) override; |
78 virtual void postMessageToPageInspector(const WTF::String&) override; | 80 void postMessageToPageInspector(const WTF::String&) override; |
79 virtual void postWorkerConsoleAgentEnabled() override { } | 81 void postWorkerConsoleAgentEnabled() override { } |
80 virtual void didEvaluateWorkerScript(bool success) override { }; | 82 void didEvaluateWorkerScript(bool success) override { }; |
81 virtual void workerGlobalScopeStarted(WorkerGlobalScope*) override; | 83 void workerGlobalScopeStarted(WorkerGlobalScope*) override; |
82 virtual void workerGlobalScopeClosed() override; | 84 void workerGlobalScopeClosed() override; |
83 virtual void workerThreadTerminated() override; | 85 void workerThreadTerminated() override; |
84 virtual void willDestroyWorkerGlobalScope() override { } | 86 void willDestroyWorkerGlobalScope() override { } |
85 | 87 |
86 // WebFrameClient methods to support resource loading thru the 'shadow page'
. | 88 // WebFrameClient methods to support resource loading thru the 'shadow page'
. |
87 virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*,
WebApplicationCacheHostClient*) override; | 89 WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*, WebAppli
cationCacheHostClient*) override; |
88 virtual void willSendRequest(WebLocalFrame*, unsigned identifier, WebURLRequ
est&, const WebURLResponse& redirectResponse) override; | 90 void willSendRequest(WebLocalFrame*, unsigned identifier, WebURLRequest&, co
nst WebURLResponse& redirectResponse) override; |
89 virtual void didFinishDocumentLoad(WebLocalFrame*) override; | 91 void didFinishDocumentLoad(WebLocalFrame*) override; |
90 virtual bool isControlledByServiceWorker(WebDataSource&) override; | 92 bool isControlledByServiceWorker(WebDataSource&) override; |
91 virtual int64_t serviceWorkerID(WebDataSource&) override; | 93 int64_t serviceWorkerID(WebDataSource&) override; |
92 | 94 |
93 // WebDevToolsAgentClient overrides. | 95 // WebDevToolsAgentClient overrides. |
94 virtual void sendProtocolMessage(int callId, const WebString&, const WebStri
ng&) override; | 96 void sendProtocolMessage(int callId, const WebString&, const WebString&) ove
rride; |
95 virtual void resumeStartup() override; | 97 void resumeStartup() override; |
96 | 98 |
97 // WebSharedWorker methods: | 99 // WebSharedWorker methods: |
98 virtual void startWorkerContext(const WebURL&, const WebString& name, const
WebString& contentSecurityPolicy, WebContentSecurityPolicyType) override; | 100 void startWorkerContext(const WebURL&, const WebString& name, const WebStrin
g& contentSecurityPolicy, WebContentSecurityPolicyType) override; |
99 virtual void connect(WebMessagePortChannel*) override; | 101 void connect(WebMessagePortChannel*) override; |
100 virtual void terminateWorkerContext() override; | 102 void terminateWorkerContext() override; |
101 | 103 |
102 virtual void pauseWorkerContextOnStart() override; | 104 void pauseWorkerContextOnStart() override; |
103 virtual void attachDevTools(const WebString& hostId) override; | 105 void attachDevTools(const WebString& hostId) override; |
104 virtual void reattachDevTools(const WebString& hostId, const WebString& save
dState) override; | 106 void reattachDevTools(const WebString& hostId, const WebString& savedState)
override; |
105 virtual void detachDevTools() override; | 107 void detachDevTools() override; |
106 virtual void dispatchDevToolsMessage(const WebString&) override; | 108 void dispatchDevToolsMessage(const WebString&) override; |
107 | 109 |
108 private: | 110 private: |
109 class Loader; | 111 ~WebSharedWorkerImpl() override; |
110 | |
111 virtual ~WebSharedWorkerImpl(); | |
112 | 112 |
113 void setWorkerThread(PassRefPtr<WorkerThread> thread) { m_workerThread = thr
ead; } | 113 void setWorkerThread(PassRefPtr<WorkerThread> thread) { m_workerThread = thr
ead; } |
114 WorkerThread* workerThread() { return m_workerThread.get(); } | 114 WorkerThread* workerThread() { return m_workerThread.get(); } |
115 | 115 |
116 // Shuts down the worker thread. | 116 // Shuts down the worker thread. |
117 void terminateWorkerThread(); | 117 void terminateWorkerThread(); |
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 |
(...skipping 24 matching lines...) Expand all Loading... |
146 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; | 146 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; |
147 | 147 |
148 RefPtr<WorkerThread> m_workerThread; | 148 RefPtr<WorkerThread> m_workerThread; |
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 OwnPtr<Loader> m_mainScriptLoader; | 156 OwnPtr<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 |