OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CC_DEBUG_FRAME_TIMING_TRACKER_H_ | 5 #ifndef CC_DEBUG_FRAME_TIMING_TRACKER_H_ |
6 #define CC_DEBUG_FRAME_TIMING_TRACKER_H_ | 6 #define CC_DEBUG_FRAME_TIMING_TRACKER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <unordered_map> | 11 #include <unordered_map> |
11 #include <utility> | 12 #include <utility> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "cc/base/cc_export.h" | 17 #include "cc/base/cc_export.h" |
18 #include "cc/base/delayed_unique_notifier.h" | 18 #include "cc/base/delayed_unique_notifier.h" |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 | 21 |
22 class LayerTreeHostImpl; | 22 class LayerTreeHostImpl; |
23 | 23 |
24 // This class maintains a history of timestamps and rect IDs to communicate | 24 // This class maintains a history of timestamps and rect IDs to communicate |
25 // frame events back to Blink | 25 // frame events back to Blink |
(...skipping 18 matching lines...) Expand all Loading... |
44 ~MainFrameTimingEvent(); | 44 ~MainFrameTimingEvent(); |
45 | 45 |
46 int frame_id; | 46 int frame_id; |
47 base::TimeTicks timestamp; | 47 base::TimeTicks timestamp; |
48 base::TimeTicks end_time; | 48 base::TimeTicks end_time; |
49 }; | 49 }; |
50 | 50 |
51 using MainFrameTimingSet = | 51 using MainFrameTimingSet = |
52 std::unordered_map<int64_t, std::vector<MainFrameTimingEvent>>; | 52 std::unordered_map<int64_t, std::vector<MainFrameTimingEvent>>; |
53 | 53 |
54 static scoped_ptr<FrameTimingTracker> Create( | 54 static std::unique_ptr<FrameTimingTracker> Create( |
55 LayerTreeHostImpl* layer_tree_host_impl); | 55 LayerTreeHostImpl* layer_tree_host_impl); |
56 | 56 |
57 ~FrameTimingTracker(); | 57 ~FrameTimingTracker(); |
58 | 58 |
59 // This routine takes all of the individual CompositeEvents stored in the | 59 // This routine takes all of the individual CompositeEvents stored in the |
60 // tracker and collects them by "rect_id", as in the example below. | 60 // tracker and collects them by "rect_id", as in the example below. |
61 // [ {f_id1,r_id1,t1}, {f_id2,r_id1,t2}, {f_id3,r_id2,t3} ] | 61 // [ {f_id1,r_id1,t1}, {f_id2,r_id1,t2}, {f_id3,r_id2,t3} ] |
62 // ====> | 62 // ====> |
63 // [ {r_id1,<{f_id1,t1},{f_id2,t2}>}, {r_id2,<{f_id3,t3}>} ] | 63 // [ {r_id1,<{f_id1,t1},{f_id2,t2}>}, {r_id2,<{f_id3,t3}>} ] |
64 scoped_ptr<CompositeTimingSet> GroupCompositeCountsByRectId(); | 64 std::unique_ptr<CompositeTimingSet> GroupCompositeCountsByRectId(); |
65 | 65 |
66 // This routine takes all of the individual MainFrameEvents stored in the | 66 // This routine takes all of the individual MainFrameEvents stored in the |
67 // tracker and collects them by "rect_id", as in the example below. | 67 // tracker and collects them by "rect_id", as in the example below. |
68 scoped_ptr<MainFrameTimingSet> GroupMainFrameCountsByRectId(); | 68 std::unique_ptr<MainFrameTimingSet> GroupMainFrameCountsByRectId(); |
69 | 69 |
70 // This routine takes a timestamp and an array of frame_id,rect_id pairs | 70 // This routine takes a timestamp and an array of frame_id,rect_id pairs |
71 // and generates CompositeTimingEvents (frame_id, timestamp) and adds them to | 71 // and generates CompositeTimingEvents (frame_id, timestamp) and adds them to |
72 // internal hash_map keyed on rect_id | 72 // internal hash_map keyed on rect_id |
73 using FrameAndRectIds = std::pair<int, int64_t>; | 73 using FrameAndRectIds = std::pair<int, int64_t>; |
74 void SaveTimeStamps(base::TimeTicks timestamp, | 74 void SaveTimeStamps(base::TimeTicks timestamp, |
75 const std::vector<FrameAndRectIds>& frame_ids); | 75 const std::vector<FrameAndRectIds>& frame_ids); |
76 | 76 |
77 void SaveMainFrameTimeStamps(const std::vector<int64_t>& request_ids, | 77 void SaveMainFrameTimeStamps(const std::vector<int64_t>& request_ids, |
78 base::TimeTicks main_frame_time, | 78 base::TimeTicks main_frame_time, |
79 base::TimeTicks end_time, | 79 base::TimeTicks end_time, |
80 int source_frame_number); | 80 int source_frame_number); |
81 | 81 |
82 private: | 82 private: |
83 explicit FrameTimingTracker(LayerTreeHostImpl* layer_tree_host_impl); | 83 explicit FrameTimingTracker(LayerTreeHostImpl* layer_tree_host_impl); |
84 | 84 |
85 void PostEvents(); | 85 void PostEvents(); |
86 | 86 |
87 scoped_ptr<CompositeTimingSet> composite_events_; | 87 std::unique_ptr<CompositeTimingSet> composite_events_; |
88 scoped_ptr<MainFrameTimingSet> main_frame_events_; | 88 std::unique_ptr<MainFrameTimingSet> main_frame_events_; |
89 | 89 |
90 LayerTreeHostImpl* layer_tree_host_impl_; | 90 LayerTreeHostImpl* layer_tree_host_impl_; |
91 DelayedUniqueNotifier post_events_notifier_; | 91 DelayedUniqueNotifier post_events_notifier_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(FrameTimingTracker); | 93 DISALLOW_COPY_AND_ASSIGN(FrameTimingTracker); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace cc | 96 } // namespace cc |
97 | 97 |
98 #endif // CC_DEBUG_FRAME_TIMING_TRACKER_H_ | 98 #endif // CC_DEBUG_FRAME_TIMING_TRACKER_H_ |
OLD | NEW |