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

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

Issue 1411843008: Make blink platform time consistent with the timer virtual time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CachingCorrectnessTest 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
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/child/virtual_time_tqm_delegate.h" 5 #include "components/scheduler/child/virtual_time_tqm_delegate.h"
6 6
7 namespace scheduler { 7 namespace scheduler {
8 8
9 // static 9 // static
10 scoped_refptr<VirtualTimeTqmDelegate> VirtualTimeTqmDelegate::Create( 10 scoped_refptr<VirtualTimeTqmDelegate> VirtualTimeTqmDelegate::Create(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 bool VirtualTimeTqmDelegate::IsNested() const { 60 bool VirtualTimeTqmDelegate::IsNested() const {
61 return message_loop_->IsNested(); 61 return message_loop_->IsNested();
62 } 62 }
63 63
64 base::TimeTicks VirtualTimeTqmDelegate::NowTicks() { 64 base::TimeTicks VirtualTimeTqmDelegate::NowTicks() {
65 return now_; 65 return now_;
66 } 66 }
67 67
68 double VirtualTimeTqmDelegate::CurrentTimeSeconds() const {
69 return (now_ - base::TimeTicks::UnixEpoch()).InSecondsF();
70 }
71
68 void VirtualTimeTqmDelegate::AdvancedTimeTo(base::TimeTicks now) { 72 void VirtualTimeTqmDelegate::AdvancedTimeTo(base::TimeTicks now) {
69 now_ = now; 73 now_ = now;
70 DCHECK_GE(now, now_); 74 DCHECK_GE(now, now_);
71 while (!delayed_wakeup_multimap_.empty()) { 75 while (!delayed_wakeup_multimap_.empty()) {
72 DelayedWakeupMultimap::iterator next_wakeup = 76 DelayedWakeupMultimap::iterator next_wakeup =
73 delayed_wakeup_multimap_.begin(); 77 delayed_wakeup_multimap_.begin();
74 if (next_wakeup->first > now) 78 if (next_wakeup->first > now)
75 break; 79 break;
76 message_loop_task_runner_->PostDelayedTask(FROM_HERE, next_wakeup->second, 80 message_loop_task_runner_->PostDelayedTask(FROM_HERE, next_wakeup->second,
77 base::TimeDelta()); 81 base::TimeDelta());
78 delayed_wakeup_multimap_.erase(next_wakeup); 82 delayed_wakeup_multimap_.erase(next_wakeup);
79 } 83 }
80 } 84 }
81 85
82 void VirtualTimeTqmDelegate::OnNoMoreImmediateWork() { 86 void VirtualTimeTqmDelegate::OnNoMoreImmediateWork() {
83 if (delayed_wakeup_multimap_.empty()) 87 if (delayed_wakeup_multimap_.empty())
84 return; 88 return;
85 89
86 AdvancedTimeTo(delayed_wakeup_multimap_.begin()->first); 90 AdvancedTimeTo(delayed_wakeup_multimap_.begin()->first);
87 } 91 }
88 92
89 } // namespace scheduler 93 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/child/virtual_time_tqm_delegate.h ('k') | components/scheduler/renderer/renderer_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698