| 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 | 9 |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // originally created, e.g. the timestamp of its ORIGINAL/UI_COMPONENT, | 237 // originally created, e.g. the timestamp of its ORIGINAL/UI_COMPONENT, |
| 238 // not when we actually issue the ASYNC_BEGIN trace event. | 238 // not when we actually issue the ASYNC_BEGIN trace event. |
| 239 LatencyComponent begin_component; | 239 LatencyComponent begin_component; |
| 240 int64 ts = 0; | 240 int64 ts = 0; |
| 241 if (FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | 241 if (FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
| 242 0, | 242 0, |
| 243 &begin_component) || | 243 &begin_component) || |
| 244 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, | 244 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, |
| 245 0, | 245 0, |
| 246 &begin_component)) { | 246 &begin_component)) { |
| 247 // The timestamp stored in ORIGINAL/UI_COMPONENT is using clock | 247 ts = begin_component.event_time.ToInternalValue(); |
| 248 // CLOCK_MONOTONIC while TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0 | |
| 249 // expects timestamp using CLOCK_MONOTONIC or CLOCK_SYSTEM_TRACE (on | |
| 250 // CrOS). So we need to adjust the diff between in CLOCK_MONOTONIC and | |
| 251 // CLOCK_SYSTEM_TRACE. Note that the diff is drifting overtime so we | |
| 252 // can't use a static value. | |
| 253 base::TimeDelta diff = (base::TimeTicks::Now() - base::TimeTicks()) - | |
| 254 (base::TraceTicks::Now() - base::TraceTicks()); | |
| 255 ts = (begin_component.event_time - diff).ToInternalValue(); | |
| 256 } else { | 248 } else { |
| 257 ts = base::TraceTicks::Now().ToInternalValue(); | 249 ts = base::TimeTicks::Now().ToInternalValue(); |
| 258 } | 250 } |
| 259 | 251 |
| 260 if (trace_name_str) { | 252 if (trace_name_str) { |
| 261 if (IsInputLatencyBeginComponent(component)) | 253 if (IsInputLatencyBeginComponent(component)) |
| 262 trace_name_ = std::string("InputLatency::") + trace_name_str; | 254 trace_name_ = std::string("InputLatency::") + trace_name_str; |
| 263 else | 255 else |
| 264 trace_name_ = std::string("Latency::") + trace_name_str; | 256 trace_name_ = std::string("Latency::") + trace_name_str; |
| 265 } | 257 } |
| 266 | 258 |
| 267 TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0( | 259 TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0( |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 373 } |
| 382 | 374 |
| 383 bool LatencyInfo::AddCoalescedEventTimestamp(double timestamp) { | 375 bool LatencyInfo::AddCoalescedEventTimestamp(double timestamp) { |
| 384 if (coalesced_events_size_ >= kMaxCoalescedEventTimestamps) | 376 if (coalesced_events_size_ >= kMaxCoalescedEventTimestamps) |
| 385 return false; | 377 return false; |
| 386 timestamps_of_coalesced_events_[coalesced_events_size_++] = timestamp; | 378 timestamps_of_coalesced_events_[coalesced_events_size_++] = timestamp; |
| 387 return true; | 379 return true; |
| 388 } | 380 } |
| 389 | 381 |
| 390 } // namespace ui | 382 } // namespace ui |
| OLD | NEW |