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

Side by Side Diff: ui/events/latency_info.cc

Issue 569653002: Add input coordinate information to InputLatency (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use uint32 instead of size_t to unbreak IPC. Created 6 years, 3 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
« no previous file with comments | « ui/events/latency_info.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/debug/trace_event.h" 5 #include "base/debug/trace_event.h"
6 #include "base/json/json_writer.h" 6 #include "base/json/json_writer.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "ui/events/latency_info.h" 9 #include "ui/events/latency_info.h"
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 for (ui::LatencyInfo::LatencyMap::const_iterator it = 110 for (ui::LatencyInfo::LatencyMap::const_iterator it =
111 latency.latency_components.begin(); 111 latency.latency_components.begin();
112 it != latency.latency_components.end(); ++it) { 112 it != latency.latency_components.end(); ++it) {
113 base::DictionaryValue* component_info = new base::DictionaryValue(); 113 base::DictionaryValue* component_info = new base::DictionaryValue();
114 component_info->SetDouble("comp_id", it->first.second); 114 component_info->SetDouble("comp_id", it->first.second);
115 component_info->SetDouble("time", it->second.event_time.ToInternalValue()); 115 component_info->SetDouble("time", it->second.event_time.ToInternalValue());
116 component_info->SetDouble("count", it->second.event_count); 116 component_info->SetDouble("count", it->second.event_count);
117 record_data->Set(GetComponentName(it->first.first), component_info); 117 record_data->Set(GetComponentName(it->first.first), component_info);
118 } 118 }
119 record_data->SetDouble("trace_id", latency.trace_id); 119 record_data->SetDouble("trace_id", latency.trace_id);
120
121 scoped_ptr<base::ListValue> coordinates(new base::ListValue());
122 for (size_t i = 0; i < latency.input_coordinates_size; i++) {
123 scoped_ptr<base::DictionaryValue> coordinate_pair(
124 new base::DictionaryValue());
125 coordinate_pair->SetDouble("x", latency.input_coordinates[i].x);
126 coordinate_pair->SetDouble("y", latency.input_coordinates[i].y);
127 coordinates->Append(coordinate_pair.release());
128 }
129 record_data->Set("coordinates", coordinates.release());
120 return LatencyInfoTracedValue::FromValue(record_data.PassAs<base::Value>()); 130 return LatencyInfoTracedValue::FromValue(record_data.PassAs<base::Value>());
121 } 131 }
122 132
123 } // namespace 133 } // namespace
124 134
125 namespace ui { 135 namespace ui {
126 136
127 LatencyInfo::LatencyInfo() : trace_id(-1), terminated(false) { 137 LatencyInfo::InputCoordinate::InputCoordinate() : x(0), y(0) {
138 }
139
140 LatencyInfo::InputCoordinate::InputCoordinate(float x, float y) : x(x), y(y) {
141 }
142
143 LatencyInfo::LatencyInfo()
144 : input_coordinates_size(0), trace_id(-1), terminated(false) {
128 } 145 }
129 146
130 LatencyInfo::~LatencyInfo() { 147 LatencyInfo::~LatencyInfo() {
131 } 148 }
132 149
133 bool LatencyInfo::Verify(const std::vector<LatencyInfo>& latency_info, 150 bool LatencyInfo::Verify(const std::vector<LatencyInfo>& latency_info,
134 const char* referring_msg) { 151 const char* referring_msg) {
135 if (latency_info.size() > kMaxLatencyInfoNumber) { 152 if (latency_info.size() > kMaxLatencyInfoNumber) {
136 LOG(ERROR) << referring_msg << ", LatencyInfo vector size " 153 LOG(ERROR) << referring_msg << ", LatencyInfo vector size "
137 << latency_info.size() << " is too big."; 154 << latency_info.size() << " is too big.";
138 return false; 155 return false;
139 } 156 }
157 for (size_t i = 0; i < latency_info.size(); i++) {
158 if (latency_info[i].input_coordinates_size > kMaxInputCoordinates) {
159 LOG(ERROR) << referring_msg << ", coordinate vector size "
160 << latency_info[i].input_coordinates_size << " is too big.";
161 return false;
162 }
163 }
164
140 return true; 165 return true;
141 } 166 }
142 167
143 void LatencyInfo::CopyLatencyFrom(const LatencyInfo& other, 168 void LatencyInfo::CopyLatencyFrom(const LatencyInfo& other,
144 LatencyComponentType type) { 169 LatencyComponentType type) {
145 for (LatencyMap::const_iterator it = other.latency_components.begin(); 170 for (LatencyMap::const_iterator it = other.latency_components.begin();
146 it != other.latency_components.end(); 171 it != other.latency_components.end();
147 ++it) { 172 ++it) {
148 if (it->first.first == type) { 173 if (it->first.first == type) {
149 AddLatencyNumberWithTimestamp(it->first.first, 174 AddLatencyNumberWithTimestamp(it->first.first,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 318 }
294 319
295 void LatencyInfo::TraceEventType(const char* event_type) { 320 void LatencyInfo::TraceEventType(const char* event_type) {
296 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", 321 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark",
297 "InputLatency", 322 "InputLatency",
298 TRACE_ID_DONT_MANGLE(trace_id), 323 TRACE_ID_DONT_MANGLE(trace_id),
299 event_type); 324 event_type);
300 } 325 }
301 326
302 } // namespace ui 327 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/latency_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698