Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: ui/events/latency_info.cc

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/device_data_manager.h ('k') | ui/events/platform/platform_event_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/json/json_writer.h" 5 #include "base/json/json_writer.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "ui/events/latency_info.h" 9 #include "ui/events/latency_info.h"
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 LatencyInfoTracedValue::FromValue(scoped_ptr<base::Value> value) { 94 LatencyInfoTracedValue::FromValue(scoped_ptr<base::Value> value) {
95 return scoped_refptr<base::trace_event::ConvertableToTraceFormat>( 95 return scoped_refptr<base::trace_event::ConvertableToTraceFormat>(
96 new LatencyInfoTracedValue(value.release())); 96 new LatencyInfoTracedValue(value.release()));
97 } 97 }
98 98
99 LatencyInfoTracedValue::~LatencyInfoTracedValue() { 99 LatencyInfoTracedValue::~LatencyInfoTracedValue() {
100 } 100 }
101 101
102 void LatencyInfoTracedValue::AppendAsTraceFormat(std::string* out) const { 102 void LatencyInfoTracedValue::AppendAsTraceFormat(std::string* out) const {
103 std::string tmp; 103 std::string tmp;
104 base::JSONWriter::Write(value_.get(), &tmp); 104 base::JSONWriter::Write(*value_, &tmp);
105 *out += tmp; 105 *out += tmp;
106 } 106 }
107 107
108 LatencyInfoTracedValue::LatencyInfoTracedValue(base::Value* value) 108 LatencyInfoTracedValue::LatencyInfoTracedValue(base::Value* value)
109 : value_(value) { 109 : value_(value) {
110 } 110 }
111 111
112 // Converts latencyinfo into format that can be dumped into trace buffer. 112 // Converts latencyinfo into format that can be dumped into trace buffer.
113 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsTraceableData( 113 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsTraceableData(
114 const ui::LatencyInfo& latency) { 114 const ui::LatencyInfo& latency) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // Should only ever add begin component once. 221 // Should only ever add begin component once.
222 CHECK_EQ(-1, trace_id); 222 CHECK_EQ(-1, trace_id);
223 trace_id = component_sequence_number; 223 trace_id = component_sequence_number;
224 224
225 if (*benchmark_enabled) { 225 if (*benchmark_enabled) {
226 // The timestamp for ASYNC_BEGIN trace event is used for drawing the 226 // The timestamp for ASYNC_BEGIN trace event is used for drawing the
227 // beginning of the trace event in trace viewer. For better visualization, 227 // beginning of the trace event in trace viewer. For better visualization,
228 // for an input event, we want to draw the beginning as when the event is 228 // for an input event, we want to draw the beginning as when the event is
229 // originally created, e.g. the timestamp of its ORIGINAL/UI_COMPONENT, 229 // originally created, e.g. the timestamp of its ORIGINAL/UI_COMPONENT,
230 // not when we actually issue the ASYNC_BEGIN trace event. 230 // not when we actually issue the ASYNC_BEGIN trace event.
231 LatencyComponent component; 231 LatencyComponent begin_component;
232 int64 ts = 0; 232 int64 ts = 0;
233 if (FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 233 if (FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
234 0, 234 0,
235 &component) || 235 &begin_component) ||
236 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 236 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT,
237 0, 237 0,
238 &component)) { 238 &begin_component)) {
239 // The timestamp stored in ORIGINAL/UI_COMPONENT is using clock 239 // The timestamp stored in ORIGINAL/UI_COMPONENT is using clock
240 // CLOCK_MONOTONIC while TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0 240 // CLOCK_MONOTONIC while TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0
241 // expects timestamp using CLOCK_MONOTONIC or CLOCK_SYSTEM_TRACE (on 241 // expects timestamp using CLOCK_MONOTONIC or CLOCK_SYSTEM_TRACE (on
242 // CrOS). So we need to adjust the diff between in CLOCK_MONOTONIC and 242 // CrOS). So we need to adjust the diff between in CLOCK_MONOTONIC and
243 // CLOCK_SYSTEM_TRACE. Note that the diff is drifting overtime so we 243 // CLOCK_SYSTEM_TRACE. Note that the diff is drifting overtime so we
244 // can't use a static value. 244 // can't use a static value.
245 int64 diff = base::TimeTicks::Now().ToInternalValue() - 245 base::TimeDelta diff = (base::TimeTicks::Now() - base::TimeTicks()) -
246 base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); 246 (base::TraceTicks::Now() - base::TraceTicks());
247 ts = component.event_time.ToInternalValue() - diff; 247 ts = (begin_component.event_time - diff).ToInternalValue();
248 } else { 248 } else {
249 ts = base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); 249 ts = base::TraceTicks::Now().ToInternalValue();
250 } 250 }
251 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0( 251 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(
252 "benchmark", 252 "benchmark",
253 "InputLatency", 253 "InputLatency",
254 TRACE_ID_DONT_MANGLE(trace_id), 254 TRACE_ID_DONT_MANGLE(trace_id),
255 ts); 255 ts);
256 } 256 }
257 257
258 TRACE_EVENT_FLOW_BEGIN0( 258 TRACE_EVENT_FLOW_BEGIN0(
259 "input,benchmark", "LatencyInfo.Flow", TRACE_ID_DONT_MANGLE(trace_id)); 259 "input,benchmark", "LatencyInfo.Flow", TRACE_ID_DONT_MANGLE(trace_id));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 325 }
326 326
327 void LatencyInfo::TraceEventType(const char* event_type) { 327 void LatencyInfo::TraceEventType(const char* event_type) {
328 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", 328 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark",
329 "InputLatency", 329 "InputLatency",
330 TRACE_ID_DONT_MANGLE(trace_id), 330 TRACE_ID_DONT_MANGLE(trace_id),
331 event_type); 331 event_type);
332 } 332 }
333 333
334 } // namespace ui 334 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/device_data_manager.h ('k') | ui/events/platform/platform_event_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698