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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 &begin_component) || | 274 &begin_component) || |
275 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, | 275 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, |
276 0, | 276 0, |
277 &begin_component)) { | 277 &begin_component)) { |
278 // The timestamp stored in ORIGINAL/UI_COMPONENT is using clock | 278 // The timestamp stored in ORIGINAL/UI_COMPONENT is using clock |
279 // CLOCK_MONOTONIC while TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0 | 279 // CLOCK_MONOTONIC while TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0 |
280 // expects timestamp using CLOCK_MONOTONIC or CLOCK_SYSTEM_TRACE (on | 280 // expects timestamp using CLOCK_MONOTONIC or CLOCK_SYSTEM_TRACE (on |
281 // CrOS). So we need to adjust the diff between in CLOCK_MONOTONIC and | 281 // CrOS). So we need to adjust the diff between in CLOCK_MONOTONIC and |
282 // CLOCK_SYSTEM_TRACE. Note that the diff is drifting overtime so we | 282 // CLOCK_SYSTEM_TRACE. Note that the diff is drifting overtime so we |
283 // can't use a static value. | 283 // can't use a static value. |
284 int64 diff = base::TimeTicks::Now().ToInternalValue() - | 284 base::TimeDelta diff = (base::TimeTicks::Now() - base::TimeTicks()) - |
285 base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); | 285 (base::TraceTicks::Now() - base::TraceTicks()); |
286 ts = begin_component.event_time.ToInternalValue() - diff; | 286 ts = (begin_component.event_time - diff).ToInternalValue(); |
287 } else { | 287 } else { |
288 ts = base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); | 288 ts = base::TraceTicks::Now().ToInternalValue(); |
289 } | 289 } |
290 | 290 |
291 if (trace_name_str) { | 291 if (trace_name_str) { |
292 if (IsInputLatencyBeginComponent(component)) | 292 if (IsInputLatencyBeginComponent(component)) |
293 trace_name = std::string("InputLatency::") + trace_name_str; | 293 trace_name = std::string("InputLatency::") + trace_name_str; |
294 else | 294 else |
295 trace_name = std::string("Latency::") + trace_name_str; | 295 trace_name = std::string("Latency::") + trace_name_str; |
296 } | 296 } |
297 | 297 |
298 TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0( | 298 TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 it++; | 366 it++; |
367 } | 367 } |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 void LatencyInfo::Clear() { | 371 void LatencyInfo::Clear() { |
372 latency_components.clear(); | 372 latency_components.clear(); |
373 } | 373 } |
374 | 374 |
375 } // namespace ui | 375 } // namespace ui |
OLD | NEW |