| 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/frame/Console.h" | 36 #include "core/frame/Console.h" |
| 37 #include "core/frame/FrameConsole.h" | 37 #include "core/frame/FrameConsole.h" |
| 38 #include "core/frame/LocalDOMWindow.h" | 38 #include "core/frame/LocalDOMWindow.h" |
| 39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 40 #include "core/frame/csp/ContentSecurityPolicy.h" | 40 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 41 #include "core/inspector/ConsoleMessage.h" | 41 #include "core/inspector/ConsoleMessage.h" |
| 42 #include "core/inspector/ScriptCallStack.h" | 42 #include "core/inspector/ScriptCallStack.h" |
| 43 #include "core/inspector/WorkerDebuggerAgent.h" | 43 #include "core/inspector/WorkerDebuggerAgent.h" |
| 44 #include "core/loader/DocumentLoadTiming.h" | 44 #include "core/loader/DocumentLoadTiming.h" |
| 45 #include "core/loader/DocumentLoader.h" | 45 #include "core/loader/DocumentLoader.h" |
| 46 #include "core/workers/DedicatedWorkerGlobalScope.h" | |
| 47 #include "core/workers/DedicatedWorkerThread.h" | 46 #include "core/workers/DedicatedWorkerThread.h" |
| 48 #include "core/workers/Worker.h" | 47 #include "core/workers/Worker.h" |
| 49 #include "core/workers/WorkerClients.h" | 48 #include "core/workers/WorkerClients.h" |
| 50 #include "core/workers/WorkerInspectorProxy.h" | 49 #include "core/workers/WorkerInspectorProxy.h" |
| 51 #include "core/workers/WorkerObjectProxy.h" | 50 #include "core/workers/WorkerObjectProxy.h" |
| 52 #include "core/workers/WorkerThreadStartupData.h" | 51 #include "core/workers/WorkerThreadStartupData.h" |
| 53 #include "platform/heap/Handle.h" | 52 #include "platform/heap/Handle.h" |
| 54 #include "wtf/Functional.h" | 53 #include "wtf/Functional.h" |
| 55 #include "wtf/MainThread.h" | 54 #include "wtf/MainThread.h" |
| 56 | 55 |
| 57 namespace blink { | 56 namespace blink { |
| 58 | 57 |
| 59 class MessageWorkerGlobalScopeTask : public ExecutionContextTask { | 58 class MessageWorkerGlobalScopeTask : public ExecutionContextTask { |
| 60 public: | 59 public: |
| 61 static PassOwnPtr<MessageWorkerGlobalScopeTask> create(PassRefPtr<Serialized
ScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) | 60 static PassOwnPtr<MessageWorkerGlobalScopeTask> create(PassRefPtr<Serialized
ScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels, WorkerObject
Proxy& workerObjectProxy) |
| 62 { | 61 { |
| 63 return adoptPtr(new MessageWorkerGlobalScopeTask(message, channels)); | 62 return adoptPtr(new MessageWorkerGlobalScopeTask(message, channels, work
erObjectProxy)); |
| 64 } | 63 } |
| 65 | 64 |
| 66 private: | 65 private: |
| 67 MessageWorkerGlobalScopeTask(PassRefPtr<SerializedScriptValue> message, Pass
OwnPtr<MessagePortChannelArray> channels) | 66 MessageWorkerGlobalScopeTask(PassRefPtr<SerializedScriptValue> message, Pass
OwnPtr<MessagePortChannelArray> channels, WorkerObjectProxy& workerObjectProxy) |
| 68 : m_message(message) | 67 : m_message(message) |
| 69 , m_channels(channels) | 68 , m_channels(channels) |
| 69 , m_workerObjectProxy(workerObjectProxy) |
| 70 { | 70 { |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual void performTask(ExecutionContext* scriptContext) | 73 virtual void performTask(ExecutionContext* scriptContext) |
| 74 { | 74 { |
| 75 ASSERT_WITH_SECURITY_IMPLICATION(scriptContext->isWorkerGlobalScope()); | 75 ASSERT_WITH_SECURITY_IMPLICATION(scriptContext->isWorkerGlobalScope()); |
| 76 DedicatedWorkerGlobalScope* context = static_cast<DedicatedWorkerGlobalS
cope*>(scriptContext); | |
| 77 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::entanglePorts(
*scriptContext, m_channels.release()); | 76 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::entanglePorts(
*scriptContext, m_channels.release()); |
| 78 context->dispatchEvent(MessageEvent::create(ports.release(), m_message))
; | 77 WorkerGlobalScope* globalScope = static_cast<WorkerGlobalScope*>(scriptC
ontext); |
| 79 context->thread()->workerObjectProxy().confirmMessageFromWorkerObject(co
ntext->hasPendingActivity()); | 78 globalScope->dispatchEvent(MessageEvent::create(ports.release(), m_messa
ge)); |
| 79 m_workerObjectProxy.confirmMessageFromWorkerObject(scriptContext->hasPen
dingActivity()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 RefPtr<SerializedScriptValue> m_message; | 83 RefPtr<SerializedScriptValue> m_message; |
| 84 OwnPtr<MessagePortChannelArray> m_channels; | 84 OwnPtr<MessagePortChannelArray> m_channels; |
| 85 WorkerObjectProxy& m_workerObjectProxy; |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 WorkerMessagingProxy::WorkerMessagingProxy(Worker* workerObject, PassOwnPtrWillB
eRawPtr<WorkerClients> workerClients) | 88 WorkerMessagingProxy::WorkerMessagingProxy(Worker* workerObject, PassOwnPtrWillB
eRawPtr<WorkerClients> workerClients) |
| 88 : m_executionContext(workerObject->executionContext()) | 89 : m_executionContext(workerObject->executionContext()) |
| 89 , m_workerObjectProxy(WorkerObjectProxy::create(m_executionContext.get(), th
is)) | 90 , m_workerObjectProxy(WorkerObjectProxy::create(m_executionContext.get(), th
is)) |
| 90 , m_workerObject(workerObject) | 91 , m_workerObject(workerObject) |
| 91 , m_mayBeDestroyed(false) | 92 , m_mayBeDestroyed(false) |
| 92 , m_unconfirmedMessageCount(0) | 93 , m_unconfirmedMessageCount(0) |
| 93 , m_workerThreadHadPendingActivity(false) | 94 , m_workerThreadHadPendingActivity(false) |
| 94 , m_askedToTerminate(false) | 95 , m_askedToTerminate(false) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 m_workerObject->dispatchEvent(MessageEvent::create(ports.release(), message)
); | 141 m_workerObject->dispatchEvent(MessageEvent::create(ports.release(), message)
); |
| 141 } | 142 } |
| 142 | 143 |
| 143 void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedS
criptValue> message, PassOwnPtr<MessagePortChannelArray> channels) | 144 void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedS
criptValue> message, PassOwnPtr<MessagePortChannelArray> channels) |
| 144 { | 145 { |
| 145 if (m_askedToTerminate) | 146 if (m_askedToTerminate) |
| 146 return; | 147 return; |
| 147 | 148 |
| 148 if (m_workerThread) { | 149 if (m_workerThread) { |
| 149 ++m_unconfirmedMessageCount; | 150 ++m_unconfirmedMessageCount; |
| 150 m_workerThread->postTask(FROM_HERE, MessageWorkerGlobalScopeTask::create
(message, channels)); | 151 m_workerThread->postTask(FROM_HERE, MessageWorkerGlobalScopeTask::create
(message, channels, workerObjectProxy())); |
| 151 } else | 152 } else { |
| 152 m_queuedEarlyTasks.append(MessageWorkerGlobalScopeTask::create(message,
channels)); | 153 m_queuedEarlyTasks.append(MessageWorkerGlobalScopeTask::create(message,
channels, workerObjectProxy())); |
| 154 } |
| 153 } | 155 } |
| 154 | 156 |
| 155 bool WorkerMessagingProxy::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionConte
xtTask> task) | 157 bool WorkerMessagingProxy::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionConte
xtTask> task) |
| 156 { | 158 { |
| 157 if (m_askedToTerminate) | 159 if (m_askedToTerminate) |
| 158 return false; | 160 return false; |
| 159 | 161 |
| 160 ASSERT(m_workerThread); | 162 ASSERT(m_workerThread); |
| 161 m_workerThread->postTask(FROM_HERE, task); | 163 m_workerThread->postTask(FROM_HERE, task); |
| 162 return true; | 164 return true; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 306 |
| 305 // FIXME: This need to be revisited when we support nested worker one day | 307 // FIXME: This need to be revisited when we support nested worker one day |
| 306 ASSERT(m_executionContext->isDocument()); | 308 ASSERT(m_executionContext->isDocument()); |
| 307 Document* document = toDocument(m_executionContext.get()); | 309 Document* document = toDocument(m_executionContext.get()); |
| 308 LocalFrame* frame = document->frame(); | 310 LocalFrame* frame = document->frame(); |
| 309 if (frame) | 311 if (frame) |
| 310 frame->console().adoptWorkerMessagesAfterTermination(this); | 312 frame->console().adoptWorkerMessagesAfterTermination(this); |
| 311 } | 313 } |
| 312 | 314 |
| 313 } // namespace blink | 315 } // namespace blink |
| OLD | NEW |