| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/scheduler/delay_based_time_source.h" | 5 #include "cc/scheduler/delay_based_time_source.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // immediate interval change. kPhaseChangeThreshold is the fraction of the | 26 // immediate interval change. kPhaseChangeThreshold is the fraction of the |
| 27 // interval that will trigger an immediate phase change. If the changes are | 27 // interval that will trigger an immediate phase change. If the changes are |
| 28 // within the thresholds, the change will take place on the next tick. If | 28 // within the thresholds, the change will take place on the next tick. If |
| 29 // either change is outside the thresholds, the next tick will be canceled and | 29 // either change is outside the thresholds, the next tick will be canceled and |
| 30 // reissued immediately. | 30 // reissued immediately. |
| 31 static const double kIntervalChangeThreshold = 0.25; | 31 static const double kIntervalChangeThreshold = 0.25; |
| 32 static const double kPhaseChangeThreshold = 0.25; | 32 static const double kPhaseChangeThreshold = 0.25; |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 // The following methods correspond to the DelayBasedTimeSource that uses |
| 37 // the base::TimeTicks::HighResNow as the timebase. |
| 38 scoped_refptr<DelayBasedTimeSourceHighRes> DelayBasedTimeSourceHighRes::Create( |
| 39 base::TimeDelta interval, |
| 40 base::SingleThreadTaskRunner* task_runner) { |
| 41 return make_scoped_refptr( |
| 42 new DelayBasedTimeSourceHighRes(interval, task_runner)); |
| 43 } |
| 44 |
| 45 DelayBasedTimeSourceHighRes::DelayBasedTimeSourceHighRes( |
| 46 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner) |
| 47 : DelayBasedTimeSource(interval, task_runner) {} |
| 48 |
| 49 DelayBasedTimeSourceHighRes::~DelayBasedTimeSourceHighRes() {} |
| 50 |
| 51 base::TimeTicks DelayBasedTimeSourceHighRes::Now() const { |
| 52 return base::TimeTicks::HighResNow(); |
| 53 } |
| 54 |
| 55 // The following methods correspond to the DelayBasedTimeSource that uses |
| 56 // the base::TimeTicks::Now as the timebase. |
| 36 scoped_refptr<DelayBasedTimeSource> DelayBasedTimeSource::Create( | 57 scoped_refptr<DelayBasedTimeSource> DelayBasedTimeSource::Create( |
| 37 base::TimeDelta interval, | 58 base::TimeDelta interval, |
| 38 base::SingleThreadTaskRunner* task_runner) { | 59 base::SingleThreadTaskRunner* task_runner) { |
| 39 return make_scoped_refptr(new DelayBasedTimeSource(interval, task_runner)); | 60 return make_scoped_refptr(new DelayBasedTimeSource(interval, task_runner)); |
| 40 } | 61 } |
| 41 | 62 |
| 42 DelayBasedTimeSource::DelayBasedTimeSource( | 63 DelayBasedTimeSource::DelayBasedTimeSource( |
| 43 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner) | 64 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner) |
| 44 : client_(NULL), | 65 : client_(NULL), |
| 45 last_tick_time_(base::TimeTicks() - interval), | 66 last_tick_time_(base::TimeTicks() - interval), |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 task_runner_->PostDelayedTask(FROM_HERE, | 266 task_runner_->PostDelayedTask(FROM_HERE, |
| 246 base::Bind(&DelayBasedTimeSource::OnTimerFired, | 267 base::Bind(&DelayBasedTimeSource::OnTimerFired, |
| 247 weak_factory_.GetWeakPtr()), | 268 weak_factory_.GetWeakPtr()), |
| 248 delay); | 269 delay); |
| 249 | 270 |
| 250 next_parameters_.tick_target = new_tick_target; | 271 next_parameters_.tick_target = new_tick_target; |
| 251 current_parameters_ = next_parameters_; | 272 current_parameters_ = next_parameters_; |
| 252 } | 273 } |
| 253 | 274 |
| 254 } // namespace cc | 275 } // namespace cc |
| OLD | NEW |