| 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 10 matching lines...) Expand all Loading... |
| 21 TaskQueueManager* task_queue_manager) { | 21 TaskQueueManager* task_queue_manager) { |
| 22 task_queue_manager_ = task_queue_manager; | 22 task_queue_manager_ = task_queue_manager; |
| 23 DCHECK(task_queue_manager_); | 23 DCHECK(task_queue_manager_); |
| 24 } | 24 } |
| 25 | 25 |
| 26 LazyNow VirtualTimeDomain::CreateLazyNow() { | 26 LazyNow VirtualTimeDomain::CreateLazyNow() { |
| 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::ComputeDelayedRunTime( | |
| 32 base::TimeTicks time_domain_now, | |
| 33 base::TimeDelta delay) const { | |
| 34 return time_domain_now + delay; | |
| 35 } | |
| 36 | |
| 37 void VirtualTimeDomain::RequestWakeup(LazyNow* lazy_now, | 31 void VirtualTimeDomain::RequestWakeup(LazyNow* lazy_now, |
| 38 base::TimeDelta delay) { | 32 base::TimeDelta delay) { |
| 39 // We don't need to do anything here because the caller of AdvanceTo is | 33 // We don't need to do anything here because the caller of AdvanceTo is |
| 40 // responsible for calling TaskQueueManager::MaybeScheduleImmediateWork if | 34 // responsible for calling TaskQueueManager::MaybeScheduleImmediateWork if |
| 41 // needed. | 35 // needed. |
| 42 } | 36 } |
| 43 | 37 |
| 44 bool VirtualTimeDomain::MaybeAdvanceTime() { | 38 bool VirtualTimeDomain::MaybeAdvanceTime() { |
| 45 return false; | 39 return false; |
| 46 } | 40 } |
| 47 | 41 |
| 48 void VirtualTimeDomain::AsValueIntoInternal( | 42 void VirtualTimeDomain::AsValueIntoInternal( |
| 49 base::trace_event::TracedValue* state) const {} | 43 base::trace_event::TracedValue* state) const {} |
| 50 | 44 |
| 51 void VirtualTimeDomain::AdvanceTo(base::TimeTicks now) { | 45 void VirtualTimeDomain::AdvanceTo(base::TimeTicks now) { |
| 52 base::AutoLock lock(lock_); | 46 base::AutoLock lock(lock_); |
| 53 DCHECK_GE(now, now_); | 47 DCHECK_GE(now, now_); |
| 54 now_ = now; | 48 now_ = now; |
| 55 } | 49 } |
| 56 | 50 |
| 57 void VirtualTimeDomain::RequestDoWork() { | 51 void VirtualTimeDomain::RequestDoWork() { |
| 58 task_queue_manager_->MaybeScheduleImmediateWork(FROM_HERE); | 52 task_queue_manager_->MaybeScheduleImmediateWork(FROM_HERE); |
| 59 } | 53 } |
| 60 | 54 |
| 61 const char* VirtualTimeDomain::GetName() const { | 55 const char* VirtualTimeDomain::GetName() const { |
| 62 return "VirtualTimeDomain"; | 56 return "VirtualTimeDomain"; |
| 63 } | 57 } |
| 64 | 58 |
| 65 } // namespace scheduler | 59 } // namespace scheduler |
| OLD | NEW |