diff options
author | miletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-26 00:08:53 +0000 |
---|---|---|
committer | miletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-26 00:08:53 +0000 |
commit | 7612a848db4b40477ac6fd6bc0f4b9cdcf421751 (patch) | |
tree | 23070862c954e116a9d28646c23122d8d0936d5f /ui | |
parent | 9fea4d921c84275002e1f2aa465ea82a1014343b (diff) | |
download | chromium_src-7612a848db4b40477ac6fd6bc0f4b9cdcf421751.zip chromium_src-7612a848db4b40477ac6fd6bc0f4b9cdcf421751.tar.gz chromium_src-7612a848db4b40477ac6fd6bc0f4b9cdcf421751.tar.bz2 |
Let gesture & touch event LatencyInfo have different trace_id
LatencyInfo's trace_id is the unique ID for LatencyInfo's ASYNC
trace event shown in the about://tracing. When input event reaches
RWHI, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT is inserted into
event's LatencyInfo, and the latency component's component sequence
number is used as the LatencyInfo's trace_id. ASYNC_BEGIN event with
the trace_id is emitted also.
The problem is that one touch event can generate multiple gesture
events, so if the gesture event inherits touch event's LatencyInfo
trace_id, there could be multiple gesture events LatencyInfo emitting
ASYNC_END with the same trace_id.
In this CL we do the following: if touch event's LatencyInfo does
not end at render side, end it at browser side. Copy the touch
event's LatencyInfo into gesture events' LatencyInfo. Clear gesture
events' LatencyInfo trace_id and remove the
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT.
So when gesture event passes through RWHI, it will have its own
LatencyInfo trace_id and new ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT.
Also the trace_id needs to be unique across multiple processes (
since we can emit ASYNC_BEGIN in one process and ASYNC_END in another
process). So initialize the last_input_number_'s high 32bits with
process id.
BUG=246034
TEST=Check in about://tracing, that gesture events' LatencyInfo don't
inherit trace_id from touche events' LatencyInfo.
Review URL: https://codereview.chromium.org/81873003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/events/gestures/gesture_sequence.cc | 36 | ||||
-rw-r--r-- | ui/events/latency_info.cc | 14 | ||||
-rw-r--r-- | ui/events/latency_info.h | 2 |
3 files changed, 35 insertions, 17 deletions
diff --git a/ui/events/gestures/gesture_sequence.cc b/ui/events/gestures/gesture_sequence.cc index f13af4a..7c19519 100644 --- a/ui/events/gestures/gesture_sequence.cc +++ b/ui/events/gestures/gesture_sequence.cc @@ -449,25 +449,27 @@ float CalibrateFlingVelocity(float velocity) { void UpdateGestureEventLatencyInfo(const TouchEvent& event, GestureSequence::Gestures* gestures) { - // If the touch event does not cause any rendering scheduled, then - // 1) If the touch event does not generate any gesture event, its - // LatencyInfo ends here. - // 2) If the touch event generates gesture events, its latencyinfo - // is copied into the gesture events. + // If the touch event does not cause any rendering scheduled, we first + // end the touch event's LatencyInfo. Then we copy the touch event's + // LatencyInfo into the generated gesture's LatencyInfo. Since one touch + // event can generate multiple gesture events, we have to clear the gesture + // event's trace_id, remove its ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, + // so when the gesture event passes through RWHI, a new trace_id will be + // assigned and new ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will be added. if (!event.latency()->FindLatency( ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { - if (gestures->empty()) { - ui::LatencyInfo* touch_latency = - const_cast<ui::LatencyInfo*>(event.latency()); - touch_latency->AddLatencyNumber( - ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0); - } else { - GestureSequence::Gestures::iterator it = gestures->begin(); - for (; it != gestures->end(); it++) { - (*it)->latency()->MergeWith(*event.latency()); - // Inheriting the trace_id from the touch event's LatencyInfo - (*it)->latency()->trace_id = event.latency()->trace_id; - } + ui::LatencyInfo* touch_latency = + const_cast<ui::LatencyInfo*>(event.latency()); + touch_latency->AddLatencyNumber( + ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0); + GestureSequence::Gestures::iterator it = gestures->begin(); + for (; it != gestures->end(); it++) { + ui::LatencyInfo* gesture_latency = (*it)->latency(); + *gesture_latency = *touch_latency; + gesture_latency->trace_id = -1; + gesture_latency->terminated = false; + gesture_latency->RemoveLatency( + ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT); } } } diff --git a/ui/events/latency_info.cc b/ui/events/latency_info.cc index 9c44bdc..b75af66 100644 --- a/ui/events/latency_info.cc +++ b/ui/events/latency_info.cc @@ -98,6 +98,7 @@ scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData( component_info->SetDouble("count", it->second.event_count); record_data->Set(GetComponentName(it->first.first), component_info); } + record_data->SetDouble("trace_id", latency.trace_id); return LatencyInfoTracedValue::FromValue(record_data.PassAs<base::Value>()); } @@ -204,6 +205,19 @@ bool LatencyInfo::FindLatency(LatencyComponentType type, return true; } +void LatencyInfo::RemoveLatency(LatencyComponentType type) { + LatencyMap::iterator it = latency_components.begin(); + while (it != latency_components.end()) { + if (it->first.first == type) { + LatencyMap::iterator tmp = it; + ++it; + latency_components.erase(tmp); + } else { + it++; + } + } +} + void LatencyInfo::Clear() { latency_components.clear(); } diff --git a/ui/events/latency_info.h b/ui/events/latency_info.h index f0f89b7..ea3293c 100644 --- a/ui/events/latency_info.h +++ b/ui/events/latency_info.h @@ -107,6 +107,8 @@ struct EVENTS_BASE_EXPORT LatencyInfo { int64 id, LatencyComponent* output) const; + void RemoveLatency(LatencyComponentType type); + void Clear(); LatencyMap latency_components; |