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 |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "core/inspector/InspectorInstrumentation.h" | 38 #include "core/inspector/InspectorInstrumentation.h" |
39 #include "core/inspector/ScriptCallStack.h" | 39 #include "core/inspector/ScriptCallStack.h" |
40 #include "core/inspector/WorkerDebuggerAgent.h" | 40 #include "core/inspector/WorkerDebuggerAgent.h" |
41 #include "core/inspector/WorkerInspectorController.h" | 41 #include "core/inspector/WorkerInspectorController.h" |
42 #include "core/loader/DocumentLoadTiming.h" | 42 #include "core/loader/DocumentLoadTiming.h" |
43 #include "core/loader/DocumentLoader.h" | 43 #include "core/loader/DocumentLoader.h" |
44 #include "core/page/ContentSecurityPolicy.h" | 44 #include "core/page/ContentSecurityPolicy.h" |
45 #include "core/page/DOMWindow.h" | 45 #include "core/page/DOMWindow.h" |
46 #include "core/page/PageGroup.h" | 46 #include "core/page/PageGroup.h" |
47 #include "core/platform/NotImplemented.h" | 47 #include "core/platform/NotImplemented.h" |
48 #include "core/workers/DedicatedWorkerContext.h" | 48 #include "core/workers/DedicatedWorkerGlobalScope.h" |
49 #include "core/workers/DedicatedWorkerThread.h" | 49 #include "core/workers/DedicatedWorkerThread.h" |
50 #include "core/workers/Worker.h" | 50 #include "core/workers/Worker.h" |
51 #include <wtf/MainThread.h> | 51 #include <wtf/MainThread.h> |
52 | 52 |
53 namespace WebCore { | 53 namespace WebCore { |
54 | 54 |
55 class MessageWorkerContextTask : public ScriptExecutionContext::Task { | 55 class MessageWorkerGlobalScopeTask : public ScriptExecutionContext::Task { |
56 public: | 56 public: |
57 static PassOwnPtr<MessageWorkerContextTask> create(PassRefPtr<SerializedScri
ptValue> message, PassOwnPtr<MessagePortChannelArray> channels) | 57 static PassOwnPtr<MessageWorkerGlobalScopeTask> create(PassRefPtr<Serialized
ScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) |
58 { | 58 { |
59 return adoptPtr(new MessageWorkerContextTask(message, channels)); | 59 return adoptPtr(new MessageWorkerGlobalScopeTask(message, channels)); |
60 } | 60 } |
61 | 61 |
62 private: | 62 private: |
63 MessageWorkerContextTask(PassRefPtr<SerializedScriptValue> message, PassOwnP
tr<MessagePortChannelArray> channels) | 63 MessageWorkerGlobalScopeTask(PassRefPtr<SerializedScriptValue> message, Pass
OwnPtr<MessagePortChannelArray> channels) |
64 : m_message(message) | 64 : m_message(message) |
65 , m_channels(channels) | 65 , m_channels(channels) |
66 { | 66 { |
67 } | 67 } |
68 | 68 |
69 virtual void performTask(ScriptExecutionContext* scriptContext) | 69 virtual void performTask(ScriptExecutionContext* scriptContext) |
70 { | 70 { |
71 ASSERT_WITH_SECURITY_IMPLICATION(scriptContext->isWorkerContext()); | 71 ASSERT_WITH_SECURITY_IMPLICATION(scriptContext->isWorkerGlobalScope()); |
72 DedicatedWorkerContext* context = static_cast<DedicatedWorkerContext*>(s
criptContext); | 72 DedicatedWorkerGlobalScope* context = static_cast<DedicatedWorkerGlobalS
cope*>(scriptContext); |
73 OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*scriptConte
xt, m_channels.release()); | 73 OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*scriptConte
xt, m_channels.release()); |
74 context->dispatchEvent(MessageEvent::create(ports.release(), m_message))
; | 74 context->dispatchEvent(MessageEvent::create(ports.release(), m_message))
; |
75 context->thread()->workerObjectProxy().confirmMessageFromWorkerObject(co
ntext->hasPendingActivity()); | 75 context->thread()->workerObjectProxy().confirmMessageFromWorkerObject(co
ntext->hasPendingActivity()); |
76 } | 76 } |
77 | 77 |
78 private: | 78 private: |
79 RefPtr<SerializedScriptValue> m_message; | 79 RefPtr<SerializedScriptValue> m_message; |
80 OwnPtr<MessagePortChannelArray> m_channels; | 80 OwnPtr<MessagePortChannelArray> m_channels; |
81 }; | 81 }; |
82 | 82 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 if (!errorHandled) | 140 if (!errorHandled) |
141 context->reportException(m_errorMessage, m_lineNumber, m_sourceURL,
0); | 141 context->reportException(m_errorMessage, m_lineNumber, m_sourceURL,
0); |
142 } | 142 } |
143 | 143 |
144 String m_errorMessage; | 144 String m_errorMessage; |
145 int m_lineNumber; | 145 int m_lineNumber; |
146 String m_sourceURL; | 146 String m_sourceURL; |
147 WorkerMessagingProxy* m_messagingProxy; | 147 WorkerMessagingProxy* m_messagingProxy; |
148 }; | 148 }; |
149 | 149 |
150 class WorkerContextDestroyedTask : public ScriptExecutionContext::Task { | 150 class WorkerGlobalScopeDestroyedTask : public ScriptExecutionContext::Task { |
151 public: | 151 public: |
152 static PassOwnPtr<WorkerContextDestroyedTask> create(WorkerMessagingProxy* m
essagingProxy) | 152 static PassOwnPtr<WorkerGlobalScopeDestroyedTask> create(WorkerMessagingProx
y* messagingProxy) |
153 { | 153 { |
154 return adoptPtr(new WorkerContextDestroyedTask(messagingProxy)); | 154 return adoptPtr(new WorkerGlobalScopeDestroyedTask(messagingProxy)); |
155 } | 155 } |
156 | 156 |
157 private: | 157 private: |
158 WorkerContextDestroyedTask(WorkerMessagingProxy* messagingProxy) | 158 WorkerGlobalScopeDestroyedTask(WorkerMessagingProxy* messagingProxy) |
159 : m_messagingProxy(messagingProxy) | 159 : m_messagingProxy(messagingProxy) |
160 { | 160 { |
161 } | 161 } |
162 | 162 |
163 virtual void performTask(ScriptExecutionContext*) | 163 virtual void performTask(ScriptExecutionContext*) |
164 { | 164 { |
165 m_messagingProxy->workerContextDestroyedInternal(); | 165 m_messagingProxy->workerGlobalScopeDestroyedInternal(); |
166 } | 166 } |
167 | 167 |
168 WorkerMessagingProxy* m_messagingProxy; | 168 WorkerMessagingProxy* m_messagingProxy; |
169 }; | 169 }; |
170 | 170 |
171 class WorkerTerminateTask : public ScriptExecutionContext::Task { | 171 class WorkerTerminateTask : public ScriptExecutionContext::Task { |
172 public: | 172 public: |
173 static PassOwnPtr<WorkerTerminateTask> create(WorkerMessagingProxy* messagin
gProxy) | 173 static PassOwnPtr<WorkerTerminateTask> create(WorkerMessagingProxy* messagin
gProxy) |
174 { | 174 { |
175 return adoptPtr(new WorkerTerminateTask(messagingProxy)); | 175 return adoptPtr(new WorkerTerminateTask(messagingProxy)); |
176 } | 176 } |
177 | 177 |
178 private: | 178 private: |
179 WorkerTerminateTask(WorkerMessagingProxy* messagingProxy) | 179 WorkerTerminateTask(WorkerMessagingProxy* messagingProxy) |
180 : m_messagingProxy(messagingProxy) | 180 : m_messagingProxy(messagingProxy) |
181 { | 181 { |
182 } | 182 } |
183 | 183 |
184 virtual void performTask(ScriptExecutionContext*) | 184 virtual void performTask(ScriptExecutionContext*) |
185 { | 185 { |
186 m_messagingProxy->terminateWorkerContext(); | 186 m_messagingProxy->terminateWorkerGlobalScope(); |
187 } | 187 } |
188 | 188 |
189 WorkerMessagingProxy* m_messagingProxy; | 189 WorkerMessagingProxy* m_messagingProxy; |
190 }; | 190 }; |
191 | 191 |
192 class WorkerThreadActivityReportTask : public ScriptExecutionContext::Task { | 192 class WorkerThreadActivityReportTask : public ScriptExecutionContext::Task { |
193 public: | 193 public: |
194 static PassOwnPtr<WorkerThreadActivityReportTask> create(WorkerMessagingProx
y* messagingProxy, bool confirmingMessage, bool hasPendingActivity) | 194 static PassOwnPtr<WorkerThreadActivityReportTask> create(WorkerMessagingProx
y* messagingProxy, bool confirmingMessage, bool hasPendingActivity) |
195 { | 195 { |
196 return adoptPtr(new WorkerThreadActivityReportTask(messagingProxy, confi
rmingMessage, hasPendingActivity)); | 196 return adoptPtr(new WorkerThreadActivityReportTask(messagingProxy, confi
rmingMessage, hasPendingActivity)); |
(...skipping 26 matching lines...) Expand all Loading... |
223 | 223 |
224 private: | 224 private: |
225 PostMessageToPageInspectorTask(WorkerMessagingProxy* messagingProxy, const S
tring& message) | 225 PostMessageToPageInspectorTask(WorkerMessagingProxy* messagingProxy, const S
tring& message) |
226 : m_messagingProxy(messagingProxy) | 226 : m_messagingProxy(messagingProxy) |
227 , m_message(message.isolatedCopy()) | 227 , m_message(message.isolatedCopy()) |
228 { | 228 { |
229 } | 229 } |
230 | 230 |
231 virtual void performTask(ScriptExecutionContext*) | 231 virtual void performTask(ScriptExecutionContext*) |
232 { | 232 { |
233 if (WorkerContextProxy::PageInspector* pageInspector = m_messagingProxy-
>m_pageInspector) | 233 if (WorkerGlobalScopeProxy::PageInspector* pageInspector = m_messagingPr
oxy->m_pageInspector) |
234 pageInspector->dispatchMessageFromWorker(m_message); | 234 pageInspector->dispatchMessageFromWorker(m_message); |
235 } | 235 } |
236 | 236 |
237 WorkerMessagingProxy* m_messagingProxy; | 237 WorkerMessagingProxy* m_messagingProxy; |
238 String m_message; | 238 String m_message; |
239 }; | 239 }; |
240 | 240 |
241 WorkerMessagingProxy::WorkerMessagingProxy(Worker* workerObject) | 241 WorkerMessagingProxy::WorkerMessagingProxy(Worker* workerObject) |
242 : m_scriptExecutionContext(workerObject->scriptExecutionContext()) | 242 : m_scriptExecutionContext(workerObject->scriptExecutionContext()) |
243 , m_workerObject(workerObject) | 243 , m_workerObject(workerObject) |
244 , m_mayBeDestroyed(false) | 244 , m_mayBeDestroyed(false) |
245 , m_unconfirmedMessageCount(0) | 245 , m_unconfirmedMessageCount(0) |
246 , m_workerThreadHadPendingActivity(false) | 246 , m_workerThreadHadPendingActivity(false) |
247 , m_askedToTerminate(false) | 247 , m_askedToTerminate(false) |
248 , m_pageInspector(0) | 248 , m_pageInspector(0) |
249 { | 249 { |
250 ASSERT(m_workerObject); | 250 ASSERT(m_workerObject); |
251 ASSERT((m_scriptExecutionContext->isDocument() && isMainThread()) | 251 ASSERT((m_scriptExecutionContext->isDocument() && isMainThread()) |
252 || (m_scriptExecutionContext->isWorkerContext() && static_cast<Worker
Context*>(m_scriptExecutionContext.get())->thread()->isCurrentThread())); | 252 || (m_scriptExecutionContext->isWorkerGlobalScope() && static_cast<Wo
rkerGlobalScope*>(m_scriptExecutionContext.get())->thread()->isCurrentThread()))
; |
253 } | 253 } |
254 | 254 |
255 WorkerMessagingProxy::~WorkerMessagingProxy() | 255 WorkerMessagingProxy::~WorkerMessagingProxy() |
256 { | 256 { |
257 ASSERT(!m_workerObject); | 257 ASSERT(!m_workerObject); |
258 ASSERT((m_scriptExecutionContext->isDocument() && isMainThread()) | 258 ASSERT((m_scriptExecutionContext->isDocument() && isMainThread()) |
259 || (m_scriptExecutionContext->isWorkerContext() && static_cast<Worker
Context*>(m_scriptExecutionContext.get())->thread()->isCurrentThread())); | 259 || (m_scriptExecutionContext->isWorkerGlobalScope() && static_cast<Wo
rkerGlobalScope*>(m_scriptExecutionContext.get())->thread()->isCurrentThread()))
; |
260 } | 260 } |
261 | 261 |
262 void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const Strin
g& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) | 262 void WorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL, const S
tring& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) |
263 { | 263 { |
264 // FIXME: This need to be revisited when we support nested worker one day | 264 // FIXME: This need to be revisited when we support nested worker one day |
265 ASSERT(m_scriptExecutionContext->isDocument()); | 265 ASSERT(m_scriptExecutionContext->isDocument()); |
266 Document* document = static_cast<Document*>(m_scriptExecutionContext.get()); | 266 Document* document = static_cast<Document*>(m_scriptExecutionContext.get()); |
267 RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptU
RL, userAgent, sourceCode, *this, *this, startMode, document->contentSecurityPol
icy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedHeaderTy
pe(), document->topOrigin(), document->loader()->timing()->referenceMonotonicTim
e()); | 267 RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptU
RL, userAgent, sourceCode, *this, *this, startMode, document->contentSecurityPol
icy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedHeaderTy
pe(), document->topOrigin(), document->loader()->timing()->referenceMonotonicTim
e()); |
268 workerThreadCreated(thread); | 268 workerThreadCreated(thread); |
269 thread->start(); | 269 thread->start(); |
270 InspectorInstrumentation::didStartWorkerContext(m_scriptExecutionContext.get
(), this, scriptURL); | 270 InspectorInstrumentation::didStartWorkerGlobalScope(m_scriptExecutionContext
.get(), this, scriptURL); |
271 } | 271 } |
272 | 272 |
273 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript
Value> message, PassOwnPtr<MessagePortChannelArray> channels) | 273 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript
Value> message, PassOwnPtr<MessagePortChannelArray> channels) |
274 { | 274 { |
275 m_scriptExecutionContext->postTask(MessageWorkerTask::create(message, channe
ls, this)); | 275 m_scriptExecutionContext->postTask(MessageWorkerTask::create(message, channe
ls, this)); |
276 } | 276 } |
277 | 277 |
278 void WorkerMessagingProxy::postMessageToWorkerContext(PassRefPtr<SerializedScrip
tValue> message, PassOwnPtr<MessagePortChannelArray> channels) | 278 void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedS
criptValue> message, PassOwnPtr<MessagePortChannelArray> channels) |
279 { | 279 { |
280 if (m_askedToTerminate) | 280 if (m_askedToTerminate) |
281 return; | 281 return; |
282 | 282 |
283 if (m_workerThread) { | 283 if (m_workerThread) { |
284 ++m_unconfirmedMessageCount; | 284 ++m_unconfirmedMessageCount; |
285 m_workerThread->runLoop().postTask(MessageWorkerContextTask::create(mess
age, channels)); | 285 m_workerThread->runLoop().postTask(MessageWorkerGlobalScopeTask::create(
message, channels)); |
286 } else | 286 } else |
287 m_queuedEarlyTasks.append(MessageWorkerContextTask::create(message, chan
nels)); | 287 m_queuedEarlyTasks.append(MessageWorkerGlobalScopeTask::create(message,
channels)); |
288 } | 288 } |
289 | 289 |
290 bool WorkerMessagingProxy::postTaskForModeToWorkerContext(PassOwnPtr<ScriptExecu
tionContext::Task> task, const String& mode) | 290 bool WorkerMessagingProxy::postTaskForModeToWorkerGlobalScope(PassOwnPtr<ScriptE
xecutionContext::Task> task, const String& mode) |
291 { | 291 { |
292 if (m_askedToTerminate) | 292 if (m_askedToTerminate) |
293 return false; | 293 return false; |
294 | 294 |
295 ASSERT(m_workerThread); | 295 ASSERT(m_workerThread); |
296 m_workerThread->runLoop().postTaskForMode(task, mode); | 296 m_workerThread->runLoop().postTaskForMode(task, mode); |
297 return true; | 297 return true; |
298 } | 298 } |
299 | 299 |
300 void WorkerMessagingProxy::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::T
ask> task) | 300 void WorkerMessagingProxy::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::T
ask> task) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 void WorkerMessagingProxy::workerObjectDestroyed() | 343 void WorkerMessagingProxy::workerObjectDestroyed() |
344 { | 344 { |
345 m_workerObject = 0; | 345 m_workerObject = 0; |
346 m_scriptExecutionContext->postTask(createCallbackTask(&workerObjectDestroyed
Internal, AllowCrossThreadAccess(this))); | 346 m_scriptExecutionContext->postTask(createCallbackTask(&workerObjectDestroyed
Internal, AllowCrossThreadAccess(this))); |
347 } | 347 } |
348 | 348 |
349 void WorkerMessagingProxy::workerObjectDestroyedInternal(ScriptExecutionContext*
, WorkerMessagingProxy* proxy) | 349 void WorkerMessagingProxy::workerObjectDestroyedInternal(ScriptExecutionContext*
, WorkerMessagingProxy* proxy) |
350 { | 350 { |
351 proxy->m_mayBeDestroyed = true; | 351 proxy->m_mayBeDestroyed = true; |
352 if (proxy->m_workerThread) | 352 if (proxy->m_workerThread) |
353 proxy->terminateWorkerContext(); | 353 proxy->terminateWorkerGlobalScope(); |
354 else | 354 else |
355 proxy->workerContextDestroyedInternal(); | 355 proxy->workerGlobalScopeDestroyedInternal(); |
356 } | 356 } |
357 | 357 |
358 static void connectToWorkerContextInspectorTask(ScriptExecutionContext* context,
bool) | 358 static void connectToWorkerGlobalScopeInspectorTask(ScriptExecutionContext* cont
ext, bool) |
359 { | 359 { |
360 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); | 360 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope()); |
361 static_cast<WorkerContext*>(context)->workerInspectorController()->connectFr
ontend(); | 361 static_cast<WorkerGlobalScope*>(context)->workerInspectorController()->conne
ctFrontend(); |
362 } | 362 } |
363 | 363 |
364 void WorkerMessagingProxy::connectToInspector(WorkerContextProxy::PageInspector*
pageInspector) | 364 void WorkerMessagingProxy::connectToInspector(WorkerGlobalScopeProxy::PageInspec
tor* pageInspector) |
365 { | 365 { |
366 if (m_askedToTerminate) | 366 if (m_askedToTerminate) |
367 return; | 367 return; |
368 ASSERT(!m_pageInspector); | 368 ASSERT(!m_pageInspector); |
369 m_pageInspector = pageInspector; | 369 m_pageInspector = pageInspector; |
370 m_workerThread->runLoop().postTaskForMode(createCallbackTask(connectToWorker
ContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); | 370 m_workerThread->runLoop().postTaskForMode(createCallbackTask(connectToWorker
GlobalScopeInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); |
371 } | 371 } |
372 | 372 |
373 static void disconnectFromWorkerContextInspectorTask(ScriptExecutionContext* con
text, bool) | 373 static void disconnectFromWorkerGlobalScopeInspectorTask(ScriptExecutionContext*
context, bool) |
374 { | 374 { |
375 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); | 375 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope()); |
376 static_cast<WorkerContext*>(context)->workerInspectorController()->disconnec
tFrontend(); | 376 static_cast<WorkerGlobalScope*>(context)->workerInspectorController()->disco
nnectFrontend(); |
377 } | 377 } |
378 | 378 |
379 void WorkerMessagingProxy::disconnectFromInspector() | 379 void WorkerMessagingProxy::disconnectFromInspector() |
380 { | 380 { |
381 m_pageInspector = 0; | 381 m_pageInspector = 0; |
382 if (m_askedToTerminate) | 382 if (m_askedToTerminate) |
383 return; | 383 return; |
384 m_workerThread->runLoop().postTaskForMode(createCallbackTask(disconnectFromW
orkerContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); | 384 m_workerThread->runLoop().postTaskForMode(createCallbackTask(disconnectFromW
orkerGlobalScopeInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); |
385 } | 385 } |
386 | 386 |
387 static void dispatchOnInspectorBackendTask(ScriptExecutionContext* context, cons
t String& message) | 387 static void dispatchOnInspectorBackendTask(ScriptExecutionContext* context, cons
t String& message) |
388 { | 388 { |
389 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); | 389 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope()); |
390 static_cast<WorkerContext*>(context)->workerInspectorController()->dispatchM
essageFromFrontend(message); | 390 static_cast<WorkerGlobalScope*>(context)->workerInspectorController()->dispa
tchMessageFromFrontend(message); |
391 } | 391 } |
392 | 392 |
393 void WorkerMessagingProxy::sendMessageToInspector(const String& message) | 393 void WorkerMessagingProxy::sendMessageToInspector(const String& message) |
394 { | 394 { |
395 if (m_askedToTerminate) | 395 if (m_askedToTerminate) |
396 return; | 396 return; |
397 m_workerThread->runLoop().postTaskForMode(createCallbackTask(dispatchOnInspe
ctorBackendTask, String(message)), WorkerDebuggerAgent::debuggerTaskMode); | 397 m_workerThread->runLoop().postTaskForMode(createCallbackTask(dispatchOnInspe
ctorBackendTask, String(message)), WorkerDebuggerAgent::debuggerTaskMode); |
398 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(m_workerThread.ge
t()); | 398 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(m_workerThread.ge
t()); |
399 } | 399 } |
400 | 400 |
401 void WorkerMessagingProxy::workerContextDestroyed() | 401 void WorkerMessagingProxy::workerGlobalScopeDestroyed() |
402 { | 402 { |
403 m_scriptExecutionContext->postTask(WorkerContextDestroyedTask::create(this))
; | 403 m_scriptExecutionContext->postTask(WorkerGlobalScopeDestroyedTask::create(th
is)); |
404 // Will execute workerContextDestroyedInternal() on context's thread. | 404 // Will execute workerGlobalScopeDestroyedInternal() on context's thread. |
405 } | 405 } |
406 | 406 |
407 void WorkerMessagingProxy::workerContextClosed() | 407 void WorkerMessagingProxy::workerGlobalScopeClosed() |
408 { | 408 { |
409 // Executes terminateWorkerContext() on parent context's thread. | 409 // Executes terminateWorkerGlobalScope() on parent context's thread. |
410 m_scriptExecutionContext->postTask(WorkerTerminateTask::create(this)); | 410 m_scriptExecutionContext->postTask(WorkerTerminateTask::create(this)); |
411 } | 411 } |
412 | 412 |
413 void WorkerMessagingProxy::workerContextDestroyedInternal() | 413 void WorkerMessagingProxy::workerGlobalScopeDestroyedInternal() |
414 { | 414 { |
415 // WorkerContextDestroyedTask is always the last to be performed, so the pro
xy is not needed for communication | 415 // WorkerGlobalScopeDestroyedTask is always the last to be performed, so the
proxy is not needed for communication |
416 // in either side any more. However, the Worker object may still exist, and
it assumes that the proxy exists, too. | 416 // in either side any more. However, the Worker object may still exist, and
it assumes that the proxy exists, too. |
417 m_askedToTerminate = true; | 417 m_askedToTerminate = true; |
418 m_workerThread = 0; | 418 m_workerThread = 0; |
419 | 419 |
420 InspectorInstrumentation::workerContextTerminated(m_scriptExecutionContext.g
et(), this); | 420 InspectorInstrumentation::workerGlobalScopeTerminated(m_scriptExecutionConte
xt.get(), this); |
421 | 421 |
422 if (m_mayBeDestroyed) | 422 if (m_mayBeDestroyed) |
423 delete this; | 423 delete this; |
424 } | 424 } |
425 | 425 |
426 void WorkerMessagingProxy::terminateWorkerContext() | 426 void WorkerMessagingProxy::terminateWorkerGlobalScope() |
427 { | 427 { |
428 if (m_askedToTerminate) | 428 if (m_askedToTerminate) |
429 return; | 429 return; |
430 m_askedToTerminate = true; | 430 m_askedToTerminate = true; |
431 | 431 |
432 if (m_workerThread) | 432 if (m_workerThread) |
433 m_workerThread->stop(); | 433 m_workerThread->stop(); |
434 | 434 |
435 InspectorInstrumentation::workerContextTerminated(m_scriptExecutionContext.g
et(), this); | 435 InspectorInstrumentation::workerGlobalScopeTerminated(m_scriptExecutionConte
xt.get(), this); |
436 } | 436 } |
437 | 437 |
438 void WorkerMessagingProxy::postMessageToPageInspector(const String& message) | 438 void WorkerMessagingProxy::postMessageToPageInspector(const String& message) |
439 { | 439 { |
440 m_scriptExecutionContext->postTask(PostMessageToPageInspectorTask::create(th
is, message)); | 440 m_scriptExecutionContext->postTask(PostMessageToPageInspectorTask::create(th
is, message)); |
441 } | 441 } |
442 | 442 |
443 void WorkerMessagingProxy::updateInspectorStateCookie(const String&) | 443 void WorkerMessagingProxy::updateInspectorStateCookie(const String&) |
444 { | 444 { |
445 notImplemented(); | 445 notImplemented(); |
(...skipping 20 matching lines...) Expand all Loading... |
466 | 466 |
467 m_workerThreadHadPendingActivity = hasPendingActivity; | 467 m_workerThreadHadPendingActivity = hasPendingActivity; |
468 } | 468 } |
469 | 469 |
470 bool WorkerMessagingProxy::hasPendingActivity() const | 470 bool WorkerMessagingProxy::hasPendingActivity() const |
471 { | 471 { |
472 return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m
_askedToTerminate; | 472 return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m
_askedToTerminate; |
473 } | 473 } |
474 | 474 |
475 } // namespace WebCore | 475 } // namespace WebCore |
OLD | NEW |