| Index: base/test/test_simple_task_runner.cc
|
| diff --git a/base/test/test_simple_task_runner.cc b/base/test/test_simple_task_runner.cc
|
| index e7779184f390c3b83a1fa4a6b4ae22faeaef9aea..090a72e96adf0f0c8ae4445f1965a6c1b31bb7ed 100644
|
| --- a/base/test/test_simple_task_runner.cc
|
| +++ b/base/test/test_simple_task_runner.cc
|
| @@ -5,6 +5,8 @@
|
| #include "base/test/test_simple_task_runner.h"
|
|
|
| #include "base/logging.h"
|
| +#include "base/memory/ptr_util.h"
|
| +#include "base/threading/thread_task_runner_handle.h"
|
|
|
| namespace base {
|
|
|
| @@ -34,6 +36,9 @@ bool TestSimpleTaskRunner::PostNonNestableDelayedTask(
|
| return true;
|
| }
|
|
|
| +// TODO(gab): Use SequenceToken here to differentiate between tasks running in
|
| +// the scope of this TestSimpleTaskRunner and other task runners sharing this
|
| +// thread. http://crbug.com/631186
|
| bool TestSimpleTaskRunner::RunsTasksOnCurrentThread() const {
|
| return thread_ref_ == PlatformThread::CurrentRef();
|
| }
|
| @@ -78,6 +83,14 @@ void TestSimpleTaskRunner::RunPendingTasks() {
|
| tasks_to_run.swap(pending_tasks_);
|
| }
|
|
|
| + // Multiple test task runners can share the same thread for determinism in
|
| + // unit tests. Make sure this TestSimpleTaskRunner's tasks run in its scope.
|
| + ScopedClosureRunner undo_override;
|
| + if (!ThreadTaskRunnerHandle::IsSet() ||
|
| + ThreadTaskRunnerHandle::Get() != this) {
|
| + undo_override = ThreadTaskRunnerHandle::OverrideForTesting(this);
|
| + }
|
| +
|
| for (auto& task : tasks_to_run)
|
| std::move(task.task).Run();
|
| }
|
|
|