Roll src/third_party/WebKit 605a979:06cb9e9 (svn 202556:202558)
[chromium-blink-merge.git] / components / scheduler / child / scheduler_task_runner_delegate_for_test.cc
blobdacfeb7258968eb0a2b5c8462283a059b4f2f506
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/scheduler/child/scheduler_task_runner_delegate_for_test.h"
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "components/scheduler/child/nestable_task_runner_for_test.h"
11 namespace scheduler {
13 // static
14 scoped_refptr<SchedulerTaskRunnerDelegateForTest>
15 SchedulerTaskRunnerDelegateForTest::Create(
16 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
17 return make_scoped_refptr(
18 new SchedulerTaskRunnerDelegateForTest(task_runner));
21 SchedulerTaskRunnerDelegateForTest::SchedulerTaskRunnerDelegateForTest(
22 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
23 : task_runner_(NestableTaskRunnerForTest::Create(task_runner)) {}
25 SchedulerTaskRunnerDelegateForTest::~SchedulerTaskRunnerDelegateForTest() {}
27 void SchedulerTaskRunnerDelegateForTest::SetDefaultTaskRunner(
28 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
29 default_task_runner_ = task_runner.Pass();
32 void SchedulerTaskRunnerDelegateForTest::RestoreDefaultTaskRunner() {
33 default_task_runner_ = nullptr;
36 bool SchedulerTaskRunnerDelegateForTest::PostDelayedTask(
37 const tracked_objects::Location& from_here,
38 const base::Closure& task,
39 base::TimeDelta delay) {
40 return task_runner_->PostDelayedTask(from_here, task, delay);
43 bool SchedulerTaskRunnerDelegateForTest::PostNonNestableDelayedTask(
44 const tracked_objects::Location& from_here,
45 const base::Closure& task,
46 base::TimeDelta delay) {
47 return task_runner_->PostNonNestableDelayedTask(from_here, task, delay);
50 bool SchedulerTaskRunnerDelegateForTest::RunsTasksOnCurrentThread() const {
51 return task_runner_->RunsTasksOnCurrentThread();
54 bool SchedulerTaskRunnerDelegateForTest::IsNested() const {
55 return task_runner_->IsNested();
58 } // namespace scheduler