[tracing] Implement RunsTasksOnCurrentThread() properly

Perfetto will actually call this from the main thread in various cases
so we need to implement it.

Cq-Include-Trybots: luci.v8.try:v8_linux64_perfetto_dbg_ng
Bug: v8:8339
Change-Id: I509fa277fb0f7e98e9dea4d991a2d313e0a249da
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1599183
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61320}
diff --git a/src/libplatform/tracing/perfetto-tasks.cc b/src/libplatform/tracing/perfetto-tasks.cc
index fd6a3d5..70d00ed 100644
--- a/src/libplatform/tracing/perfetto-tasks.cc
+++ b/src/libplatform/tracing/perfetto-tasks.cc
@@ -34,14 +34,11 @@
 }
 
 bool PerfettoTaskRunner::RunsTasksOnCurrentThread() const {
-  // TODO(petermarshall): Can be called from the V8 main thread in some
-  // situations so we actually need to implement this properly.
-  return true;
+  return runner_.RunsTasksOnCurrentThread();
 }
 
 void PerfettoTaskRunner::FinishImmediateTasks() {
-  // TODO(petermarshall): Add a check !RunsTasksOnCurrentThread() once that is
-  // implemented properly.
+  DCHECK(!RunsTasksOnCurrentThread());
   base::Semaphore semaphore(0);
   // PostTask has guaranteed ordering so this will be the last task executed.
   runner_.PostTask(