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

Unified Diff: third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp

Issue 2829683006: Threading: Add thread checks in TaskRunnerHelper
Patch Set: GlobalScopeScheduler / MessagePort fix (333 layout tests failed on linux_chromium_rel_ng) Created 3 years, 8 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 | « no previous file | 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/dom/TaskRunnerHelper.cpp
diff --git a/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp b/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
index 631c5de8c0ec7a26c67b96aea14956e1c38bf507..afed2a87eab6e828831f3a4f4c1824631bd61046 100644
--- a/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
+++ b/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
@@ -17,6 +17,7 @@
namespace blink {
RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, LocalFrame* frame) {
+ DCHECK(WTF::IsMainThread());
// TODO(haraken): Optimize the mapping from TaskTypes to task runners.
switch (type) {
case TaskType::kTimer:
@@ -61,20 +62,18 @@ RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, LocalFrame* frame) {
}
RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, Document* document) {
+ DCHECK(!document || document->IsContextThread());
return Get(type, document ? document->GetFrame() : nullptr);
}
RefPtr<WebTaskRunner> TaskRunnerHelper::Get(
TaskType type,
- ExecutionContext* executionContext) {
- if (!executionContext)
- return Get(type, ToDocument(executionContext));
- if (executionContext->IsDocument())
- return Get(type, ToDocument(executionContext));
- if (executionContext->IsWorkerOrWorkletGlobalScope())
- return Get(type, ToWorkerOrWorkletGlobalScope(executionContext));
- executionContext = nullptr;
- return Get(type, ToDocument(executionContext));
+ ExecutionContext* execution_context) {
+ DCHECK(!execution_context || execution_context->IsContextThread());
+ if (!execution_context || execution_context->IsDocument())
+ return Get(type, ToDocument(execution_context));
+ DCHECK(execution_context->IsWorkerOrWorkletGlobalScope());
+ return Get(type, ToWorkerOrWorkletGlobalScope(execution_context));
}
RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698