Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: cc/debug/frame_timing_tracker.h

Issue 1152153003: [WIP] cc: Plumb frame timing info without using a commit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "cc/base/cc_export.h" 15 #include "cc/base/cc_export.h"
16 #include "cc/base/delayed_unique_notifier.h"
16 17
17 namespace cc { 18 namespace cc {
18 19
20 class LayerTreeHostImpl;
21
19 // This class maintains a history of timestamps and rect IDs to communicate 22 // This class maintains a history of timestamps and rect IDs to communicate
20 // frame events back to Blink 23 // frame events back to Blink
21 // TODO(mpb): Start using this. crbug.com/442554 24 // TODO(mpb): Start using this. crbug.com/442554
22 class CC_EXPORT FrameTimingTracker { 25 class CC_EXPORT FrameTimingTracker {
23 public: 26 public:
24 struct CC_EXPORT CompositeTimingEvent { 27 struct CC_EXPORT CompositeTimingEvent {
25 CompositeTimingEvent(int, base::TimeTicks); 28 CompositeTimingEvent(int, base::TimeTicks);
26 ~CompositeTimingEvent(); 29 ~CompositeTimingEvent();
27 30
28 int frame_id; 31 int frame_id;
29 base::TimeTicks timestamp; 32 base::TimeTicks timestamp;
30 }; 33 };
31 34
32 using CompositeTimingSet = 35 using CompositeTimingSet =
33 base::hash_map<int, std::vector<CompositeTimingEvent>>; 36 base::hash_map<int, std::vector<CompositeTimingEvent>>;
MikeB 2015/05/27 21:07:38 This should be int64_t.
34 37
35 struct CC_EXPORT MainFrameTimingEvent { 38 struct CC_EXPORT MainFrameTimingEvent {
36 MainFrameTimingEvent(int frame_id, 39 MainFrameTimingEvent(int frame_id,
37 base::TimeTicks timestamp, 40 base::TimeTicks timestamp,
38 base::TimeTicks end_time); 41 base::TimeTicks end_time);
39 ~MainFrameTimingEvent(); 42 ~MainFrameTimingEvent();
40 43
41 int frame_id; 44 int frame_id;
42 base::TimeTicks timestamp; 45 base::TimeTicks timestamp;
43 base::TimeTicks end_time; 46 base::TimeTicks end_time;
44 }; 47 };
45 48
46 using MainFrameTimingSet = 49 using MainFrameTimingSet =
47 base::hash_map<int, std::vector<MainFrameTimingEvent>>; 50 base::hash_map<int, std::vector<MainFrameTimingEvent>>;
MikeB 2015/05/27 21:07:38 int64_t as well.
48 51
49 static scoped_ptr<FrameTimingTracker> Create(); 52 static scoped_ptr<FrameTimingTracker> Create(
53 LayerTreeHostImpl* layer_tree_host_impl);
50 54
51 ~FrameTimingTracker(); 55 ~FrameTimingTracker();
52 56
53 // This routine takes all of the individual CompositeEvents stored in the 57 // This routine takes all of the individual CompositeEvents stored in the
54 // tracker and collects them by "rect_id", as in the example below. 58 // tracker and collects them by "rect_id", as in the example below.
55 // [ {f_id1,r_id1,t1}, {f_id2,r_id1,t2}, {f_id3,r_id2,t3} ] 59 // [ {f_id1,r_id1,t1}, {f_id2,r_id1,t2}, {f_id3,r_id2,t3} ]
56 // ====> 60 // ====>
57 // [ {r_id1,<{f_id1,t1},{f_id2,t2}>}, {r_id2,<{f_id3,t3}>} ] 61 // [ {r_id1,<{f_id1,t1},{f_id2,t2}>}, {r_id2,<{f_id3,t3}>} ]
58 scoped_ptr<CompositeTimingSet> GroupCompositeCountsByRectId(); 62 scoped_ptr<CompositeTimingSet> GroupCompositeCountsByRectId();
59 63
60 // This routine takes all of the individual MainFrameEvents stored in the 64 // This routine takes all of the individual MainFrameEvents stored in the
61 // tracker and collects them by "rect_id", as in the example below. 65 // tracker and collects them by "rect_id", as in the example below.
62 scoped_ptr<MainFrameTimingSet> GroupMainFrameCountsByRectId(); 66 scoped_ptr<MainFrameTimingSet> GroupMainFrameCountsByRectId();
63 67
64 // This routine takes a timestamp and an array of frame_id,rect_id pairs 68 // This routine takes a timestamp and an array of frame_id,rect_id pairs
65 // and generates CompositeTimingEvents (frame_id, timestamp) and adds them to 69 // and generates CompositeTimingEvents (frame_id, timestamp) and adds them to
66 // internal hash_map keyed on rect_id 70 // internal hash_map keyed on rect_id
67 using FrameAndRectIds = std::pair<int, int64_t>; 71 using FrameAndRectIds = std::pair<int, int64_t>;
68 void SaveTimeStamps(base::TimeTicks timestamp, 72 void SaveTimeStamps(base::TimeTicks timestamp,
69 const std::vector<FrameAndRectIds>& frame_ids); 73 const std::vector<FrameAndRectIds>& frame_ids);
70 74
71 void SaveMainFrameTimeStamps(const std::vector<int64_t>& request_ids, 75 void SaveMainFrameTimeStamps(const std::vector<int64_t>& request_ids,
72 base::TimeTicks main_frame_time, 76 base::TimeTicks main_frame_time,
73 base::TimeTicks end_time, 77 base::TimeTicks end_time,
74 int source_frame_number); 78 int source_frame_number);
75 79
76 private: 80 private:
77 FrameTimingTracker(); 81 explicit FrameTimingTracker(LayerTreeHostImpl* layer_tree_host_impl);
82
83 void PostEvents();
78 84
79 scoped_ptr<CompositeTimingSet> composite_events_; 85 scoped_ptr<CompositeTimingSet> composite_events_;
80 scoped_ptr<MainFrameTimingSet> main_frame_events_; 86 scoped_ptr<MainFrameTimingSet> main_frame_events_;
81 87
88 LayerTreeHostImpl* layer_tree_host_impl_;
89 DelayedUniqueNotifier post_events_notifier_;
90
82 DISALLOW_COPY_AND_ASSIGN(FrameTimingTracker); 91 DISALLOW_COPY_AND_ASSIGN(FrameTimingTracker);
83 }; 92 };
84 93
85 } // namespace cc 94 } // namespace cc
86 95
87 #endif // CC_DEBUG_FRAME_TIMING_TRACKER_H_ 96 #endif // CC_DEBUG_FRAME_TIMING_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/debug/frame_timing_tracker.cc » ('j') | content/renderer/gpu/render_widget_compositor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698