| 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 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 |
| 15 const unsigned int kMaxLatencyInfoNumber = 100; |
| 16 |
| 14 const char* GetComponentName(ui::LatencyComponentType type) { | 17 const char* GetComponentName(ui::LatencyComponentType type) { |
| 15 #define CASE_TYPE(t) case ui::t: return #t | 18 #define CASE_TYPE(t) case ui::t: return #t |
| 16 switch (type) { | 19 switch (type) { |
| 17 CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT); | 20 CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT); |
| 18 CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT); | 21 CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT); |
| 19 CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT); | 22 CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT); |
| 20 CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); | 23 CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); |
| 21 CASE_TYPE(INPUT_EVENT_LATENCY_UI_COMPONENT); | 24 CASE_TYPE(INPUT_EVENT_LATENCY_UI_COMPONENT); |
| 22 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT); | 25 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT); |
| 23 CASE_TYPE(INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT); | 26 CASE_TYPE(INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } // namespace | 115 } // namespace |
| 113 | 116 |
| 114 namespace ui { | 117 namespace ui { |
| 115 | 118 |
| 116 LatencyInfo::LatencyInfo() : trace_id(-1), terminated(false) { | 119 LatencyInfo::LatencyInfo() : trace_id(-1), terminated(false) { |
| 117 } | 120 } |
| 118 | 121 |
| 119 LatencyInfo::~LatencyInfo() { | 122 LatencyInfo::~LatencyInfo() { |
| 120 } | 123 } |
| 121 | 124 |
| 125 bool LatencyInfo::Verify(const std::vector<LatencyInfo>& latency_info, |
| 126 const char* referring_msg) { |
| 127 if (latency_info.size() > kMaxLatencyInfoNumber) { |
| 128 LOG(ERROR) << referring_msg << ", LatencyInfo vector size " |
| 129 << latency_info.size() << " is too big."; |
| 130 return false; |
| 131 } |
| 132 return true; |
| 133 } |
| 134 |
| 122 void LatencyInfo::MergeWith(const LatencyInfo& other) { | 135 void LatencyInfo::MergeWith(const LatencyInfo& other) { |
| 123 for (LatencyMap::const_iterator it = other.latency_components.begin(); | 136 for (LatencyMap::const_iterator it = other.latency_components.begin(); |
| 124 it != other.latency_components.end(); | 137 it != other.latency_components.end(); |
| 125 ++it) { | 138 ++it) { |
| 126 AddLatencyNumberWithTimestamp(it->first.first, | 139 AddLatencyNumberWithTimestamp(it->first.first, |
| 127 it->first.second, | 140 it->first.second, |
| 128 it->second.sequence_number, | 141 it->second.sequence_number, |
| 129 it->second.event_time, | 142 it->second.event_time, |
| 130 it->second.event_count, | 143 it->second.event_count, |
| 131 false); | 144 false); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 242 } |
| 230 | 243 |
| 231 void LatencyInfo::TraceEventType(const char* event_type) { | 244 void LatencyInfo::TraceEventType(const char* event_type) { |
| 232 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", | 245 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", |
| 233 "InputLatency", | 246 "InputLatency", |
| 234 TRACE_ID_DONT_MANGLE(trace_id), | 247 TRACE_ID_DONT_MANGLE(trace_id), |
| 235 event_type); | 248 event_type); |
| 236 } | 249 } |
| 237 | 250 |
| 238 } // namespace ui | 251 } // namespace ui |
| OLD | NEW |