OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 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 "cc/debug/paint_time_counter.h" |
| 6 |
| 7 namespace cc { |
| 8 |
| 9 // static |
| 10 scoped_ptr<PaintTimeCounter> PaintTimeCounter::Create() { |
| 11 return make_scoped_ptr(new PaintTimeCounter()); |
| 12 } |
| 13 |
| 14 PaintTimeCounter::PaintTimeCounter() { |
| 15 } |
| 16 |
| 17 void PaintTimeCounter::SavePaintTime(const base::TimeDelta& paint_time) { |
| 18 ring_buffer_.SaveToBuffer(paint_time); |
| 19 } |
| 20 |
| 21 void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min, |
| 22 base::TimeDelta* max) const { |
| 23 *min = base::TimeDelta::FromDays(1); |
| 24 *max = base::TimeDelta(); |
| 25 |
| 26 for (RingBufferType::Iterator it = ring_buffer_.Begin(); it; ++it) { |
| 27 const base::TimeDelta paint_time = **it; |
| 28 |
| 29 if (paint_time < *min) |
| 30 *min = paint_time; |
| 31 if (paint_time > *max) |
| 32 *max = paint_time; |
| 33 } |
| 34 |
| 35 if (*min > *max) |
| 36 *min = *max; |
| 37 } |
| 38 |
| 39 void PaintTimeCounter::ClearHistory() { |
| 40 ring_buffer_.Clear(); |
| 41 } |
| 42 |
| 43 } // namespace cc |
OLD | NEW |