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

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

Issue 2640813006: Worker: Move instrumentation flag check from WorkerThread to WorkerOrWorkletGlobalScope (Closed)
Patch Set: Created 3 years, 11 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/WorkerOrWorkletGlobalScope.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp b/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp
index 9306f804f414698210b623780a34d3e1f414470a..1a79822579153f1b162750fe0a14b5f0bbc49494 100644
--- a/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp
@@ -6,6 +6,7 @@
#include "core/frame/Deprecation.h"
#include "core/inspector/ConsoleMessage.h"
+#include "core/inspector/InspectorInstrumentation.h"
#include "core/workers/WorkerReportingProxy.h"
#include "core/workers/WorkerThread.h"
@@ -39,8 +40,27 @@ void WorkerOrWorkletGlobalScope::postTask(
const String& taskNameForInstrumentation) {
if (!thread())
return;
- thread()->postTask(location, std::move(task),
- !taskNameForInstrumentation.isEmpty());
+
+ bool isInstrumented = !taskNameForInstrumentation.isEmpty();
+ if (isInstrumented) {
+ InspectorInstrumentation::asyncTaskScheduled(this, "Worker task",
+ task.get());
+ }
+
+ std::unique_ptr<ExecutionContextTask> wrappedTask = createCrossThreadTask(
+ &WorkerOrWorkletGlobalScope::runTask, wrapCrossThreadWeakPersistent(this),
+ WTF::passed(std::move(task)), isInstrumented);
+ thread()->postTask(location, std::move(wrappedTask));
+}
+
+void WorkerOrWorkletGlobalScope::runTask(
+ std::unique_ptr<ExecutionContextTask> task,
+ bool isInstrumented,
+ ExecutionContext*) {
+ DCHECK(thread()->isCurrentThread());
+ InspectorInstrumentation::AsyncTask asyncTask(this, task.get(),
+ isInstrumented);
+ task->performTask(this);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698