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
3 // found in the LICENSE file.
5 #include "cc/debug/frame_timing_tracker.h"
10 #include "base/metrics/histogram.h"
11 #include "cc/trees/proxy.h"
15 FrameTimingTracker::CompositeTimingEvent::CompositeTimingEvent(
17 base::TimeTicks _timestamp
)
18 : frame_id(_frame_id
), timestamp(_timestamp
) {
21 FrameTimingTracker::CompositeTimingEvent::~CompositeTimingEvent() {
25 scoped_ptr
<FrameTimingTracker
> FrameTimingTracker::Create() {
26 return make_scoped_ptr(new FrameTimingTracker
);
29 FrameTimingTracker::FrameTimingTracker() {
32 FrameTimingTracker::~FrameTimingTracker() {
35 void FrameTimingTracker::SaveTimeStamps(
36 base::TimeTicks timestamp
,
37 const std::vector
<FrameAndRectIds
>& frame_ids
) {
38 if (!composite_events_
)
39 composite_events_
.reset(new CompositeTimingSet
);
40 for (const auto& pair
: frame_ids
)
41 (*composite_events_
)[pair
.second
].push_back(
42 CompositeTimingEvent(pair
.first
, timestamp
));
45 scoped_ptr
<FrameTimingTracker::CompositeTimingSet
>
46 FrameTimingTracker::GroupCountsByRectId() {
47 if (!composite_events_
)
48 return make_scoped_ptr(new CompositeTimingSet
);
49 scoped_ptr
<CompositeTimingSet
> composite_info(new CompositeTimingSet
);
50 for (auto& infos
: *composite_events_
)
52 infos
.second
.begin(), infos
.second
.end(),
53 [](const CompositeTimingEvent
& lhs
, const CompositeTimingEvent
& rhs
) {
54 return lhs
.timestamp
< rhs
.timestamp
;
56 return composite_events_
.Pass();