Clean up compatibility code for last_active_time
This code has been here for one year now. It is time to remove it. It was added in http://crrev.com/c/5071355. Fixed: 40946710 Change-Id: Ic2aef138b5709dbe6da441f24472c2c86f7d7abc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6175029 Reviewed-by: Stefan Kuhne <skuhne@chromium.org> Reviewed-by: Marc Treib <treib@chromium.org> Auto-Submit: Gauthier Ambard <gambard@chromium.org> Commit-Queue: Stefan Kuhne <skuhne@chromium.org> Cr-Commit-Position: refs/heads/main@{#1406812}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
9698c72c4f
commit
f0f11392a4
@ -171,13 +171,6 @@ enum PersistedWindowShowState {
|
||||
PERSISTED_SHOW_STATE_END = 8,
|
||||
};
|
||||
|
||||
// TODO(crbug.com/40946710): Remove this around December 2024. This is part of a
|
||||
// workaround added to support the transition from storing the last_active_time
|
||||
// as TimeTicks to Time that was added in December 2023. This is the threshold
|
||||
// at which we consider that if a tab is so far in the past, it must be a tab
|
||||
// serialized with TimeTicks and not Time.
|
||||
const base::TimeDelta kLastActiveWorkaroundThreshold = base::Days(366 * 15);
|
||||
|
||||
// Assert to ensure PersistedWindowShowState is updated if ui::WindowShowState
|
||||
// is changed.
|
||||
// TODO(crbug.com/361560784): Investigate and Remove `kEnd`
|
||||
@ -802,33 +795,8 @@ void CreateTabsAndWindows(
|
||||
}
|
||||
SessionTab* tab =
|
||||
GetTab(SessionID::FromSerializedValue(payload.tab_id), tabs);
|
||||
base::Time deserialized_time = base::Time::FromDeltaSinceWindowsEpoch(
|
||||
tab->last_active_time = base::Time::FromDeltaSinceWindowsEpoch(
|
||||
base::Microseconds(payload.last_active_time));
|
||||
|
||||
if (base::Time::Now() - deserialized_time >
|
||||
kLastActiveWorkaroundThreshold) {
|
||||
// TODO(crbug.com/40946710): Remove this once enough time has passed
|
||||
// (added in December 2023, can be removed after ~1 year). This is a
|
||||
// workaround put in place during the migration from base::TimeTicks
|
||||
// internal representation to microseconds since Windows epoch. As the
|
||||
// origin point may be vastely different, the values stored in the old
|
||||
// format appear as really old when deserialized in the new format. So
|
||||
// checking all value older than 15 years should be a good enough
|
||||
// filter to catch them. If it is a value stored in the old format, it
|
||||
// should be correctly decoded.
|
||||
base::TimeTicks time_tick_value =
|
||||
base::TimeTicks::FromInternalValue(payload.last_active_time);
|
||||
base::TimeDelta delta_since_epoch =
|
||||
time_tick_value - base::TimeTicks::UnixEpoch();
|
||||
base::Time corrected_time =
|
||||
base::Time::UnixEpoch() + delta_since_epoch;
|
||||
if (base::Time::Now() < corrected_time) {
|
||||
// If the correction is giving a time in the future, set it to now.
|
||||
corrected_time = base::Time::Now();
|
||||
}
|
||||
deserialized_time = corrected_time;
|
||||
}
|
||||
tab->last_active_time = deserialized_time;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user