Commit 8315fdfa authored by Collin Baker's avatar Collin Baker Committed by Chromium LUCI CQ

Handle late OnSessionEnded() calls

A TouchModeChanged() call may happen just after a session ends, but
just before the associated OnSessionEnded() call. This caused a
DCHECK. Handle this case by ignoring it.

Fixed: 1165462
Change-Id: Id8c8a52acd94fef6a34a5349693af7caa9c570d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622529Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845287}
parent 202d44ec
...@@ -65,8 +65,14 @@ void TouchModeStatsTracker::OnSessionEnded(base::TimeDelta session_length, ...@@ -65,8 +65,14 @@ void TouchModeStatsTracker::OnSessionEnded(base::TimeDelta session_length,
base::TimeTicks session_end) { base::TimeTicks session_end) {
// If we end in touch mode, we must count the time from // If we end in touch mode, we must count the time from
// last_touch_mode_switch_in_session_ to session_end. // last_touch_mode_switch_in_session_ to session_end.
if (touch_ui_controller_->touch_ui()) { //
DCHECK_GE(session_end, last_touch_mode_switch_in_session_); // |session_end| may be slightly less than
// |last_touch_mode_switch_in_session_| because an OnSessionEnded()
// call may happen slightly after the session end time. Assuming the
// difference is small, the touch mode time left unaccounted for is small.
// Accept this error and ignore this time. See crbug.com/1165462.
if (touch_ui_controller_->touch_ui() &&
session_end >= last_touch_mode_switch_in_session_) {
touch_mode_duration_in_session_ += touch_mode_duration_in_session_ +=
session_end - last_touch_mode_switch_in_session_; session_end - last_touch_mode_switch_in_session_;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment