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

Side by Side Diff: components/scheduler/child/scheduler_tqm_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_tqm_delegate_impl.h"
6
7 namespace scheduler {
8
9 // static
10 scoped_refptr<SchedulerTqmDelegateImpl> SchedulerTqmDelegateImpl::Create(
11 base::MessageLoop* message_loop,
12 scoped_ptr<base::TickClock> time_source) {
13 return make_scoped_refptr(
14 new SchedulerTqmDelegateImpl(message_loop, time_source.Pass()));
15 }
16
17 SchedulerTqmDelegateImpl::SchedulerTqmDelegateImpl(
18 base::MessageLoop* message_loop,
19 scoped_ptr<base::TickClock> time_source)
20 : message_loop_(message_loop),
21 message_loop_task_runner_(message_loop->task_runner()),
22 time_source_(time_source.Pass()) {}
23
24 SchedulerTqmDelegateImpl::~SchedulerTqmDelegateImpl() {
25 RestoreDefaultTaskRunner();
26 }
27
28 void SchedulerTqmDelegateImpl::SetDefaultTaskRunner(
29 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
30 message_loop_->SetTaskRunner(task_runner);
31 }
32
33 void SchedulerTqmDelegateImpl::RestoreDefaultTaskRunner() {
34 if (base::MessageLoop::current() == message_loop_)
35 message_loop_->SetTaskRunner(message_loop_task_runner_);
36 }
37
38 bool SchedulerTqmDelegateImpl::PostDelayedTask(
39 const tracked_objects::Location& from_here,
40 const base::Closure& task,
41 base::TimeDelta delay) {
42 return message_loop_task_runner_->PostDelayedTask(from_here, task, delay);
43 }
44
45 bool SchedulerTqmDelegateImpl::PostNonNestableDelayedTask(
46 const tracked_objects::Location& from_here,
47 const base::Closure& task,
48 base::TimeDelta delay) {
49 return message_loop_task_runner_->PostNonNestableDelayedTask(from_here, task,
50 delay);
51 }
52
53 bool SchedulerTqmDelegateImpl::RunsTasksOnCurrentThread() const {
54 return message_loop_task_runner_->RunsTasksOnCurrentThread();
55 }
56
57 bool SchedulerTqmDelegateImpl::IsNested() const {
58 return message_loop_->IsNested();
59 }
60
61 base::TimeTicks SchedulerTqmDelegateImpl::NowTicks() {
62 return time_source_->NowTicks();
63 }
64
65 void SchedulerTqmDelegateImpl::OnNoMoreImmediateWork() {}
66
67 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698