Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Unified Diff: Source/core/workers/WorkerMessagingProxy.cpp

Issue 466753002: DevTools: Do not push to frontend messages from worker while it is alive (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address vsevik's comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)
« Source/core/workers/WorkerMessagingProxy.h ('K') | « Source/core/workers/WorkerMessagingProxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698