Chromium Code Reviews| Index: Source/core/workers/WorkerMessagingProxy.cpp |
| diff --git a/Source/core/workers/WorkerMessagingProxy.cpp b/Source/core/workers/WorkerMessagingProxy.cpp |
| index 081a68272cb06abb18d032731482785d41c54941..dc1a48dbc29f07ff2fbddb4768840e92bc4ed4cb 100644 |
| --- a/Source/core/workers/WorkerMessagingProxy.cpp |
| +++ b/Source/core/workers/WorkerMessagingProxy.cpp |
| @@ -33,7 +33,10 @@ |
| #include "core/dom/Document.h" |
| #include "core/events/ErrorEvent.h" |
| #include "core/events/MessageEvent.h" |
| +#include "core/frame/Console.h" |
| +#include "core/frame/FrameConsole.h" |
| #include "core/frame/LocalDOMWindow.h" |
| +#include "core/frame/LocalFrame.h" |
| #include "core/frame/csp/ContentSecurityPolicy.h" |
| #include "core/inspector/InspectorInstrumentation.h" |
| #include "core/inspector/ScriptCallStack.h" |
| @@ -176,7 +179,16 @@ void WorkerMessagingProxy::reportConsoleMessage(MessageSource source, MessageLev |
| { |
| if (m_askedToTerminate) |
| return; |
| - m_executionContext->addConsoleMessage(ConsoleMessage::create(source, level, message, sourceURL, lineNumber)); |
| + // FIXME: In case of nested workers, this should go directly to the root Document context. |
| + ASSERT(m_executionContext->isDocument()); |
| + Document* document = toDocument(m_executionContext.get()); |
| + LocalFrame* frame = document->frame(); |
| + if (!frame) |
| + return; |
| + |
| + RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(source, level, message, sourceURL, lineNumber); |
| + consoleMessage->setWorkerId(this); |
| + frame->console().addMessage(consoleMessage.release()); |
| } |
| void WorkerMessagingProxy::workerThreadCreated(PassRefPtr<DedicatedWorkerThread> workerThread) |
| @@ -261,6 +273,12 @@ void WorkerMessagingProxy::workerGlobalScopeDestroyed() |
| m_workerThread = nullptr; |
| InspectorInstrumentation::workerGlobalScopeTerminated(m_executionContext.get(), this); |
| + // FIXME: This need to be revisited when we support nested worker one day |
|
vsevik
2014/08/12 15:46:07
Let's extract a method here.
sergeyv
2014/08/12 16:00:59
Done.
|
| + ASSERT(m_executionContext->isDocument()); |
| + Document* document = toDocument(m_executionContext.get()); |
| + LocalFrame* frame = document->frame(); |
| + if (frame) |
| + frame->console().workerGlobalScopeTerminated(this); |
|
vsevik
2014/08/12 15:49:31
adoptWorkerConsoleMsssages
sergeyv
2014/08/12 16:00:59
Done.
|
| if (m_mayBeDestroyed) |
| delete this; |
| @@ -276,6 +294,12 @@ void WorkerMessagingProxy::terminateWorkerGlobalScope() |
| m_workerThread->stop(); |
| InspectorInstrumentation::workerGlobalScopeTerminated(m_executionContext.get(), this); |
| + // FIXME: This need to be revisited when we support nested worker one day |
| + ASSERT(m_executionContext->isDocument()); |
| + Document* document = toDocument(m_executionContext.get()); |
| + LocalFrame* frame = document->frame(); |
| + if (frame) |
| + frame->console().workerGlobalScopeTerminated(this); |
| } |
| void WorkerMessagingProxy::postMessageToPageInspector(const String& message) |