Reland "Implement V8Platform::CallDelayedOnForegroundThread. (patchset #2 id:20001 of https://codereview.chromium.org/1181113003/)"
This reverts commit f4f00c7a28bb5786f5dce52acf4e8bd2d39df6a2.
BUG=490559
Review URL: https://codereview.chromium.org/1204873003
Cr-Commit-Position: refs/heads/master@{#335937}
diff --git a/gin/public/v8_platform.h b/gin/public/v8_platform.h
index a4fc28a..df189432 100644
--- a/gin/public/v8_platform.h
+++ b/gin/public/v8_platform.h
@@ -23,6 +23,9 @@
v8::Task* task,
v8::Platform::ExpectedRuntime expected_runtime) override;
void CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) override;
+ void CallDelayedOnForegroundThread(v8::Isolate* isolate,
+ v8::Task* task,
+ double delay_in_seconds) override;
double MonotonicallyIncreasingTime() override;
private:
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
index 330aeb3..6214d3d3 100644
--- a/gin/v8_platform.cc
+++ b/gin/v8_platform.cc
@@ -38,6 +38,14 @@
FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)));
}
+void V8Platform::CallDelayedOnForegroundThread(v8::Isolate* isolate,
+ v8::Task* task,
+ double delay_in_seconds) {
+ PerIsolateData::From(isolate)->task_runner()->PostDelayedTask(
+ FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)),
+ base::TimeDelta::FromSecondsD(delay_in_seconds));
+}
+
double V8Platform::MonotonicallyIncreasingTime() {
return base::TimeTicks::Now().ToInternalValue() /
static_cast<double>(base::Time::kMicrosecondsPerSecond);