| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/scheduler/base/virtual_time_domain.h" | 5 #include "components/scheduler/base/virtual_time_domain.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "components/scheduler/base/task_queue_impl.h" | 8 #include "components/scheduler/base/task_queue_impl.h" |
| 9 #include "components/scheduler/base/task_queue_manager.h" | 9 #include "components/scheduler/base/task_queue_manager.h" |
| 10 #include "components/scheduler/base/task_queue_manager_delegate.h" | 10 #include "components/scheduler/base/task_queue_manager_delegate.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 LazyNow VirtualTimeDomain::CreateLazyNow() const { | 26 LazyNow VirtualTimeDomain::CreateLazyNow() const { |
| 27 base::AutoLock lock(lock_); | 27 base::AutoLock lock(lock_); |
| 28 return LazyNow(now_); | 28 return LazyNow(now_); |
| 29 } | 29 } |
| 30 | 30 |
| 31 base::TimeTicks VirtualTimeDomain::Now() const { | 31 base::TimeTicks VirtualTimeDomain::Now() const { |
| 32 base::AutoLock lock(lock_); | 32 base::AutoLock lock(lock_); |
| 33 return now_; | 33 return now_; |
| 34 } | 34 } |
| 35 | 35 |
| 36 base::TimeTicks VirtualTimeDomain::ComputeDelayedRunTime( |
| 37 base::TimeTicks time_domain_now, |
| 38 base::TimeDelta delay) const { |
| 39 return time_domain_now + delay; |
| 40 } |
| 41 |
| 36 void VirtualTimeDomain::RequestWakeup(base::TimeTicks now, | 42 void VirtualTimeDomain::RequestWakeup(base::TimeTicks now, |
| 37 base::TimeDelta delay) { | 43 base::TimeDelta delay) { |
| 38 // We don't need to do anything here because the caller of AdvanceTo is | 44 // We don't need to do anything here because the caller of AdvanceTo is |
| 39 // responsible for calling TaskQueueManager::MaybeScheduleImmediateWork if | 45 // responsible for calling TaskQueueManager::MaybeScheduleImmediateWork if |
| 40 // needed. | 46 // needed. |
| 41 } | 47 } |
| 42 | 48 |
| 43 bool VirtualTimeDomain::MaybeAdvanceTime() { | 49 bool VirtualTimeDomain::MaybeAdvanceTime() { |
| 44 return false; | 50 return false; |
| 45 } | 51 } |
| 46 | 52 |
| 47 void VirtualTimeDomain::AsValueIntoInternal( | 53 void VirtualTimeDomain::AsValueIntoInternal( |
| 48 base::trace_event::TracedValue* state) const {} | 54 base::trace_event::TracedValue* state) const {} |
| 49 | 55 |
| 50 void VirtualTimeDomain::AdvanceTo(base::TimeTicks now) { | 56 void VirtualTimeDomain::AdvanceTo(base::TimeTicks now) { |
| 51 base::AutoLock lock(lock_); | 57 base::AutoLock lock(lock_); |
| 52 DCHECK_GE(now, now_); | 58 DCHECK_GE(now, now_); |
| 53 now_ = now; | 59 now_ = now; |
| 54 } | 60 } |
| 55 | 61 |
| 56 void VirtualTimeDomain::RequestDoWork() { | 62 void VirtualTimeDomain::RequestDoWork() { |
| 57 task_queue_manager_->MaybeScheduleImmediateWork(FROM_HERE); | 63 task_queue_manager_->MaybeScheduleImmediateWork(FROM_HERE); |
| 58 } | 64 } |
| 59 | 65 |
| 60 const char* VirtualTimeDomain::GetName() const { | 66 const char* VirtualTimeDomain::GetName() const { |
| 61 return "VirtualTimeDomain"; | 67 return "VirtualTimeDomain"; |
| 62 } | 68 } |
| 63 | 69 |
| 64 } // namespace scheduler | 70 } // namespace scheduler |
| OLD | NEW |