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 "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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 | 108 |
109 // Converts latencyinfo into format that can be dumped into trace buffer. | 109 // Converts latencyinfo into format that can be dumped into trace buffer. |
110 scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData( | 110 scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData( |
111 const ui::LatencyInfo& latency) { | 111 const ui::LatencyInfo& latency) { |
112 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 112 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
113 for (ui::LatencyInfo::LatencyMap::const_iterator it = | 113 for (ui::LatencyInfo::LatencyMap::const_iterator it = |
114 latency.latency_components.begin(); | 114 latency.latency_components.begin(); |
115 it != latency.latency_components.end(); ++it) { | 115 it != latency.latency_components.end(); ++it) { |
116 base::DictionaryValue* component_info = new base::DictionaryValue(); | 116 base::DictionaryValue* component_info = new base::DictionaryValue(); |
117 component_info->SetDouble("comp_id", it->first.second); | 117 component_info->SetDouble("comp_id", static_cast<double>(it->first.second)); |
118 component_info->SetDouble("time", it->second.event_time.ToInternalValue()); | 118 component_info->SetDouble( |
| 119 "time", static_cast<double>(it->second.event_time.ToInternalValue())); |
119 component_info->SetDouble("count", it->second.event_count); | 120 component_info->SetDouble("count", it->second.event_count); |
120 record_data->Set(GetComponentName(it->first.first), component_info); | 121 record_data->Set(GetComponentName(it->first.first), component_info); |
121 } | 122 } |
122 record_data->SetDouble("trace_id", latency.trace_id); | 123 record_data->SetDouble("trace_id", static_cast<double>(latency.trace_id)); |
123 | 124 |
124 scoped_ptr<base::ListValue> coordinates(new base::ListValue()); | 125 scoped_ptr<base::ListValue> coordinates(new base::ListValue()); |
125 for (size_t i = 0; i < latency.input_coordinates_size; i++) { | 126 for (size_t i = 0; i < latency.input_coordinates_size; i++) { |
126 scoped_ptr<base::DictionaryValue> coordinate_pair( | 127 scoped_ptr<base::DictionaryValue> coordinate_pair( |
127 new base::DictionaryValue()); | 128 new base::DictionaryValue()); |
128 coordinate_pair->SetDouble("x", latency.input_coordinates[i].x); | 129 coordinate_pair->SetDouble("x", latency.input_coordinates[i].x); |
129 coordinate_pair->SetDouble("y", latency.input_coordinates[i].y); | 130 coordinate_pair->SetDouble("y", latency.input_coordinates[i].y); |
130 coordinates->Append(coordinate_pair.release()); | 131 coordinates->Append(coordinate_pair.release()); |
131 } | 132 } |
132 record_data->Set("coordinates", coordinates.release()); | 133 record_data->Set("coordinates", coordinates.release()); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 322 } |
322 | 323 |
323 void LatencyInfo::TraceEventType(const char* event_type) { | 324 void LatencyInfo::TraceEventType(const char* event_type) { |
324 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", | 325 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", |
325 "InputLatency", | 326 "InputLatency", |
326 TRACE_ID_DONT_MANGLE(trace_id), | 327 TRACE_ID_DONT_MANGLE(trace_id), |
327 event_type); | 328 event_type); |
328 } | 329 } |
329 | 330 |
330 } // namespace ui | 331 } // namespace ui |
OLD | NEW |