OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * | 13 * |
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 | 28 |
29 #include "core/workers/WorkerMessagingProxy.h" | 29 #include "core/workers/InProcessWorkerMessagingProxy.h" |
30 | 30 |
31 #include "bindings/core/v8/V8GCController.h" | 31 #include "bindings/core/v8/V8GCController.h" |
32 #include "core/dom/CrossThreadTask.h" | 32 #include "core/dom/CrossThreadTask.h" |
33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
34 #include "core/dom/SecurityContext.h" | 34 #include "core/dom/SecurityContext.h" |
35 #include "core/events/ErrorEvent.h" | 35 #include "core/events/ErrorEvent.h" |
36 #include "core/events/MessageEvent.h" | 36 #include "core/events/MessageEvent.h" |
37 #include "core/frame/Console.h" | 37 #include "core/frame/Console.h" |
38 #include "core/frame/FrameConsole.h" | 38 #include "core/frame/FrameConsole.h" |
39 #include "core/frame/LocalDOMWindow.h" | 39 #include "core/frame/LocalDOMWindow.h" |
(...skipping 24 matching lines...) Expand all Loading... |
64 void processMessageOnWorkerGlobalScope(PassRefPtr<SerializedScriptValue> message
, PassOwnPtr<MessagePortChannelArray> channels, WorkerObjectProxy* workerObjectP
roxy, ExecutionContext* scriptContext) | 64 void processMessageOnWorkerGlobalScope(PassRefPtr<SerializedScriptValue> message
, PassOwnPtr<MessagePortChannelArray> channels, WorkerObjectProxy* workerObjectP
roxy, ExecutionContext* scriptContext) |
65 { | 65 { |
66 WorkerGlobalScope* globalScope = toWorkerGlobalScope(scriptContext); | 66 WorkerGlobalScope* globalScope = toWorkerGlobalScope(scriptContext); |
67 MessagePortArray* ports = MessagePort::entanglePorts(*scriptContext, channel
s); | 67 MessagePortArray* ports = MessagePort::entanglePorts(*scriptContext, channel
s); |
68 globalScope->dispatchEvent(MessageEvent::create(ports, message)); | 68 globalScope->dispatchEvent(MessageEvent::create(ports, message)); |
69 workerObjectProxy->confirmMessageFromWorkerObject(V8GCController::hasPending
Activity(globalScope->thread()->isolate(), scriptContext)); | 69 workerObjectProxy->confirmMessageFromWorkerObject(V8GCController::hasPending
Activity(globalScope->thread()->isolate(), scriptContext)); |
70 } | 70 } |
71 | 71 |
72 } // namespace | 72 } // namespace |
73 | 73 |
74 WorkerMessagingProxy::WorkerMessagingProxy(InProcessWorkerBase* workerObject, Wo
rkerClients* workerClients) | 74 InProcessWorkerMessagingProxy::InProcessWorkerMessagingProxy(InProcessWorkerBase
* workerObject, WorkerClients* workerClients) |
75 : m_executionContext(workerObject->getExecutionContext()) | 75 : m_executionContext(workerObject->getExecutionContext()) |
76 , m_workerObjectProxy(WorkerObjectProxy::create(this)) | 76 , m_workerObjectProxy(WorkerObjectProxy::create(this)) |
77 , m_workerObject(workerObject) | 77 , m_workerObject(workerObject) |
78 , m_mayBeDestroyed(false) | 78 , m_mayBeDestroyed(false) |
79 , m_unconfirmedMessageCount(0) | 79 , m_unconfirmedMessageCount(0) |
80 , m_workerThreadHadPendingActivity(false) | 80 , m_workerThreadHadPendingActivity(false) |
81 , m_askedToTerminate(false) | 81 , m_askedToTerminate(false) |
82 , m_workerInspectorProxy(WorkerInspectorProxy::create()) | 82 , m_workerInspectorProxy(WorkerInspectorProxy::create()) |
83 , m_workerClients(workerClients) | 83 , m_workerClients(workerClients) |
84 { | 84 { |
85 ASSERT(m_workerObject); | 85 ASSERT(m_workerObject); |
86 ASSERT((m_executionContext->isDocument() && isMainThread()) | 86 ASSERT((m_executionContext->isDocument() && isMainThread()) |
87 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e
xecutionContext.get())->thread()->isCurrentThread())); | 87 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e
xecutionContext.get())->thread()->isCurrentThread())); |
88 } | 88 } |
89 | 89 |
90 WorkerMessagingProxy::~WorkerMessagingProxy() | 90 InProcessWorkerMessagingProxy::~InProcessWorkerMessagingProxy() |
91 { | 91 { |
92 ASSERT(!m_workerObject); | 92 ASSERT(!m_workerObject); |
93 ASSERT((m_executionContext->isDocument() && isMainThread()) | 93 ASSERT((m_executionContext->isDocument() && isMainThread()) |
94 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e
xecutionContext.get())->thread()->isCurrentThread())); | 94 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e
xecutionContext.get())->thread()->isCurrentThread())); |
95 if (m_loaderProxy) | 95 if (m_loaderProxy) |
96 m_loaderProxy->detachProvider(this); | 96 m_loaderProxy->detachProvider(this); |
97 } | 97 } |
98 | 98 |
99 void WorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL, const S
tring& userAgent, const String& sourceCode) | 99 void InProcessWorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL
, const String& userAgent, const String& sourceCode) |
100 { | 100 { |
101 // FIXME: This need to be revisited when we support nested worker one day | 101 // FIXME: This need to be revisited when we support nested worker one day |
102 ASSERT(m_executionContext->isDocument()); | 102 ASSERT(m_executionContext->isDocument()); |
103 if (m_askedToTerminate) { | 103 if (m_askedToTerminate) { |
104 // Worker.terminate() could be called from JS before the thread was crea
ted. | 104 // Worker.terminate() could be called from JS before the thread was crea
ted. |
105 return; | 105 return; |
106 } | 106 } |
107 Document* document = toDocument(m_executionContext.get()); | 107 Document* document = toDocument(m_executionContext.get()); |
108 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); | 108 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); |
109 | 109 |
110 ContentSecurityPolicy* csp = m_workerObject->contentSecurityPolicy() ? m_wor
kerObject->contentSecurityPolicy() : document->contentSecurityPolicy(); | 110 ContentSecurityPolicy* csp = m_workerObject->contentSecurityPolicy() ? m_wor
kerObject->contentSecurityPolicy() : document->contentSecurityPolicy(); |
111 ASSERT(csp); | 111 ASSERT(csp); |
112 | 112 |
113 WorkerThreadStartMode startMode = m_workerInspectorProxy->workerStartMode(do
cument); | 113 WorkerThreadStartMode startMode = m_workerInspectorProxy->workerStartMode(do
cument); |
114 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e(scriptURL, userAgent, sourceCode, nullptr, startMode, csp->headers(), starterO
rigin, m_workerClients.release(), document->addressSpace()); | 114 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e(scriptURL, userAgent, sourceCode, nullptr, startMode, csp->headers(), starterO
rigin, m_workerClients.release(), document->addressSpace()); |
115 double originTime = document->loader() ? document->loader()->timing().refere
nceMonotonicTime() : monotonicallyIncreasingTime(); | 115 double originTime = document->loader() ? document->loader()->timing().refere
nceMonotonicTime() : monotonicallyIncreasingTime(); |
116 | 116 |
117 m_loaderProxy = WorkerLoaderProxy::create(this); | 117 m_loaderProxy = WorkerLoaderProxy::create(this); |
118 m_workerThread = createWorkerThread(originTime); | 118 m_workerThread = createWorkerThread(originTime); |
119 m_workerThread->start(startupData.release()); | 119 m_workerThread->start(startupData.release()); |
120 workerThreadCreated(); | 120 workerThreadCreated(); |
121 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); | 121 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); |
122 } | 122 } |
123 | 123 |
124 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript
Value> message, PassOwnPtr<MessagePortChannelArray> channels) | 124 void InProcessWorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<Seriali
zedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) |
125 { | 125 { |
126 if (!m_workerObject || m_askedToTerminate) | 126 if (!m_workerObject || m_askedToTerminate) |
127 return; | 127 return; |
128 | 128 |
129 MessagePortArray* ports = MessagePort::entanglePorts(*m_executionContext.get
(), channels); | 129 MessagePortArray* ports = MessagePort::entanglePorts(*m_executionContext.get
(), channels); |
130 m_workerObject->dispatchEvent(MessageEvent::create(ports, message)); | 130 m_workerObject->dispatchEvent(MessageEvent::create(ports, message)); |
131 } | 131 } |
132 | 132 |
133 void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedS
criptValue> message, PassOwnPtr<MessagePortChannelArray> channels) | 133 void InProcessWorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<Se
rializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) |
134 { | 134 { |
135 if (m_askedToTerminate) | 135 if (m_askedToTerminate) |
136 return; | 136 return; |
137 | 137 |
138 OwnPtr<ExecutionContextTask> task = createCrossThreadTask(&processMessageOnW
orkerGlobalScope, message, channels, AllowCrossThreadAccess(&workerObjectProxy()
)); | 138 OwnPtr<ExecutionContextTask> task = createCrossThreadTask(&processMessageOnW
orkerGlobalScope, message, channels, AllowCrossThreadAccess(&workerObjectProxy()
)); |
139 if (m_workerThread) { | 139 if (m_workerThread) { |
140 ++m_unconfirmedMessageCount; | 140 ++m_unconfirmedMessageCount; |
141 m_workerThread->postTask(BLINK_FROM_HERE, task.release()); | 141 m_workerThread->postTask(BLINK_FROM_HERE, task.release()); |
142 } else { | 142 } else { |
143 m_queuedEarlyTasks.append(task.release()); | 143 m_queuedEarlyTasks.append(task.release()); |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 bool WorkerMessagingProxy::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionConte
xtTask> task) | 147 bool InProcessWorkerMessagingProxy::postTaskToWorkerGlobalScope(PassOwnPtr<Execu
tionContextTask> task) |
148 { | 148 { |
149 if (m_askedToTerminate) | 149 if (m_askedToTerminate) |
150 return false; | 150 return false; |
151 | 151 |
152 ASSERT(m_workerThread); | 152 ASSERT(m_workerThread); |
153 m_workerThread->postTask(BLINK_FROM_HERE, task); | 153 m_workerThread->postTask(BLINK_FROM_HERE, task); |
154 return true; | 154 return true; |
155 } | 155 } |
156 | 156 |
157 void WorkerMessagingProxy::postTaskToLoader(PassOwnPtr<ExecutionContextTask> tas
k) | 157 void InProcessWorkerMessagingProxy::postTaskToLoader(PassOwnPtr<ExecutionContext
Task> task) |
158 { | 158 { |
159 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. | 159 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. |
160 ASSERT(m_executionContext->isDocument()); | 160 ASSERT(m_executionContext->isDocument()); |
161 m_executionContext->postTask(BLINK_FROM_HERE, task); | 161 m_executionContext->postTask(BLINK_FROM_HERE, task); |
162 } | 162 } |
163 | 163 |
164 void WorkerMessagingProxy::reportException(const String& errorMessage, int lineN
umber, int columnNumber, const String& sourceURL, int exceptionId) | 164 void InProcessWorkerMessagingProxy::reportException(const String& errorMessage,
int lineNumber, int columnNumber, const String& sourceURL, int exceptionId) |
165 { | 165 { |
166 if (!m_workerObject) | 166 if (!m_workerObject) |
167 return; | 167 return; |
168 | 168 |
169 // We don't bother checking the askedToTerminate() flag here, because except
ions should *always* be reported even if the thread is terminated. | 169 // We don't bother checking the askedToTerminate() flag here, because except
ions should *always* be reported even if the thread is terminated. |
170 // This is intentionally different than the behavior in MessageWorkerTask, b
ecause terminated workers no longer deliver messages (section 4.6 of the WebWork
er spec), but they do report exceptions. | 170 // This is intentionally different than the behavior in MessageWorkerTask, b
ecause terminated workers no longer deliver messages (section 4.6 of the WebWork
er spec), but they do report exceptions. |
171 | 171 |
172 ErrorEvent* event = ErrorEvent::create(errorMessage, sourceURL, lineNumber,
columnNumber, nullptr); | 172 ErrorEvent* event = ErrorEvent::create(errorMessage, sourceURL, lineNumber,
columnNumber, nullptr); |
173 DispatchEventResult dispatchResult = m_workerObject->dispatchEvent(event); | 173 DispatchEventResult dispatchResult = m_workerObject->dispatchEvent(event); |
174 postTaskToWorkerGlobalScope(createCrossThreadTask(&processExceptionOnWorkerG
lobalScope, exceptionId, dispatchResult != DispatchEventResult::NotCanceled)); | 174 postTaskToWorkerGlobalScope(createCrossThreadTask(&processExceptionOnWorkerG
lobalScope, exceptionId, dispatchResult != DispatchEventResult::NotCanceled)); |
175 } | 175 } |
176 | 176 |
177 void WorkerMessagingProxy::reportConsoleMessage(MessageSource source, MessageLev
el level, const String& message, int lineNumber, const String& sourceURL) | 177 void InProcessWorkerMessagingProxy::reportConsoleMessage(MessageSource source, M
essageLevel level, const String& message, int lineNumber, const String& sourceUR
L) |
178 { | 178 { |
179 if (m_askedToTerminate) | 179 if (m_askedToTerminate) |
180 return; | 180 return; |
181 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. | 181 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. |
182 ASSERT(m_executionContext->isDocument()); | 182 ASSERT(m_executionContext->isDocument()); |
183 Document* document = toDocument(m_executionContext.get()); | 183 Document* document = toDocument(m_executionContext.get()); |
184 LocalFrame* frame = document->frame(); | 184 LocalFrame* frame = document->frame(); |
185 if (!frame) | 185 if (!frame) |
186 return; | 186 return; |
187 | 187 |
188 ConsoleMessage* consoleMessage = ConsoleMessage::create(source, level, messa
ge, sourceURL, lineNumber); | 188 ConsoleMessage* consoleMessage = ConsoleMessage::create(source, level, messa
ge, sourceURL, lineNumber); |
189 consoleMessage->setWorkerInspectorProxy(m_workerInspectorProxy.get()); | 189 consoleMessage->setWorkerInspectorProxy(m_workerInspectorProxy.get()); |
190 frame->console().addMessage(consoleMessage); | 190 frame->console().addMessage(consoleMessage); |
191 } | 191 } |
192 | 192 |
193 void WorkerMessagingProxy::workerThreadCreated() | 193 void InProcessWorkerMessagingProxy::workerThreadCreated() |
194 { | 194 { |
195 ASSERT(!m_askedToTerminate); | 195 ASSERT(!m_askedToTerminate); |
196 ASSERT(m_workerThread); | 196 ASSERT(m_workerThread); |
197 | 197 |
198 ASSERT(!m_unconfirmedMessageCount); | 198 ASSERT(!m_unconfirmedMessageCount); |
199 m_unconfirmedMessageCount = m_queuedEarlyTasks.size(); | 199 m_unconfirmedMessageCount = m_queuedEarlyTasks.size(); |
200 m_workerThreadHadPendingActivity = true; // Worker initialization means a pe
nding activity. | 200 m_workerThreadHadPendingActivity = true; // Worker initialization means a pe
nding activity. |
201 | 201 |
202 for (auto& earlyTasks : m_queuedEarlyTasks) | 202 for (auto& earlyTasks : m_queuedEarlyTasks) |
203 m_workerThread->postTask(BLINK_FROM_HERE, earlyTasks.release()); | 203 m_workerThread->postTask(BLINK_FROM_HERE, earlyTasks.release()); |
204 m_queuedEarlyTasks.clear(); | 204 m_queuedEarlyTasks.clear(); |
205 } | 205 } |
206 | 206 |
207 void WorkerMessagingProxy::workerObjectDestroyed() | 207 void InProcessWorkerMessagingProxy::workerObjectDestroyed() |
208 { | 208 { |
209 // workerObjectDestroyed() is called in InProcessWorkerBase's destructor. | 209 // workerObjectDestroyed() is called in InProcessWorkerBase's destructor. |
210 // Thus it should be guaranteed that a weak pointer m_workerObject has been
cleared | 210 // Thus it should be guaranteed that a weak pointer m_workerObject has been
cleared |
211 // before this method gets called. | 211 // before this method gets called. |
212 ASSERT(!m_workerObject); | 212 ASSERT(!m_workerObject); |
213 | 213 |
214 m_executionContext->postTask(BLINK_FROM_HERE, createCrossThreadTask(&WorkerM
essagingProxy::workerObjectDestroyedInternal, this)); | 214 m_executionContext->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InProce
ssWorkerMessagingProxy::workerObjectDestroyedInternal, this)); |
215 } | 215 } |
216 | 216 |
217 void WorkerMessagingProxy::workerObjectDestroyedInternal() | 217 void InProcessWorkerMessagingProxy::workerObjectDestroyedInternal() |
218 { | 218 { |
219 m_mayBeDestroyed = true; | 219 m_mayBeDestroyed = true; |
220 if (m_workerThread) | 220 if (m_workerThread) |
221 terminateWorkerGlobalScope(); | 221 terminateWorkerGlobalScope(); |
222 else | 222 else |
223 workerThreadTerminated(); | 223 workerThreadTerminated(); |
224 } | 224 } |
225 | 225 |
226 void WorkerMessagingProxy::workerThreadTerminated() | 226 void InProcessWorkerMessagingProxy::workerThreadTerminated() |
227 { | 227 { |
228 // This method is always the last to be performed, so the proxy is not neede
d for communication | 228 // This method is always the last to be performed, so the proxy is not neede
d for communication |
229 // in either side any more. However, the Worker object may still exist, and
it assumes that the proxy exists, too. | 229 // in either side any more. However, the Worker object may still exist, and
it assumes that the proxy exists, too. |
230 m_askedToTerminate = true; | 230 m_askedToTerminate = true; |
231 m_workerThread = nullptr; | 231 m_workerThread = nullptr; |
232 terminateInternally(); | 232 terminateInternally(); |
233 if (m_mayBeDestroyed) | 233 if (m_mayBeDestroyed) |
234 delete this; | 234 delete this; |
235 } | 235 } |
236 | 236 |
237 void WorkerMessagingProxy::terminateWorkerGlobalScope() | 237 void InProcessWorkerMessagingProxy::terminateWorkerGlobalScope() |
238 { | 238 { |
239 if (m_askedToTerminate) | 239 if (m_askedToTerminate) |
240 return; | 240 return; |
241 m_askedToTerminate = true; | 241 m_askedToTerminate = true; |
242 | 242 |
243 if (m_workerThread) | 243 if (m_workerThread) |
244 m_workerThread->terminate(); | 244 m_workerThread->terminate(); |
245 | 245 |
246 terminateInternally(); | 246 terminateInternally(); |
247 } | 247 } |
248 | 248 |
249 void WorkerMessagingProxy::postMessageToPageInspector(const String& message) | 249 void InProcessWorkerMessagingProxy::postMessageToPageInspector(const String& mes
sage) |
250 { | 250 { |
251 if (m_workerInspectorProxy) | 251 if (m_workerInspectorProxy) |
252 m_workerInspectorProxy->dispatchMessageFromWorker(message); | 252 m_workerInspectorProxy->dispatchMessageFromWorker(message); |
253 } | 253 } |
254 | 254 |
255 void WorkerMessagingProxy::postWorkerConsoleAgentEnabled() | 255 void InProcessWorkerMessagingProxy::postWorkerConsoleAgentEnabled() |
256 { | 256 { |
257 if (m_workerInspectorProxy) | 257 if (m_workerInspectorProxy) |
258 m_workerInspectorProxy->workerConsoleAgentEnabled(); | 258 m_workerInspectorProxy->workerConsoleAgentEnabled(); |
259 } | 259 } |
260 | 260 |
261 void WorkerMessagingProxy::confirmMessageFromWorkerObject(bool hasPendingActivit
y) | 261 void InProcessWorkerMessagingProxy::confirmMessageFromWorkerObject(bool hasPendi
ngActivity) |
262 { | 262 { |
263 if (!m_askedToTerminate) { | 263 if (!m_askedToTerminate) { |
264 ASSERT(m_unconfirmedMessageCount); | 264 ASSERT(m_unconfirmedMessageCount); |
265 --m_unconfirmedMessageCount; | 265 --m_unconfirmedMessageCount; |
266 } | 266 } |
267 reportPendingActivity(hasPendingActivity); | 267 reportPendingActivity(hasPendingActivity); |
268 } | 268 } |
269 | 269 |
270 void WorkerMessagingProxy::reportPendingActivity(bool hasPendingActivity) | 270 void InProcessWorkerMessagingProxy::reportPendingActivity(bool hasPendingActivit
y) |
271 { | 271 { |
272 m_workerThreadHadPendingActivity = hasPendingActivity; | 272 m_workerThreadHadPendingActivity = hasPendingActivity; |
273 } | 273 } |
274 | 274 |
275 bool WorkerMessagingProxy::hasPendingActivity() const | 275 bool InProcessWorkerMessagingProxy::hasPendingActivity() const |
276 { | 276 { |
277 return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m
_askedToTerminate; | 277 return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m
_askedToTerminate; |
278 } | 278 } |
279 | 279 |
280 void WorkerMessagingProxy::terminateInternally() | 280 void InProcessWorkerMessagingProxy::terminateInternally() |
281 { | 281 { |
282 m_workerInspectorProxy->workerThreadTerminated(); | 282 m_workerInspectorProxy->workerThreadTerminated(); |
283 | 283 |
284 // FIXME: This need to be revisited when we support nested worker one day | 284 // FIXME: This need to be revisited when we support nested worker one day |
285 ASSERT(m_executionContext->isDocument()); | 285 ASSERT(m_executionContext->isDocument()); |
286 Document* document = toDocument(m_executionContext.get()); | 286 Document* document = toDocument(m_executionContext.get()); |
287 LocalFrame* frame = document->frame(); | 287 LocalFrame* frame = document->frame(); |
288 if (frame) | 288 if (frame) |
289 frame->console().adoptWorkerMessagesAfterTermination(m_workerInspectorPr
oxy.get()); | 289 frame->console().adoptWorkerMessagesAfterTermination(m_workerInspectorPr
oxy.get()); |
290 } | 290 } |
291 | 291 |
292 } // namespace blink | 292 } // namespace blink |
OLD | NEW |