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

Side by Side Diff: cc/debug/rendering_stats.cc

Issue 380763002: Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed memory leak found by Linux ASAN Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/debug/rendering_stats.h ('k') | cc/debug/rendering_stats_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 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 #include "cc/debug/rendering_stats.h" 5 #include "cc/debug/rendering_stats.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 RenderingStats::TimeDeltaList::TimeDeltaList() { 9 RenderingStats::TimeDeltaList::TimeDeltaList() {
10 } 10 }
11 11
12 RenderingStats::TimeDeltaList::~TimeDeltaList() { 12 RenderingStats::TimeDeltaList::~TimeDeltaList() {
13 } 13 }
14 14
15 void RenderingStats::TimeDeltaList::Append(base::TimeDelta value) { 15 void RenderingStats::TimeDeltaList::Append(base::TimeDelta value) {
16 values.push_back(value); 16 values.push_back(value);
17 } 17 }
18 18
19 scoped_ptr<base::ListValue> 19 void RenderingStats::TimeDeltaList::AddToTracedValue(
20 RenderingStats::TimeDeltaList::AsListValueInMilliseconds() const { 20 base::debug::TracedValue* list_value) const {
21 scoped_ptr<base::ListValue> list_value(new base::ListValue);
22 std::list<base::TimeDelta>::const_iterator iter; 21 std::list<base::TimeDelta>::const_iterator iter;
23 for (iter = values.begin(); iter != values.end(); ++iter) { 22 for (iter = values.begin(); iter != values.end(); ++iter) {
24 list_value->AppendDouble(iter->InMillisecondsF()); 23 list_value->AppendDouble(iter->InMillisecondsF());
25 } 24 }
26 return list_value.Pass();
27 } 25 }
28 26
29 void RenderingStats::TimeDeltaList::Add(const TimeDeltaList& other) { 27 void RenderingStats::TimeDeltaList::Add(const TimeDeltaList& other) {
30 values.insert(values.end(), other.values.begin(), other.values.end()); 28 values.insert(values.end(), other.values.begin(), other.values.end());
31 } 29 }
32 30
33 RenderingStats::MainThreadRenderingStats::MainThreadRenderingStats() 31 RenderingStats::MainThreadRenderingStats::MainThreadRenderingStats()
34 : frame_count(0), painted_pixel_count(0), recorded_pixel_count(0) { 32 : frame_count(0), painted_pixel_count(0), recorded_pixel_count(0) {
35 } 33 }
36 34
37 RenderingStats::MainThreadRenderingStats::~MainThreadRenderingStats() { 35 RenderingStats::MainThreadRenderingStats::~MainThreadRenderingStats() {
38 } 36 }
39 37
40 scoped_refptr<base::debug::ConvertableToTraceFormat> 38 scoped_refptr<base::debug::ConvertableToTraceFormat>
41 RenderingStats::MainThreadRenderingStats::AsTraceableData() const { 39 RenderingStats::MainThreadRenderingStats::AsTraceableData() const {
42 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); 40 scoped_refptr<base::debug::TracedValue> record_data =
41 new base::debug::TracedValue();
43 record_data->SetInteger("frame_count", frame_count); 42 record_data->SetInteger("frame_count", frame_count);
44 record_data->SetDouble("paint_time", paint_time.InSecondsF()); 43 record_data->SetDouble("paint_time", paint_time.InSecondsF());
45 record_data->SetInteger("painted_pixel_count", painted_pixel_count); 44 record_data->SetInteger("painted_pixel_count", painted_pixel_count);
46 record_data->SetDouble("record_time", record_time.InSecondsF()); 45 record_data->SetDouble("record_time", record_time.InSecondsF());
47 record_data->SetInteger("recorded_pixel_count", recorded_pixel_count); 46 record_data->SetInteger("recorded_pixel_count", recorded_pixel_count);
48 return TracedValue::FromValue(record_data.release()); 47 return record_data;
49 } 48 }
50 49
51 void RenderingStats::MainThreadRenderingStats::Add( 50 void RenderingStats::MainThreadRenderingStats::Add(
52 const MainThreadRenderingStats& other) { 51 const MainThreadRenderingStats& other) {
53 frame_count += other.frame_count; 52 frame_count += other.frame_count;
54 paint_time += other.paint_time; 53 paint_time += other.paint_time;
55 painted_pixel_count += other.painted_pixel_count; 54 painted_pixel_count += other.painted_pixel_count;
56 record_time += other.record_time; 55 record_time += other.record_time;
57 recorded_pixel_count += other.recorded_pixel_count; 56 recorded_pixel_count += other.recorded_pixel_count;
58 } 57 }
59 58
60 RenderingStats::ImplThreadRenderingStats::ImplThreadRenderingStats() 59 RenderingStats::ImplThreadRenderingStats::ImplThreadRenderingStats()
61 : frame_count(0), 60 : frame_count(0),
62 rasterized_pixel_count(0), 61 rasterized_pixel_count(0),
63 visible_content_area(0), 62 visible_content_area(0),
64 approximated_visible_content_area(0) { 63 approximated_visible_content_area(0) {
65 } 64 }
66 65
67 RenderingStats::ImplThreadRenderingStats::~ImplThreadRenderingStats() { 66 RenderingStats::ImplThreadRenderingStats::~ImplThreadRenderingStats() {
68 } 67 }
69 68
70 scoped_refptr<base::debug::ConvertableToTraceFormat> 69 scoped_refptr<base::debug::ConvertableToTraceFormat>
71 RenderingStats::ImplThreadRenderingStats::AsTraceableData() const { 70 RenderingStats::ImplThreadRenderingStats::AsTraceableData() const {
72 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); 71 scoped_refptr<base::debug::TracedValue> record_data =
72 new base::debug::TracedValue();
73 record_data->SetInteger("frame_count", frame_count); 73 record_data->SetInteger("frame_count", frame_count);
74 record_data->SetDouble("rasterize_time", rasterize_time.InSecondsF()); 74 record_data->SetDouble("rasterize_time", rasterize_time.InSecondsF());
75 record_data->SetInteger("rasterized_pixel_count", rasterized_pixel_count); 75 record_data->SetInteger("rasterized_pixel_count", rasterized_pixel_count);
76 record_data->SetInteger("visible_content_area", visible_content_area); 76 record_data->SetInteger("visible_content_area", visible_content_area);
77 record_data->SetInteger("approximated_visible_content_area", 77 record_data->SetInteger("approximated_visible_content_area",
78 approximated_visible_content_area); 78 approximated_visible_content_area);
79 record_data->Set("draw_duration_ms", 79 record_data->BeginArray("draw_duration_ms");
80 draw_duration.AsListValueInMilliseconds().release()); 80 draw_duration.AddToTracedValue(record_data.get());
81 record_data->Set( 81 record_data->EndArray();
82 "draw_duration_estimate_ms", 82
83 draw_duration_estimate.AsListValueInMilliseconds().release()); 83 record_data->BeginArray("draw_duration_estimate_ms");
84 record_data->Set( 84 draw_duration_estimate.AddToTracedValue(record_data.get());
85 "begin_main_frame_to_commit_duration_ms", 85 record_data->EndArray();
86 begin_main_frame_to_commit_duration.AsListValueInMilliseconds() 86
87 .release()); 87 record_data->BeginArray("begin_main_frame_to_commit_duration_ms");
88 record_data->Set( 88 begin_main_frame_to_commit_duration.AddToTracedValue(record_data.get());
89 "begin_main_frame_to_commit_duration_estimate_ms", 89 record_data->EndArray();
90 begin_main_frame_to_commit_duration_estimate.AsListValueInMilliseconds() 90
91 .release()); 91 record_data->BeginArray("begin_main_frame_to_commit_duration_estimate_ms");
92 record_data->Set( 92 begin_main_frame_to_commit_duration_estimate.AddToTracedValue(
93 "commit_to_activate_duration_ms", 93 record_data.get());
94 commit_to_activate_duration.AsListValueInMilliseconds().release()); 94 record_data->EndArray();
95 record_data->Set( 95
96 "commit_to_activate_duration_estimate_ms", 96 record_data->BeginArray("commit_to_activate_duration_ms");
97 commit_to_activate_duration_estimate.AsListValueInMilliseconds() 97 commit_to_activate_duration.AddToTracedValue(record_data.get());
98 .release()); 98 record_data->EndArray();
99 return TracedValue::FromValue(record_data.release()); 99
100 record_data->BeginArray("commit_to_activate_duration_estimate_ms");
101 commit_to_activate_duration_estimate.AddToTracedValue(record_data.get());
102 record_data->EndArray();
103 return record_data;
100 } 104 }
101 105
102 void RenderingStats::ImplThreadRenderingStats::Add( 106 void RenderingStats::ImplThreadRenderingStats::Add(
103 const ImplThreadRenderingStats& other) { 107 const ImplThreadRenderingStats& other) {
104 frame_count += other.frame_count; 108 frame_count += other.frame_count;
105 rasterize_time += other.rasterize_time; 109 rasterize_time += other.rasterize_time;
106 analysis_time += other.analysis_time; 110 analysis_time += other.analysis_time;
107 rasterized_pixel_count += other.rasterized_pixel_count; 111 rasterized_pixel_count += other.rasterized_pixel_count;
108 visible_content_area += other.visible_content_area; 112 visible_content_area += other.visible_content_area;
109 approximated_visible_content_area += other.approximated_visible_content_area; 113 approximated_visible_content_area += other.approximated_visible_content_area;
110 114
111 draw_duration.Add(other.draw_duration); 115 draw_duration.Add(other.draw_duration);
112 draw_duration_estimate.Add(other.draw_duration_estimate); 116 draw_duration_estimate.Add(other.draw_duration_estimate);
113 begin_main_frame_to_commit_duration.Add( 117 begin_main_frame_to_commit_duration.Add(
114 other.begin_main_frame_to_commit_duration); 118 other.begin_main_frame_to_commit_duration);
115 begin_main_frame_to_commit_duration_estimate.Add( 119 begin_main_frame_to_commit_duration_estimate.Add(
116 other.begin_main_frame_to_commit_duration_estimate); 120 other.begin_main_frame_to_commit_duration_estimate);
117 commit_to_activate_duration.Add(other.commit_to_activate_duration); 121 commit_to_activate_duration.Add(other.commit_to_activate_duration);
118 commit_to_activate_duration_estimate.Add( 122 commit_to_activate_duration_estimate.Add(
119 other.commit_to_activate_duration_estimate); 123 other.commit_to_activate_duration_estimate);
120 } 124 }
121 125
122 void RenderingStats::Add(const RenderingStats& other) { 126 void RenderingStats::Add(const RenderingStats& other) {
123 main_stats.Add(other.main_stats); 127 main_stats.Add(other.main_stats);
124 impl_stats.Add(other.impl_stats); 128 impl_stats.Add(other.impl_stats);
125 } 129 }
126 130
127 } // namespace cc 131 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/rendering_stats.h ('k') | cc/debug/rendering_stats_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698