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

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: Fix test 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
« no previous file with comments | « Source/core/workers/WorkerMessagingProxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/WorkerMessagingProxy.cpp
diff --git a/Source/core/workers/WorkerMessagingProxy.cpp b/Source/core/workers/WorkerMessagingProxy.cpp
index 46d09cffd0fab2db4b6f4f50a8110a102e3255d4..79c2e829e836ecb8d22527821a66efedce1300f1 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"
@@ -177,7 +180,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)
@@ -276,9 +288,7 @@ void WorkerMessagingProxy::workerGlobalScopeDestroyed()
// in either side any more. However, the Worker object may still exist, and it assumes that the proxy exists, too.
m_askedToTerminate = true;
m_workerThread = nullptr;
-
- InspectorInstrumentation::workerGlobalScopeTerminated(m_executionContext.get(), this);
-
+ terminateInternally();
if (m_mayBeDestroyed)
delete this;
}
@@ -292,7 +302,7 @@ void WorkerMessagingProxy::terminateWorkerGlobalScope()
if (m_workerThread)
m_workerThread->stop();
- InspectorInstrumentation::workerGlobalScopeTerminated(m_executionContext.get(), this);
+ terminateInternally();
}
void WorkerMessagingProxy::postMessageToPageInspector(const String& message)
@@ -320,4 +330,16 @@ bool WorkerMessagingProxy::hasPendingActivity() const
return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m_askedToTerminate;
}
+void WorkerMessagingProxy::terminateInternally()
+{
+ 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().adoptWorkerConsoleMessages(this);
+}
+
} // namespace blink
« no previous file with comments | « Source/core/workers/WorkerMessagingProxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698