| 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/events/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> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool IsInputLatencyBeginComponent(ui::LatencyComponentType type) { | 79 bool IsInputLatencyBeginComponent(ui::LatencyComponentType type) { |
| 80 return type == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT; | 80 return type == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // This class is for converting latency info to trace buffer friendly format. | 83 // This class is for converting latency info to trace buffer friendly format. |
| 84 class LatencyInfoTracedValue | 84 class LatencyInfoTracedValue |
| 85 : public base::trace_event::ConvertableToTraceFormat { | 85 : public base::trace_event::ConvertableToTraceFormat { |
| 86 public: | 86 public: |
| 87 static scoped_ptr<ConvertableToTraceFormat> FromValue( | 87 static std::unique_ptr<ConvertableToTraceFormat> FromValue( |
| 88 scoped_ptr<base::Value> value); | 88 std::unique_ptr<base::Value> value); |
| 89 | 89 |
| 90 void AppendAsTraceFormat(std::string* out) const override; | 90 void AppendAsTraceFormat(std::string* out) const override; |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 explicit LatencyInfoTracedValue(base::Value* value); | 93 explicit LatencyInfoTracedValue(base::Value* value); |
| 94 ~LatencyInfoTracedValue() override; | 94 ~LatencyInfoTracedValue() override; |
| 95 | 95 |
| 96 scoped_ptr<base::Value> value_; | 96 std::unique_ptr<base::Value> value_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(LatencyInfoTracedValue); | 98 DISALLOW_COPY_AND_ASSIGN(LatencyInfoTracedValue); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 101 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 102 LatencyInfoTracedValue::FromValue(scoped_ptr<base::Value> value) { | 102 LatencyInfoTracedValue::FromValue(std::unique_ptr<base::Value> value) { |
| 103 return scoped_ptr<base::trace_event::ConvertableToTraceFormat>( | 103 return std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( |
| 104 new LatencyInfoTracedValue(value.release())); | 104 new LatencyInfoTracedValue(value.release())); |
| 105 } | 105 } |
| 106 | 106 |
| 107 LatencyInfoTracedValue::~LatencyInfoTracedValue() { | 107 LatencyInfoTracedValue::~LatencyInfoTracedValue() { |
| 108 } | 108 } |
| 109 | 109 |
| 110 void LatencyInfoTracedValue::AppendAsTraceFormat(std::string* out) const { | 110 void LatencyInfoTracedValue::AppendAsTraceFormat(std::string* out) const { |
| 111 std::string tmp; | 111 std::string tmp; |
| 112 base::JSONWriter::Write(*value_, &tmp); | 112 base::JSONWriter::Write(*value_, &tmp); |
| 113 *out += tmp; | 113 *out += tmp; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 "coordinates", CoordinatesAsTraceableData()); | 307 "coordinates", CoordinatesAsTraceableData()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 TRACE_EVENT_WITH_FLOW0("input,benchmark", | 310 TRACE_EVENT_WITH_FLOW0("input,benchmark", |
| 311 "LatencyInfo.Flow", | 311 "LatencyInfo.Flow", |
| 312 TRACE_ID_DONT_MANGLE(trace_id_), | 312 TRACE_ID_DONT_MANGLE(trace_id_), |
| 313 TRACE_EVENT_FLAG_FLOW_IN); | 313 TRACE_EVENT_FLAG_FLOW_IN); |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 | 316 |
| 317 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 317 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 318 LatencyInfo::AsTraceableData() { | 318 LatencyInfo::AsTraceableData() { |
| 319 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 319 std::unique_ptr<base::DictionaryValue> record_data( |
| 320 new base::DictionaryValue()); |
| 320 for (const auto& lc : latency_components_) { | 321 for (const auto& lc : latency_components_) { |
| 321 scoped_ptr<base::DictionaryValue> | 322 std::unique_ptr<base::DictionaryValue> component_info( |
| 322 component_info(new base::DictionaryValue()); | 323 new base::DictionaryValue()); |
| 323 component_info->SetDouble("comp_id", static_cast<double>(lc.first.second)); | 324 component_info->SetDouble("comp_id", static_cast<double>(lc.first.second)); |
| 324 component_info->SetDouble( | 325 component_info->SetDouble( |
| 325 "time", | 326 "time", |
| 326 static_cast<double>(lc.second.event_time.ToInternalValue())); | 327 static_cast<double>(lc.second.event_time.ToInternalValue())); |
| 327 component_info->SetDouble("count", lc.second.event_count); | 328 component_info->SetDouble("count", lc.second.event_count); |
| 328 component_info->SetDouble("sequence_number", | 329 component_info->SetDouble("sequence_number", |
| 329 lc.second.sequence_number); | 330 lc.second.sequence_number); |
| 330 record_data->Set(GetComponentName(lc.first.first), | 331 record_data->Set(GetComponentName(lc.first.first), |
| 331 std::move(component_info)); | 332 std::move(component_info)); |
| 332 } | 333 } |
| 333 record_data->SetDouble("trace_id", static_cast<double>(trace_id_)); | 334 record_data->SetDouble("trace_id", static_cast<double>(trace_id_)); |
| 334 return LatencyInfoTracedValue::FromValue(std::move(record_data)); | 335 return LatencyInfoTracedValue::FromValue(std::move(record_data)); |
| 335 } | 336 } |
| 336 | 337 |
| 337 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 338 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 338 LatencyInfo::CoordinatesAsTraceableData() { | 339 LatencyInfo::CoordinatesAsTraceableData() { |
| 339 scoped_ptr<base::ListValue> coordinates(new base::ListValue()); | 340 std::unique_ptr<base::ListValue> coordinates(new base::ListValue()); |
| 340 for (size_t i = 0; i < input_coordinates_size_; i++) { | 341 for (size_t i = 0; i < input_coordinates_size_; i++) { |
| 341 scoped_ptr<base::DictionaryValue> coordinate_pair( | 342 std::unique_ptr<base::DictionaryValue> coordinate_pair( |
| 342 new base::DictionaryValue()); | 343 new base::DictionaryValue()); |
| 343 coordinate_pair->SetDouble("x", input_coordinates_[i].x); | 344 coordinate_pair->SetDouble("x", input_coordinates_[i].x); |
| 344 coordinate_pair->SetDouble("y", input_coordinates_[i].y); | 345 coordinate_pair->SetDouble("y", input_coordinates_[i].y); |
| 345 coordinates->Append(coordinate_pair.release()); | 346 coordinates->Append(coordinate_pair.release()); |
| 346 } | 347 } |
| 347 return LatencyInfoTracedValue::FromValue(std::move(coordinates)); | 348 return LatencyInfoTracedValue::FromValue(std::move(coordinates)); |
| 348 } | 349 } |
| 349 | 350 |
| 350 bool LatencyInfo::FindLatency(LatencyComponentType type, | 351 bool LatencyInfo::FindLatency(LatencyComponentType type, |
| 351 int64_t id, | 352 int64_t id, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 373 } | 374 } |
| 374 | 375 |
| 375 bool LatencyInfo::AddInputCoordinate(const InputCoordinate& input_coordinate) { | 376 bool LatencyInfo::AddInputCoordinate(const InputCoordinate& input_coordinate) { |
| 376 if (input_coordinates_size_ >= kMaxInputCoordinates) | 377 if (input_coordinates_size_ >= kMaxInputCoordinates) |
| 377 return false; | 378 return false; |
| 378 input_coordinates_[input_coordinates_size_++] = input_coordinate; | 379 input_coordinates_[input_coordinates_size_++] = input_coordinate; |
| 379 return true; | 380 return true; |
| 380 } | 381 } |
| 381 | 382 |
| 382 } // namespace ui | 383 } // namespace ui |
| OLD | NEW |