Skip to content

Commit

Permalink
[gin] Implement V8ForegroundTaskRunner::PostNonNestableDelayedTask
Browse files Browse the repository at this point in the history
Needed for the Atomics.waitAsync API's timeout functionality

Bug: chromium:1167541
Change-Id: I713348641a7eeb74f924a8f3081cb746989b9bda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2691397
Auto-Submit: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#853445}
  • Loading branch information
syg authored and Chromium LUCI CQ committed Feb 12, 2021
1 parent b101723 commit bce979e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gin/v8_foreground_task_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ void V8ForegroundTaskRunner::PostDelayedTask(std::unique_ptr<v8::Task> task,
base::TimeDelta::FromSecondsD(delay_in_seconds));
}

void V8ForegroundTaskRunner::PostNonNestableDelayedTask(
std::unique_ptr<v8::Task> task,
double delay_in_seconds) {
task_runner_->PostNonNestableDelayedTask(
FROM_HERE, base::BindOnce(&v8::Task::Run, std::move(task)),
base::TimeDelta::FromSecondsD(delay_in_seconds));
}

void V8ForegroundTaskRunner::PostIdleTask(std::unique_ptr<v8::IdleTask> task) {
DCHECK(IdleTasksEnabled());
idle_task_runner()->PostIdleTask(std::move(task));
Expand All @@ -46,4 +54,8 @@ bool V8ForegroundTaskRunner::NonNestableTasksEnabled() const {
return true;
}

bool V8ForegroundTaskRunner::NonNestableDelayedTasksEnabled() const {
return true;
}

} // namespace gin
4 changes: 4 additions & 0 deletions gin/v8_foreground_task_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ class V8ForegroundTaskRunner : public V8ForegroundTaskRunnerBase {
void PostDelayedTask(std::unique_ptr<v8::Task> task,
double delay_in_seconds) override;

void PostNonNestableDelayedTask(std::unique_ptr<v8::Task> task,
double delay_in_seconds) override;

void PostIdleTask(std::unique_ptr<v8::IdleTask> task) override;

bool NonNestableTasksEnabled() const override;
bool NonNestableDelayedTasksEnabled() const override;

private:
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
Expand Down

0 comments on commit bce979e

Please sign in to comment.