TimeDelta::FromDouble now uses saturated_cast
This change resolves the issue described in crbug.com/612601 (internal) by changing the existing ternary implementation of TimeDelta::FromDouble into a call to saturated_cast. Back in 2016, when TimeDelta::FromDouble's current control flow was written (https://crrev.com/1976703005), there was some concern about using saturated_cast here because TimeDelta's permitted values ranged from Max() to -Max() at the time. jyasskin implemented a safe version [1] that met the [-Max(), Max()] requirement, but it looks like the CL got lost somewhere before landing. As of February 2018 (crrev.com/c/539058), the internal value of TimeDelta can now range over all int64_t's, so the desired semantics of TimeDelta::FromDouble are now those of saturated_cast<int64_t>. [1] https://codereview.chromium.org/1976703005/diff/100001/base/time/time.h#newcode627 Test: Expanded time_unittest Bug: 612601 Change-Id: Id00bdad9e732a22f0765c228b65ac6d65aa8b3d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1830114Reviewed-by:Asanka Herath <asanka@chromium.org> Reviewed-by:
danakj <danakj@chromium.org> Commit-Queue: Asanka Herath <asanka@chromium.org> Commit-Queue: David Van Cleve <davidvc@chromium.org> Auto-Submit: David Van Cleve <davidvc@chromium.org> Cr-Commit-Position: refs/heads/master@{#701704}
Showing
Please register or sign in to comment