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

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

Issue 2741643003: Replace WorkerGlobalScope::postTask with WorkerThread::postTask (Closed)
Patch Set: missppelling; include cleanup Created 3 years, 9 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 | « third_party/WebKit/Source/core/workers/WorkerThread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/workers/WorkerThread.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.cpp b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
index e76c01f4c0b093588570e2e1b192ff8dbd0da0af..071f7d15a945272f2b9c8a24f55105279a7700ff 100644
--- a/third_party/WebKit/Source/core/workers/WorkerThread.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
@@ -26,6 +26,8 @@
#include "core/workers/WorkerThread.h"
+#include <limits.h>
+#include <memory>
#include "bindings/core/v8/Microtask.h"
#include "bindings/core/v8/ScriptSourceCode.h"
#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
@@ -53,8 +55,6 @@
#include "wtf/PtrUtil.h"
#include "wtf/Threading.h"
#include "wtf/text/WTFString.h"
-#include <limits.h>
-#include <memory>
namespace blink {
@@ -191,13 +191,26 @@ bool WorkerThread::isCurrentThread() {
}
void WorkerThread::postTask(const WebTraceLocation& location,
+ std::unique_ptr<WTF::Closure> task) {
+ DCHECK(isCurrentThread());
+ if (isInShutdown())
+ return;
+ workerBackingThread().backingThread().postTask(
+ location,
+ WTF::bind(
+ &WorkerThread::performTaskOnWorkerThread<WTF::SameThreadAffinity>,
+ WTF::unretained(this), WTF::passed(std::move(task))));
+}
+
+void WorkerThread::postTask(const WebTraceLocation& location,
std::unique_ptr<WTF::CrossThreadClosure> task) {
if (isInShutdown())
return;
workerBackingThread().backingThread().postTask(
- location, crossThreadBind(&WorkerThread::performTaskOnWorkerThread,
- crossThreadUnretained(this),
- WTF::passed(std::move(task))));
+ location,
+ crossThreadBind(
+ &WorkerThread::performTaskOnWorkerThread<WTF::CrossThreadAffinity>,
+ crossThreadUnretained(this), WTF::passed(std::move(task))));
}
void WorkerThread::appendDebuggerTask(
@@ -550,8 +563,9 @@ void WorkerThread::performShutdownOnWorkerThread() {
m_shutdownEvent->signal();
}
+template <WTF::FunctionThreadAffinity threadAffinity>
void WorkerThread::performTaskOnWorkerThread(
- std::unique_ptr<WTF::CrossThreadClosure> task) {
+ std::unique_ptr<Function<void(), threadAffinity>> task) {
DCHECK(isCurrentThread());
if (m_threadState != ThreadState::Running)
return;
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698