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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
| 9 #include <utility> |
9 | 10 |
10 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
11 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 const size_t kMaxLatencyInfoNumber = 100; | 17 const size_t kMaxLatencyInfoNumber = 100; |
17 | 18 |
18 const char* GetComponentName(ui::LatencyComponentType type) { | 19 const char* GetComponentName(ui::LatencyComponentType type) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 for (const auto& lc : latency_components_) { | 318 for (const auto& lc : latency_components_) { |
318 scoped_ptr<base::DictionaryValue> | 319 scoped_ptr<base::DictionaryValue> |
319 component_info(new base::DictionaryValue()); | 320 component_info(new base::DictionaryValue()); |
320 component_info->SetDouble("comp_id", static_cast<double>(lc.first.second)); | 321 component_info->SetDouble("comp_id", static_cast<double>(lc.first.second)); |
321 component_info->SetDouble( | 322 component_info->SetDouble( |
322 "time", | 323 "time", |
323 static_cast<double>(lc.second.event_time.ToInternalValue())); | 324 static_cast<double>(lc.second.event_time.ToInternalValue())); |
324 component_info->SetDouble("count", lc.second.event_count); | 325 component_info->SetDouble("count", lc.second.event_count); |
325 component_info->SetDouble("sequence_number", | 326 component_info->SetDouble("sequence_number", |
326 lc.second.sequence_number); | 327 lc.second.sequence_number); |
327 record_data->Set(GetComponentName(lc.first.first), component_info.Pass()); | 328 record_data->Set(GetComponentName(lc.first.first), |
| 329 std::move(component_info)); |
328 } | 330 } |
329 record_data->SetDouble("trace_id", static_cast<double>(trace_id_)); | 331 record_data->SetDouble("trace_id", static_cast<double>(trace_id_)); |
330 return LatencyInfoTracedValue::FromValue(record_data.Pass()); | 332 return LatencyInfoTracedValue::FromValue(std::move(record_data)); |
331 } | 333 } |
332 | 334 |
333 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 335 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
334 LatencyInfo::CoordinatesAsTraceableData() { | 336 LatencyInfo::CoordinatesAsTraceableData() { |
335 scoped_ptr<base::ListValue> coordinates(new base::ListValue()); | 337 scoped_ptr<base::ListValue> coordinates(new base::ListValue()); |
336 for (size_t i = 0; i < input_coordinates_size_; i++) { | 338 for (size_t i = 0; i < input_coordinates_size_; i++) { |
337 scoped_ptr<base::DictionaryValue> coordinate_pair( | 339 scoped_ptr<base::DictionaryValue> coordinate_pair( |
338 new base::DictionaryValue()); | 340 new base::DictionaryValue()); |
339 coordinate_pair->SetDouble("x", input_coordinates_[i].x); | 341 coordinate_pair->SetDouble("x", input_coordinates_[i].x); |
340 coordinate_pair->SetDouble("y", input_coordinates_[i].y); | 342 coordinate_pair->SetDouble("y", input_coordinates_[i].y); |
341 coordinates->Append(coordinate_pair.release()); | 343 coordinates->Append(coordinate_pair.release()); |
342 } | 344 } |
343 return LatencyInfoTracedValue::FromValue(coordinates.Pass()); | 345 return LatencyInfoTracedValue::FromValue(std::move(coordinates)); |
344 } | 346 } |
345 | 347 |
346 bool LatencyInfo::FindLatency(LatencyComponentType type, | 348 bool LatencyInfo::FindLatency(LatencyComponentType type, |
347 int64 id, | 349 int64 id, |
348 LatencyComponent* output) const { | 350 LatencyComponent* output) const { |
349 LatencyMap::const_iterator it = latency_components_.find( | 351 LatencyMap::const_iterator it = latency_components_.find( |
350 std::make_pair(type, id)); | 352 std::make_pair(type, id)); |
351 if (it == latency_components_.end()) | 353 if (it == latency_components_.end()) |
352 return false; | 354 return false; |
353 if (output) | 355 if (output) |
(...skipping 22 matching lines...) Expand all Loading... |
376 } | 378 } |
377 | 379 |
378 bool LatencyInfo::AddCoalescedEventTimestamp(double timestamp) { | 380 bool LatencyInfo::AddCoalescedEventTimestamp(double timestamp) { |
379 if (coalesced_events_size_ >= kMaxCoalescedEventTimestamps) | 381 if (coalesced_events_size_ >= kMaxCoalescedEventTimestamps) |
380 return false; | 382 return false; |
381 timestamps_of_coalesced_events_[coalesced_events_size_++] = timestamp; | 383 timestamps_of_coalesced_events_[coalesced_events_size_++] = timestamp; |
382 return true; | 384 return true; |
383 } | 385 } |
384 | 386 |
385 } // namespace ui | 387 } // namespace ui |
OLD | NEW |