| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 const unsigned char* latency_info_enabled; | 131 const unsigned char* latency_info_enabled; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 static base::LazyInstance<LatencyInfoEnabledInitializer>::Leaky | 134 static base::LazyInstance<LatencyInfoEnabledInitializer>::Leaky |
| 135 g_latency_info_enabled = LAZY_INSTANCE_INITIALIZER; | 135 g_latency_info_enabled = LAZY_INSTANCE_INITIALIZER; |
| 136 | 136 |
| 137 } // namespace | 137 } // namespace |
| 138 | 138 |
| 139 namespace ui { | 139 namespace ui { |
| 140 | 140 |
| 141 LatencyInfo::LatencyInfo() : LatencyInfo(SourceEventType::UNKNOWN) {} | 141 LatencyInfo::LatencyInfo() |
| 142 | |
| 143 LatencyInfo::LatencyInfo(SourceEventType type) | |
| 144 : input_coordinates_size_(0), | 142 : input_coordinates_size_(0), |
| 145 trace_id_(-1), | 143 trace_id_(-1), |
| 146 coalesced_(false), | 144 coalesced_(false), |
| 147 terminated_(false), | 145 terminated_(false) {} |
| 148 source_event_type_(type) {} | |
| 149 | 146 |
| 150 LatencyInfo::LatencyInfo(const LatencyInfo& other) = default; | 147 LatencyInfo::LatencyInfo(const LatencyInfo& other) = default; |
| 151 | 148 |
| 152 LatencyInfo::~LatencyInfo() {} | 149 LatencyInfo::~LatencyInfo() {} |
| 153 | 150 |
| 154 LatencyInfo::LatencyInfo(int64_t trace_id, bool terminated) | 151 LatencyInfo::LatencyInfo(int64_t trace_id, bool terminated) |
| 155 : input_coordinates_size_(0), | 152 : input_coordinates_size_(0), |
| 156 trace_id_(trace_id), | 153 trace_id_(trace_id), |
| 157 terminated_(terminated), | 154 terminated_(terminated) {} |
| 158 source_event_type_(SourceEventType::UNKNOWN) {} | |
| 159 | 155 |
| 160 bool LatencyInfo::Verify(const std::vector<LatencyInfo>& latency_info, | 156 bool LatencyInfo::Verify(const std::vector<LatencyInfo>& latency_info, |
| 161 const char* referring_msg) { | 157 const char* referring_msg) { |
| 162 if (latency_info.size() > kMaxLatencyInfoNumber) { | 158 if (latency_info.size() > kMaxLatencyInfoNumber) { |
| 163 LOG(ERROR) << referring_msg << ", LatencyInfo vector size " | 159 LOG(ERROR) << referring_msg << ", LatencyInfo vector size " |
| 164 << latency_info.size() << " is too big."; | 160 << latency_info.size() << " is too big."; |
| 165 TRACE_EVENT_INSTANT1("input,benchmark", "LatencyInfo::Verify Fails", | 161 TRACE_EVENT_INSTANT1("input,benchmark", "LatencyInfo::Verify Fails", |
| 166 TRACE_EVENT_SCOPE_GLOBAL, | 162 TRACE_EVENT_SCOPE_GLOBAL, |
| 167 "size", latency_info.size()); | 163 "size", latency_info.size()); |
| 168 return false; | 164 return false; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 368 } |
| 373 | 369 |
| 374 bool LatencyInfo::AddInputCoordinate(const gfx::PointF& input_coordinate) { | 370 bool LatencyInfo::AddInputCoordinate(const gfx::PointF& input_coordinate) { |
| 375 if (input_coordinates_size_ >= kMaxInputCoordinates) | 371 if (input_coordinates_size_ >= kMaxInputCoordinates) |
| 376 return false; | 372 return false; |
| 377 input_coordinates_[input_coordinates_size_++] = input_coordinate; | 373 input_coordinates_[input_coordinates_size_++] = input_coordinate; |
| 378 return true; | 374 return true; |
| 379 } | 375 } |
| 380 | 376 |
| 381 } // namespace ui | 377 } // namespace ui |
| OLD | NEW |