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"
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
)
38 if (paint_time
> *max
)
46 void PaintTimeCounter::ClearHistory() {
48 can_save_paint_time_delta_
= false;