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

Unified Diff: third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp

Issue 2163983004: Pass per-frame task runners to Workers (when possible) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 5 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: third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp
diff --git a/third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp b/third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp
index eb7d39119011adb69e2f6202caa331b99e9f83b1..b0d0e0318242ea659dc611b209fca5c22fdca560 100644
--- a/third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp
+++ b/third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp
@@ -37,6 +37,9 @@
#include "core/dom/ExecutionContext.h"
#include "core/inspector/ConsoleMessage.h"
#include "core/workers/InProcessWorkerMessagingProxy.h"
+#include "core/workers/ParentFrameTaskRunners.h"
+#include "platform/CrossThreadFunctional.h"
+#include "public/platform/WebTaskRunner.h"
#include "wtf/Functional.h"
#include "wtf/PtrUtil.h"
#include <memory>
@@ -51,50 +54,55 @@ std::unique_ptr<InProcessWorkerObjectProxy> InProcessWorkerObjectProxy::create(I
void InProcessWorkerObjectProxy::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
{
- getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InProcessWorkerMessagingProxy::postMessageToWorkerObject, crossThreadUnretained(m_messagingProxy), message, passed(std::move(channels))));
+ getParentFrameTaskRunners()->getUnthrottledTaskRunner()->postTask(BLINK_FROM_HERE, crossThreadBind(&InProcessWorkerMessagingProxy::postMessageToWorkerObject, crossThreadUnretained(m_messagingProxy), message, passed(std::move(channels))));
}
void InProcessWorkerObjectProxy::postTaskToMainExecutionContext(std::unique_ptr<ExecutionContextTask> task)
{
+ // TODO(hiroshige,yuryu): Make this not use ExecutionContextTask and use
+ // getParentFrameTaskRunners() instead.
getExecutionContext()->postTask(BLINK_FROM_HERE, std::move(task));
}
void InProcessWorkerObjectProxy::confirmMessageFromWorkerObject(bool hasPendingActivity)
{
- getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InProcessWorkerMessagingProxy::confirmMessageFromWorkerObject, crossThreadUnretained(m_messagingProxy), hasPendingActivity));
+ getParentFrameTaskRunners()->getUnthrottledTaskRunner()->postTask(BLINK_FROM_HERE, crossThreadBind(&InProcessWorkerMessagingProxy::confirmMessageFromWorkerObject, crossThreadUnretained(m_messagingProxy), hasPendingActivity));
}
void InProcessWorkerObjectProxy::reportPendingActivity(bool hasPendingActivity)
{
- getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InProcessWorkerMessagingProxy::reportPendingActivity, crossThreadUnretained(m_messagingProxy), hasPendingActivity));
+ getParentFrameTaskRunners()->getUnthrottledTaskRunner()->postTask(BLINK_FROM_HERE, crossThreadBind(&InProcessWorkerMessagingProxy::reportPendingActivity, crossThreadUnretained(m_messagingProxy), hasPendingActivity));
}
void InProcessWorkerObjectProxy::reportException(const String& errorMessage, std::unique_ptr<SourceLocation> location)
{
- getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InProcessWorkerMessagingProxy::reportException, crossThreadUnretained(m_messagingProxy), errorMessage, passed(std::move(location))));
+ getParentFrameTaskRunners()->getUnthrottledTaskRunner()->postTask(BLINK_FROM_HERE, crossThreadBind(&InProcessWorkerMessagingProxy::reportException, crossThreadUnretained(m_messagingProxy), errorMessage, passed(std::move(location))));
}
void InProcessWorkerObjectProxy::reportConsoleMessage(ConsoleMessage* consoleMessage)
{
- getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InProcessWorkerMessagingProxy::reportConsoleMessage, crossThreadUnretained(m_messagingProxy), consoleMessage->source(), consoleMessage->level(), consoleMessage->message(), passed(consoleMessage->location()->clone())));
+ getParentFrameTaskRunners()->getUnthrottledTaskRunner()->postTask(BLINK_FROM_HERE, crossThreadBind(&InProcessWorkerMessagingProxy::reportConsoleMessage, crossThreadUnretained(m_messagingProxy), consoleMessage->source(), consoleMessage->level(), consoleMessage->message(), passed(consoleMessage->location()->clone())));
}
void InProcessWorkerObjectProxy::postMessageToPageInspector(const String& message)
{
ExecutionContext* context = getExecutionContext();
- if (context->isDocument())
+ if (context->isDocument()) {
+ // TODO(hiroshige): consider using getParentFrameTaskRunners() here
+ // too.
toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThreadTask(&InProcessWorkerMessagingProxy::postMessageToPageInspector, crossThreadUnretained(m_messagingProxy), message));
+ }
}
void InProcessWorkerObjectProxy::workerGlobalScopeClosed()
{
- getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InProcessWorkerMessagingProxy::terminateWorkerGlobalScope, crossThreadUnretained(m_messagingProxy)));
+ getParentFrameTaskRunners()->getUnthrottledTaskRunner()->postTask(BLINK_FROM_HERE, crossThreadBind(&InProcessWorkerMessagingProxy::terminateWorkerGlobalScope, crossThreadUnretained(m_messagingProxy)));
}
void InProcessWorkerObjectProxy::workerThreadTerminated()
{
// This will terminate the MessagingProxy.
- getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InProcessWorkerMessagingProxy::workerThreadTerminated, crossThreadUnretained(m_messagingProxy)));
+ getParentFrameTaskRunners()->getUnthrottledTaskRunner()->postTask(BLINK_FROM_HERE, crossThreadBind(&InProcessWorkerMessagingProxy::workerThreadTerminated, crossThreadUnretained(m_messagingProxy)));
}
InProcessWorkerObjectProxy::InProcessWorkerObjectProxy(InProcessWorkerMessagingProxy* messagingProxy)
@@ -102,6 +110,12 @@ InProcessWorkerObjectProxy::InProcessWorkerObjectProxy(InProcessWorkerMessagingP
{
}
+ParentFrameTaskRunners* InProcessWorkerObjectProxy::getParentFrameTaskRunners()
+{
+ DCHECK(m_messagingProxy);
+ return m_messagingProxy->getParentFrameTaskRunners();
+}
+
ExecutionContext* InProcessWorkerObjectProxy::getExecutionContext()
{
DCHECK(m_messagingProxy);

Powered by Google App Engine
This is Rietveld 408576698