Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / debug / paint_time_counter.cc
blob7d5415427ff5e9a2763954566a0cce2c561b5e51
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.
5 #include "cc/debug/paint_time_counter.h"
7 namespace cc {
9 // static
10 scoped_ptr<PaintTimeCounter> PaintTimeCounter::Create() {
11 return make_scoped_ptr(new PaintTimeCounter());
14 PaintTimeCounter::PaintTimeCounter()
15 : can_save_paint_time_delta_(false) {
18 void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time) {
19 if (can_save_paint_time_delta_) {
20 base::TimeDelta paint_time = total_paint_time - last_total_paint_time_;
21 ring_buffer_.SaveToBuffer(paint_time);
24 last_total_paint_time_ = total_paint_time;
25 can_save_paint_time_delta_ = true;
28 void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min,
29 base::TimeDelta* max) const {
30 *min = base::TimeDelta::FromDays(1);
31 *max = base::TimeDelta();
33 for (RingBufferType::Iterator it = ring_buffer_.Begin(); it; ++it) {
34 const base::TimeDelta paint_time = **it;
36 if (paint_time < *min)
37 *min = paint_time;
38 if (paint_time > *max)
39 *max = paint_time;
42 if (*min > *max)
43 *min = *max;
46 void PaintTimeCounter::ClearHistory() {
47 ring_buffer_.Clear();
48 can_save_paint_time_delta_ = false;
51 } // namespace cc