| OLD | NEW |
| 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 "ui/latency_info/latency_info.h" | 5 #include "ui/events/latency_info.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const size_t kMaxLatencyInfoNumber = 100; | 20 const size_t kMaxLatencyInfoNumber = 100; |
| 21 | 21 |
| 22 const char* GetComponentName(ui::LatencyComponentType type) { | 22 const char* GetComponentName(ui::LatencyComponentType type) { |
| 23 #define CASE_TYPE(t) \ | 23 #define CASE_TYPE(t) case ui::t: return #t |
| 24 case ui::t: \ | |
| 25 return #t | |
| 26 switch (type) { | 24 switch (type) { |
| 27 CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT); | 25 CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT); |
| 28 CASE_TYPE(LATENCY_BEGIN_SCROLL_LISTENER_UPDATE_MAIN_COMPONENT); | 26 CASE_TYPE(LATENCY_BEGIN_SCROLL_LISTENER_UPDATE_MAIN_COMPONENT); |
| 29 CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT); | 27 CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT); |
| 30 CASE_TYPE(INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT); | 28 CASE_TYPE(INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT); |
| 31 CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); | 29 CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); |
| 32 CASE_TYPE(INPUT_EVENT_LATENCY_UI_COMPONENT); | 30 CASE_TYPE(INPUT_EVENT_LATENCY_UI_COMPONENT); |
| 33 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT); | 31 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT); |
| 34 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT); | 32 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT); |
| 35 CASE_TYPE(INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); | 33 CASE_TYPE(INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 97 |
| 100 DISALLOW_COPY_AND_ASSIGN(LatencyInfoTracedValue); | 98 DISALLOW_COPY_AND_ASSIGN(LatencyInfoTracedValue); |
| 101 }; | 99 }; |
| 102 | 100 |
| 103 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 101 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 104 LatencyInfoTracedValue::FromValue(std::unique_ptr<base::Value> value) { | 102 LatencyInfoTracedValue::FromValue(std::unique_ptr<base::Value> value) { |
| 105 return std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( | 103 return std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( |
| 106 new LatencyInfoTracedValue(value.release())); | 104 new LatencyInfoTracedValue(value.release())); |
| 107 } | 105 } |
| 108 | 106 |
| 109 LatencyInfoTracedValue::~LatencyInfoTracedValue() {} | 107 LatencyInfoTracedValue::~LatencyInfoTracedValue() { |
| 108 } |
| 110 | 109 |
| 111 void LatencyInfoTracedValue::AppendAsTraceFormat(std::string* out) const { | 110 void LatencyInfoTracedValue::AppendAsTraceFormat(std::string* out) const { |
| 112 std::string tmp; | 111 std::string tmp; |
| 113 base::JSONWriter::Write(*value_, &tmp); | 112 base::JSONWriter::Write(*value_, &tmp); |
| 114 *out += tmp; | 113 *out += tmp; |
| 115 } | 114 } |
| 116 | 115 |
| 117 LatencyInfoTracedValue::LatencyInfoTracedValue(base::Value* value) | 116 LatencyInfoTracedValue::LatencyInfoTracedValue(base::Value* value) |
| 118 : value_(value) {} | 117 : value_(value) { |
| 118 } |
| 119 | 119 |
| 120 const char kTraceCategoriesForAsyncEvents[] = "benchmark,latencyInfo"; | 120 const char kTraceCategoriesForAsyncEvents[] = "benchmark,latencyInfo"; |
| 121 | 121 |
| 122 struct LatencyInfoEnabledInitializer { | 122 struct LatencyInfoEnabledInitializer { |
| 123 LatencyInfoEnabledInitializer() | 123 LatencyInfoEnabledInitializer() : |
| 124 : latency_info_enabled(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | 124 latency_info_enabled(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( |
| 125 kTraceCategoriesForAsyncEvents)) {} | 125 kTraceCategoriesForAsyncEvents)) { |
| 126 } |
| 126 | 127 |
| 127 const unsigned char* latency_info_enabled; | 128 const unsigned char* latency_info_enabled; |
| 128 }; | 129 }; |
| 129 | 130 |
| 130 static base::LazyInstance<LatencyInfoEnabledInitializer>::Leaky | 131 static base::LazyInstance<LatencyInfoEnabledInitializer>::Leaky |
| 131 g_latency_info_enabled = LAZY_INSTANCE_INITIALIZER; | 132 g_latency_info_enabled = LAZY_INSTANCE_INITIALIZER; |
| 132 | 133 |
| 133 } // namespace | 134 } // namespace |
| 134 | 135 |
| 135 namespace ui { | 136 namespace ui { |
| 136 | 137 |
| 137 LatencyInfo::InputCoordinate::InputCoordinate() : x(0), y(0) {} | 138 LatencyInfo::InputCoordinate::InputCoordinate() : x(0), y(0) { |
| 139 } |
| 138 | 140 |
| 139 LatencyInfo::InputCoordinate::InputCoordinate(float x, float y) : x(x), y(y) {} | 141 LatencyInfo::InputCoordinate::InputCoordinate(float x, float y) : x(x), y(y) { |
| 142 } |
| 140 | 143 |
| 141 LatencyInfo::LatencyInfo() | 144 LatencyInfo::LatencyInfo() |
| 142 : input_coordinates_size_(0), | 145 : input_coordinates_size_(0), |
| 143 trace_id_(-1), | 146 trace_id_(-1), |
| 144 coalesced_(false), | 147 coalesced_(false), |
| 145 terminated_(false) {} | 148 terminated_(false) {} |
| 146 | 149 |
| 147 LatencyInfo::LatencyInfo(const LatencyInfo& other) = default; | 150 LatencyInfo::LatencyInfo(const LatencyInfo& other) = default; |
| 148 | 151 |
| 149 LatencyInfo::~LatencyInfo() {} | 152 LatencyInfo::~LatencyInfo() {} |
| 150 | 153 |
| 151 LatencyInfo::LatencyInfo(int64_t trace_id, bool terminated) | 154 LatencyInfo::LatencyInfo(int64_t trace_id, bool terminated) |
| 152 : input_coordinates_size_(0), | 155 : input_coordinates_size_(0), |
| 153 trace_id_(trace_id), | 156 trace_id_(trace_id), |
| 154 terminated_(terminated) {} | 157 terminated_(terminated) {} |
| 155 | 158 |
| 156 bool LatencyInfo::Verify(const std::vector<LatencyInfo>& latency_info, | 159 bool LatencyInfo::Verify(const std::vector<LatencyInfo>& latency_info, |
| 157 const char* referring_msg) { | 160 const char* referring_msg) { |
| 158 if (latency_info.size() > kMaxLatencyInfoNumber) { | 161 if (latency_info.size() > kMaxLatencyInfoNumber) { |
| 159 LOG(ERROR) << referring_msg << ", LatencyInfo vector size " | 162 LOG(ERROR) << referring_msg << ", LatencyInfo vector size " |
| 160 << latency_info.size() << " is too big."; | 163 << latency_info.size() << " is too big."; |
| 161 TRACE_EVENT_INSTANT1("input,benchmark", "LatencyInfo::Verify Fails", | 164 TRACE_EVENT_INSTANT1("input,benchmark", "LatencyInfo::Verify Fails", |
| 162 TRACE_EVENT_SCOPE_GLOBAL, "size", latency_info.size()); | 165 TRACE_EVENT_SCOPE_GLOBAL, |
| 166 "size", latency_info.size()); |
| 163 return false; | 167 return false; |
| 164 } | 168 } |
| 165 return true; | 169 return true; |
| 166 } | 170 } |
| 167 | 171 |
| 168 void LatencyInfo::CopyLatencyFrom(const LatencyInfo& other, | 172 void LatencyInfo::CopyLatencyFrom(const LatencyInfo& other, |
| 169 LatencyComponentType type) { | 173 LatencyComponentType type) { |
| 170 for (const auto& lc : other.latency_components()) { | 174 for (const auto& lc : other.latency_components()) { |
| 171 if (lc.first.first == type) { | 175 if (lc.first.first == type) { |
| 172 AddLatencyNumberWithTimestamp( | 176 AddLatencyNumberWithTimestamp(lc.first.first, |
| 173 lc.first.first, lc.first.second, lc.second.sequence_number, | 177 lc.first.second, |
| 174 lc.second.event_time, lc.second.event_count); | 178 lc.second.sequence_number, |
| 179 lc.second.event_time, |
| 180 lc.second.event_count); |
| 175 } | 181 } |
| 176 } | 182 } |
| 177 } | 183 } |
| 178 | 184 |
| 179 void LatencyInfo::AddNewLatencyFrom(const LatencyInfo& other) { | 185 void LatencyInfo::AddNewLatencyFrom(const LatencyInfo& other) { |
| 180 for (const auto& lc : other.latency_components()) { | 186 for (const auto& lc : other.latency_components()) { |
| 181 if (!FindLatency(lc.first.first, lc.first.second, NULL)) { | 187 if (!FindLatency(lc.first.first, lc.first.second, NULL)) { |
| 182 AddLatencyNumberWithTimestamp( | 188 AddLatencyNumberWithTimestamp(lc.first.first, |
| 183 lc.first.first, lc.first.second, lc.second.sequence_number, | 189 lc.first.second, |
| 184 lc.second.event_time, lc.second.event_count); | 190 lc.second.sequence_number, |
| 191 lc.second.event_time, |
| 192 lc.second.event_count); |
| 185 } | 193 } |
| 186 } | 194 } |
| 187 } | 195 } |
| 188 | 196 |
| 189 void LatencyInfo::AddLatencyNumber(LatencyComponentType component, | 197 void LatencyInfo::AddLatencyNumber(LatencyComponentType component, |
| 190 int64_t id, | 198 int64_t id, |
| 191 int64_t component_sequence_number) { | 199 int64_t component_sequence_number) { |
| 192 AddLatencyNumberWithTimestampImpl(component, id, component_sequence_number, | 200 AddLatencyNumberWithTimestampImpl(component, id, component_sequence_number, |
| 193 base::TimeTicks::Now(), 1, nullptr); | 201 base::TimeTicks::Now(), 1, nullptr); |
| 194 } | 202 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 trace_id_ = component_sequence_number; | 236 trace_id_ = component_sequence_number; |
| 229 | 237 |
| 230 if (*latency_info_enabled) { | 238 if (*latency_info_enabled) { |
| 231 // The timestamp for ASYNC_BEGIN trace event is used for drawing the | 239 // The timestamp for ASYNC_BEGIN trace event is used for drawing the |
| 232 // beginning of the trace event in trace viewer. For better visualization, | 240 // beginning of the trace event in trace viewer. For better visualization, |
| 233 // for an input event, we want to draw the beginning as when the event is | 241 // for an input event, we want to draw the beginning as when the event is |
| 234 // originally created, e.g. the timestamp of its ORIGINAL/UI_COMPONENT, | 242 // originally created, e.g. the timestamp of its ORIGINAL/UI_COMPONENT, |
| 235 // not when we actually issue the ASYNC_BEGIN trace event. | 243 // not when we actually issue the ASYNC_BEGIN trace event. |
| 236 LatencyComponent begin_component; | 244 LatencyComponent begin_component; |
| 237 int64_t ts = 0; | 245 int64_t ts = 0; |
| 238 if (FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, | 246 if (FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
| 247 0, |
| 239 &begin_component) || | 248 &begin_component) || |
| 240 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &begin_component)) { | 249 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, |
| 250 0, |
| 251 &begin_component)) { |
| 241 ts = begin_component.event_time.ToInternalValue(); | 252 ts = begin_component.event_time.ToInternalValue(); |
| 242 } else { | 253 } else { |
| 243 ts = base::TimeTicks::Now().ToInternalValue(); | 254 ts = base::TimeTicks::Now().ToInternalValue(); |
| 244 } | 255 } |
| 245 | 256 |
| 246 if (trace_name_str) { | 257 if (trace_name_str) { |
| 247 if (IsInputLatencyBeginComponent(component)) | 258 if (IsInputLatencyBeginComponent(component)) |
| 248 trace_name_ = std::string("InputLatency::") + trace_name_str; | 259 trace_name_ = std::string("InputLatency::") + trace_name_str; |
| 249 else | 260 else |
| 250 trace_name_ = std::string("Latency::") + trace_name_str; | 261 trace_name_ = std::string("Latency::") + trace_name_str; |
| 251 } | 262 } |
| 252 | 263 |
| 253 TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0( | 264 TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0( |
| 254 kTraceCategoriesForAsyncEvents, trace_name_.c_str(), | 265 kTraceCategoriesForAsyncEvents, |
| 255 TRACE_ID_DONT_MANGLE(trace_id_), ts); | 266 trace_name_.c_str(), |
| 267 TRACE_ID_DONT_MANGLE(trace_id_), |
| 268 ts); |
| 256 } | 269 } |
| 257 | 270 |
| 258 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", | 271 TRACE_EVENT_WITH_FLOW1("input,benchmark", |
| 272 "LatencyInfo.Flow", |
| 259 TRACE_ID_DONT_MANGLE(trace_id_), | 273 TRACE_ID_DONT_MANGLE(trace_id_), |
| 260 TRACE_EVENT_FLAG_FLOW_OUT, "trace_id", trace_id_); | 274 TRACE_EVENT_FLAG_FLOW_OUT, |
| 275 "trace_id", trace_id_); |
| 261 } | 276 } |
| 262 | 277 |
| 263 LatencyMap::key_type key = std::make_pair(component, id); | 278 LatencyMap::key_type key = std::make_pair(component, id); |
| 264 LatencyMap::iterator it = latency_components_.find(key); | 279 LatencyMap::iterator it = latency_components_.find(key); |
| 265 if (it == latency_components_.end()) { | 280 if (it == latency_components_.end()) { |
| 266 LatencyComponent info = {component_sequence_number, time, event_count}; | 281 LatencyComponent info = {component_sequence_number, time, event_count}; |
| 267 latency_components_[key] = info; | 282 latency_components_[key] = info; |
| 268 } else { | 283 } else { |
| 269 it->second.sequence_number = | 284 it->second.sequence_number = std::max(component_sequence_number, |
| 270 std::max(component_sequence_number, it->second.sequence_number); | 285 it->second.sequence_number); |
| 271 uint32_t new_count = event_count + it->second.event_count; | 286 uint32_t new_count = event_count + it->second.event_count; |
| 272 if (event_count > 0 && new_count != 0) { | 287 if (event_count > 0 && new_count != 0) { |
| 273 // Do a weighted average, so that the new event_time is the average of | 288 // Do a weighted average, so that the new event_time is the average of |
| 274 // the times of events currently in this structure with the time passed | 289 // the times of events currently in this structure with the time passed |
| 275 // into this method. | 290 // into this method. |
| 276 it->second.event_time += | 291 it->second.event_time += (time - it->second.event_time) * event_count / |
| 277 (time - it->second.event_time) * event_count / new_count; | 292 new_count; |
| 278 it->second.event_count = new_count; | 293 it->second.event_count = new_count; |
| 279 } | 294 } |
| 280 } | 295 } |
| 281 | 296 |
| 282 if (IsTerminalComponent(component) && trace_id_ != -1) { | 297 if (IsTerminalComponent(component) && trace_id_ != -1) { |
| 283 // Should only ever add terminal component once. | 298 // Should only ever add terminal component once. |
| 284 CHECK(!terminated_); | 299 CHECK(!terminated_); |
| 285 terminated_ = true; | 300 terminated_ = true; |
| 286 | 301 |
| 287 if (*latency_info_enabled) { | 302 if (*latency_info_enabled) { |
| 288 TRACE_EVENT_COPY_ASYNC_END2( | 303 TRACE_EVENT_COPY_ASYNC_END2(kTraceCategoriesForAsyncEvents, |
| 289 kTraceCategoriesForAsyncEvents, trace_name_.c_str(), | 304 trace_name_.c_str(), |
| 290 TRACE_ID_DONT_MANGLE(trace_id_), "data", AsTraceableData(), | 305 TRACE_ID_DONT_MANGLE(trace_id_), |
| 291 "coordinates", CoordinatesAsTraceableData()); | 306 "data", AsTraceableData(), |
| 307 "coordinates", CoordinatesAsTraceableData()); |
| 292 } | 308 } |
| 293 | 309 |
| 294 TRACE_EVENT_WITH_FLOW0("input,benchmark", "LatencyInfo.Flow", | 310 TRACE_EVENT_WITH_FLOW0("input,benchmark", |
| 311 "LatencyInfo.Flow", |
| 295 TRACE_ID_DONT_MANGLE(trace_id_), | 312 TRACE_ID_DONT_MANGLE(trace_id_), |
| 296 TRACE_EVENT_FLAG_FLOW_IN); | 313 TRACE_EVENT_FLAG_FLOW_IN); |
| 297 } | 314 } |
| 298 } | 315 } |
| 299 | 316 |
| 300 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 317 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 301 LatencyInfo::AsTraceableData() { | 318 LatencyInfo::AsTraceableData() { |
| 302 std::unique_ptr<base::DictionaryValue> record_data( | 319 std::unique_ptr<base::DictionaryValue> record_data( |
| 303 new base::DictionaryValue()); | 320 new base::DictionaryValue()); |
| 304 for (const auto& lc : latency_components_) { | 321 for (const auto& lc : latency_components_) { |
| 305 std::unique_ptr<base::DictionaryValue> component_info( | 322 std::unique_ptr<base::DictionaryValue> component_info( |
| 306 new base::DictionaryValue()); | 323 new base::DictionaryValue()); |
| 307 component_info->SetDouble("comp_id", static_cast<double>(lc.first.second)); | 324 component_info->SetDouble("comp_id", static_cast<double>(lc.first.second)); |
| 308 component_info->SetDouble( | 325 component_info->SetDouble( |
| 309 "time", static_cast<double>(lc.second.event_time.ToInternalValue())); | 326 "time", |
| 327 static_cast<double>(lc.second.event_time.ToInternalValue())); |
| 310 component_info->SetDouble("count", lc.second.event_count); | 328 component_info->SetDouble("count", lc.second.event_count); |
| 311 component_info->SetDouble("sequence_number", lc.second.sequence_number); | 329 component_info->SetDouble("sequence_number", |
| 330 lc.second.sequence_number); |
| 312 record_data->Set(GetComponentName(lc.first.first), | 331 record_data->Set(GetComponentName(lc.first.first), |
| 313 std::move(component_info)); | 332 std::move(component_info)); |
| 314 } | 333 } |
| 315 record_data->SetDouble("trace_id", static_cast<double>(trace_id_)); | 334 record_data->SetDouble("trace_id", static_cast<double>(trace_id_)); |
| 316 return LatencyInfoTracedValue::FromValue(std::move(record_data)); | 335 return LatencyInfoTracedValue::FromValue(std::move(record_data)); |
| 317 } | 336 } |
| 318 | 337 |
| 319 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 338 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 320 LatencyInfo::CoordinatesAsTraceableData() { | 339 LatencyInfo::CoordinatesAsTraceableData() { |
| 321 std::unique_ptr<base::ListValue> coordinates(new base::ListValue()); | 340 std::unique_ptr<base::ListValue> coordinates(new base::ListValue()); |
| 322 for (size_t i = 0; i < input_coordinates_size_; i++) { | 341 for (size_t i = 0; i < input_coordinates_size_; i++) { |
| 323 std::unique_ptr<base::DictionaryValue> coordinate_pair( | 342 std::unique_ptr<base::DictionaryValue> coordinate_pair( |
| 324 new base::DictionaryValue()); | 343 new base::DictionaryValue()); |
| 325 coordinate_pair->SetDouble("x", input_coordinates_[i].x); | 344 coordinate_pair->SetDouble("x", input_coordinates_[i].x); |
| 326 coordinate_pair->SetDouble("y", input_coordinates_[i].y); | 345 coordinate_pair->SetDouble("y", input_coordinates_[i].y); |
| 327 coordinates->Append(coordinate_pair.release()); | 346 coordinates->Append(coordinate_pair.release()); |
| 328 } | 347 } |
| 329 return LatencyInfoTracedValue::FromValue(std::move(coordinates)); | 348 return LatencyInfoTracedValue::FromValue(std::move(coordinates)); |
| 330 } | 349 } |
| 331 | 350 |
| 332 bool LatencyInfo::FindLatency(LatencyComponentType type, | 351 bool LatencyInfo::FindLatency(LatencyComponentType type, |
| 333 int64_t id, | 352 int64_t id, |
| 334 LatencyComponent* output) const { | 353 LatencyComponent* output) const { |
| 335 LatencyMap::const_iterator it = | 354 LatencyMap::const_iterator it = latency_components_.find( |
| 336 latency_components_.find(std::make_pair(type, id)); | 355 std::make_pair(type, id)); |
| 337 if (it == latency_components_.end()) | 356 if (it == latency_components_.end()) |
| 338 return false; | 357 return false; |
| 339 if (output) | 358 if (output) |
| 340 *output = it->second; | 359 *output = it->second; |
| 341 return true; | 360 return true; |
| 342 } | 361 } |
| 343 | 362 |
| 344 void LatencyInfo::RemoveLatency(LatencyComponentType type) { | 363 void LatencyInfo::RemoveLatency(LatencyComponentType type) { |
| 345 LatencyMap::iterator it = latency_components_.begin(); | 364 LatencyMap::iterator it = latency_components_.begin(); |
| 346 while (it != latency_components_.end()) { | 365 while (it != latency_components_.end()) { |
| 347 if (it->first.first == type) { | 366 if (it->first.first == type) { |
| 348 LatencyMap::iterator tmp = it; | 367 LatencyMap::iterator tmp = it; |
| 349 ++it; | 368 ++it; |
| 350 latency_components_.erase(tmp); | 369 latency_components_.erase(tmp); |
| 351 } else { | 370 } else { |
| 352 it++; | 371 it++; |
| 353 } | 372 } |
| 354 } | 373 } |
| 355 } | 374 } |
| 356 | 375 |
| 357 bool LatencyInfo::AddInputCoordinate(const InputCoordinate& input_coordinate) { | 376 bool LatencyInfo::AddInputCoordinate(const InputCoordinate& input_coordinate) { |
| 358 if (input_coordinates_size_ >= kMaxInputCoordinates) | 377 if (input_coordinates_size_ >= kMaxInputCoordinates) |
| 359 return false; | 378 return false; |
| 360 input_coordinates_[input_coordinates_size_++] = input_coordinate; | 379 input_coordinates_[input_coordinates_size_++] = input_coordinate; |
| 361 return true; | 380 return true; |
| 362 } | 381 } |
| 363 | 382 |
| 364 } // namespace ui | 383 } // namespace ui |
| OLD | NEW |