Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: components/scheduler/child/scheduler_task_runner_delegate_impl.cc

Issue 1424053002: Adds a flag to support "Virtual Time" to the blink scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "components/scheduler/child/scheduler_task_runner_delegate_impl.h"
6
7 namespace scheduler {
8
9 // static
10 scoped_refptr<SchedulerTaskRunnerDelegateImpl>
11 SchedulerTaskRunnerDelegateImpl::Create(base::MessageLoop* message_loop) {
12 return make_scoped_refptr(new SchedulerTaskRunnerDelegateImpl(message_loop));
13 }
14
15 SchedulerTaskRunnerDelegateImpl::SchedulerTaskRunnerDelegateImpl(
16 base::MessageLoop* message_loop)
17 : message_loop_(message_loop),
18 message_loop_task_runner_(message_loop->task_runner()) {}
19
20 SchedulerTaskRunnerDelegateImpl::~SchedulerTaskRunnerDelegateImpl() {
21 RestoreDefaultTaskRunner();
22 }
23
24 void SchedulerTaskRunnerDelegateImpl::SetDefaultTaskRunner(
25 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
26 message_loop_->SetTaskRunner(task_runner);
27 }
28
29 void SchedulerTaskRunnerDelegateImpl::RestoreDefaultTaskRunner() {
30 if (base::MessageLoop::current() == message_loop_)
31 message_loop_->SetTaskRunner(message_loop_task_runner_);
32 }
33
34 bool SchedulerTaskRunnerDelegateImpl::PostDelayedTask(
35 const tracked_objects::Location& from_here,
36 const base::Closure& task,
37 base::TimeDelta delay) {
38 return message_loop_task_runner_->PostDelayedTask(from_here, task, delay);
39 }
40
41 bool SchedulerTaskRunnerDelegateImpl::PostNonNestableDelayedTask(
42 const tracked_objects::Location& from_here,
43 const base::Closure& task,
44 base::TimeDelta delay) {
45 return message_loop_task_runner_->PostNonNestableDelayedTask(from_here, task,
46 delay);
47 }
48
49 bool SchedulerTaskRunnerDelegateImpl::RunsTasksOnCurrentThread() const {
50 return message_loop_task_runner_->RunsTasksOnCurrentThread();
51 }
52
53 bool SchedulerTaskRunnerDelegateImpl::IsNested() const {
54 return message_loop_->IsNested();
55 }
56
57 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698