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

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

Issue 1140503003: workers: Change how debugger-tasks are posted to the thread. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: back-to-patchset2 Created 5 years, 7 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/WorkerInspectorProxy.h ('k') | Source/core/workers/WorkerThread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/WorkerInspectorProxy.cpp
diff --git a/Source/core/workers/WorkerInspectorProxy.cpp b/Source/core/workers/WorkerInspectorProxy.cpp
index 3a613359e5c78bdbb0706a5032baaa7c92fe5723..2514f0ccc0be75ce2926c069ed167ef6236f7c89 100644
--- a/Source/core/workers/WorkerInspectorProxy.cpp
+++ b/Source/core/workers/WorkerInspectorProxy.cpp
@@ -11,8 +11,10 @@
#include "core/inspector/InspectorTraceEvents.h"
#include "core/inspector/WorkerInspectorController.h"
#include "core/workers/WorkerThread.h"
+#include "platform/Task.h"
#include "platform/TraceEvent.h"
#include "platform/weborigin/KURL.h"
+#include "public/platform/WebTraceLocation.h"
namespace blink {
@@ -48,9 +50,9 @@ void WorkerInspectorProxy::workerThreadTerminated()
m_pageInspector = nullptr;
}
-static void connectToWorkerGlobalScopeInspectorTask(ExecutionContext* context)
+static void connectToWorkerGlobalScopeInspectorTask(WorkerThread* workerThread)
{
- toWorkerGlobalScope(context)->workerInspectorController()->connectFrontend();
+ workerThread->workerGlobalScope()->workerInspectorController()->connectFrontend();
}
void WorkerInspectorProxy::connectToInspector(WorkerInspectorProxy::PageInspector* pageInspector)
@@ -59,12 +61,12 @@ void WorkerInspectorProxy::connectToInspector(WorkerInspectorProxy::PageInspecto
return;
ASSERT(!m_pageInspector);
m_pageInspector = pageInspector;
- m_workerThread->postDebuggerTask(FROM_HERE, createCrossThreadTask(connectToWorkerGlobalScopeInspectorTask));
+ addDebuggerTaskForWorker(FROM_HERE, adoptPtr(new Task(threadSafeBind(connectToWorkerGlobalScopeInspectorTask, AllowCrossThreadAccess(m_workerThread)))));
}
-static void disconnectFromWorkerGlobalScopeInspectorTask(ExecutionContext* context)
+static void disconnectFromWorkerGlobalScopeInspectorTask(WorkerThread* workerThread)
{
- toWorkerGlobalScope(context)->workerInspectorController()->disconnectFrontend();
+ workerThread->workerGlobalScope()->workerInspectorController()->disconnectFrontend();
}
void WorkerInspectorProxy::disconnectFromInspector()
@@ -72,19 +74,19 @@ void WorkerInspectorProxy::disconnectFromInspector()
m_pageInspector = nullptr;
if (!m_workerThread)
return;
- m_workerThread->postDebuggerTask(FROM_HERE, createCrossThreadTask(disconnectFromWorkerGlobalScopeInspectorTask));
+ addDebuggerTaskForWorker(FROM_HERE, adoptPtr(new Task(threadSafeBind(disconnectFromWorkerGlobalScopeInspectorTask, AllowCrossThreadAccess(m_workerThread)))));
}
-static void dispatchOnInspectorBackendTask(const String& message, ExecutionContext* context)
+static void dispatchOnInspectorBackendTask(const String& message, WorkerThread* workerThread)
{
- toWorkerGlobalScope(context)->workerInspectorController()->dispatchMessageFromFrontend(message);
+ workerThread->workerGlobalScope()->workerInspectorController()->dispatchMessageFromFrontend(message);
}
void WorkerInspectorProxy::sendMessageToInspector(const String& message)
{
if (!m_workerThread)
return;
- m_workerThread->postDebuggerTask(FROM_HERE, createCrossThreadTask(dispatchOnInspectorBackendTask, message));
+ addDebuggerTaskForWorker(FROM_HERE, adoptPtr(new Task(threadSafeBind(dispatchOnInspectorBackendTask, message, AllowCrossThreadAccess(m_workerThread)))));
m_workerThread->interruptAndDispatchInspectorCommands();
}
@@ -95,4 +97,15 @@ void WorkerInspectorProxy::writeTimelineStartedEvent(const String& sessionId, co
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TracingSessionIdForWorker", TRACE_EVENT_SCOPE_THREAD, "data", InspectorTracingSessionIdForWorkerEvent::data(sessionId, workerId, m_workerThread));
}
+static void runDebuggerTaskForWorker(WorkerThread* workerThread)
+{
+ workerThread->runDebuggerTask(WorkerThread::DontWaitForMessage);
+}
+
+void WorkerInspectorProxy::addDebuggerTaskForWorker(const WebTraceLocation& location, PassOwnPtr<WebThread::Task> task)
+{
+ m_workerThread->appendDebuggerTask(task);
+ m_workerThread->backingThread().postTask(location, new Task(threadSafeBind(&runDebuggerTaskForWorker, AllowCrossThreadAccess(m_workerThread))));
+}
+
} // namespace blink
« no previous file with comments | « Source/core/workers/WorkerInspectorProxy.h ('k') | Source/core/workers/WorkerThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698