| Index: base/time/time.h
|
| diff --git a/base/time/time.h b/base/time/time.h
|
| index 286c0738ceb4522f791a9d9cd4ac1c67f2472ae2..1084e9517942f83c6a1a1b2831147ec648384a50 100644
|
| --- a/base/time/time.h
|
| +++ b/base/time/time.h
|
| @@ -95,10 +95,6 @@ namespace time_internal {
|
| BASE_EXPORT int64_t SaturatedAdd(TimeDelta delta, int64_t value);
|
| BASE_EXPORT int64_t SaturatedSub(TimeDelta delta, int64_t value);
|
|
|
| -// Clamp |value| on overflow and underflow conditions. The int64_t argument and
|
| -// return value are in terms of a microsecond timebase.
|
| -BASE_EXPORT int64_t FromCheckedNumeric(const CheckedNumeric<int64_t> value);
|
| -
|
| } // namespace time_internal
|
|
|
| // TimeDelta ------------------------------------------------------------------
|
| @@ -205,13 +201,24 @@ class BASE_EXPORT TimeDelta {
|
| TimeDelta operator*(T a) const {
|
| CheckedNumeric<int64_t> rv(delta_);
|
| rv *= a;
|
| - return TimeDelta(time_internal::FromCheckedNumeric(rv));
|
| + if (rv.IsValid())
|
| + return TimeDelta(rv.ValueOrDie());
|
| + // Matched sign overflows. Mismatched sign underflows.
|
| + if ((delta_ < 0) ^ (a < 0))
|
| + return TimeDelta(-std::numeric_limits<int64_t>::max());
|
| + return TimeDelta(std::numeric_limits<int64_t>::max());
|
| }
|
| template<typename T>
|
| TimeDelta operator/(T a) const {
|
| CheckedNumeric<int64_t> rv(delta_);
|
| rv /= a;
|
| - return TimeDelta(time_internal::FromCheckedNumeric(rv));
|
| + if (rv.IsValid())
|
| + return TimeDelta(rv.ValueOrDie());
|
| + // Matched sign overflows. Mismatched sign underflows.
|
| + // Special case to catch divide by zero.
|
| + if ((delta_ < 0) ^ (a <= 0))
|
| + return TimeDelta(-std::numeric_limits<int64_t>::max());
|
| + return TimeDelta(std::numeric_limits<int64_t>::max());
|
| }
|
| template<typename T>
|
| TimeDelta& operator*=(T a) {
|
|
|