OLD | NEW |
| (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/base/virtual_time_domain.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "components/scheduler/base/task_queue_impl.h" | |
9 #include "components/scheduler/base/task_queue_manager.h" | |
10 #include "components/scheduler/base/task_queue_manager_delegate.h" | |
11 | |
12 namespace scheduler { | |
13 | |
14 VirtualTimeDomain::VirtualTimeDomain(TimeDomain::Observer* observer, | |
15 base::TimeTicks initial_time) | |
16 : TimeDomain(observer), now_(initial_time), task_queue_manager_(nullptr) {} | |
17 | |
18 VirtualTimeDomain::~VirtualTimeDomain() {} | |
19 | |
20 void VirtualTimeDomain::OnRegisterWithTaskQueueManager( | |
21 TaskQueueManager* task_queue_manager) { | |
22 task_queue_manager_ = task_queue_manager; | |
23 DCHECK(task_queue_manager_); | |
24 } | |
25 | |
26 LazyNow VirtualTimeDomain::CreateLazyNow() const { | |
27 base::AutoLock lock(lock_); | |
28 return LazyNow(now_); | |
29 } | |
30 | |
31 base::TimeTicks VirtualTimeDomain::Now() const { | |
32 base::AutoLock lock(lock_); | |
33 return now_; | |
34 } | |
35 | |
36 void VirtualTimeDomain::RequestWakeup(base::TimeTicks now, | |
37 base::TimeDelta delay) { | |
38 // We don't need to do anything here because the caller of AdvanceTo is | |
39 // responsible for calling TaskQueueManager::MaybeScheduleImmediateWork if | |
40 // needed. | |
41 } | |
42 | |
43 bool VirtualTimeDomain::MaybeAdvanceTime() { | |
44 return false; | |
45 } | |
46 | |
47 void VirtualTimeDomain::AsValueIntoInternal( | |
48 base::trace_event::TracedValue* state) const {} | |
49 | |
50 void VirtualTimeDomain::AdvanceTo(base::TimeTicks now) { | |
51 base::AutoLock lock(lock_); | |
52 DCHECK_GE(now, now_); | |
53 now_ = now; | |
54 } | |
55 | |
56 void VirtualTimeDomain::RequestDoWork() { | |
57 task_queue_manager_->MaybeScheduleImmediateWork(FROM_HERE); | |
58 } | |
59 | |
60 const char* VirtualTimeDomain::GetName() const { | |
61 return "VirtualTimeDomain"; | |
62 } | |
63 | |
64 } // namespace scheduler | |
OLD | NEW |