Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: base/time/time.h

Issue 179813009: Revert of Reland "Add base::TimeDelta::Max()" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/time/time.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time/time.h
diff --git a/base/time/time.h b/base/time/time.h
index 69a132431d6597514e44191a04db8bf461fb2c40..40566b92317a3c94ff183994a22c0029122fceb0 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -61,9 +61,9 @@
}
// Converts units of time to TimeDeltas.
- static TimeDelta FromDays(int days);
- static TimeDelta FromHours(int hours);
- static TimeDelta FromMinutes(int minutes);
+ static TimeDelta FromDays(int64 days);
+ static TimeDelta FromHours(int64 hours);
+ static TimeDelta FromMinutes(int64 minutes);
static TimeDelta FromSeconds(int64 secs);
static TimeDelta FromMilliseconds(int64 ms);
static TimeDelta FromMicroseconds(int64 us);
@@ -79,22 +79,12 @@
return TimeDelta(delta);
}
- // Returns the maximum time delta, which should be greater than any reasonable
- // time delta we might compare it to. Adding or subtracting the maximum time
- // delta to a time or another time delta has an undefined result.
- static TimeDelta Max();
-
// Returns the internal numeric value of the TimeDelta object. Please don't
// use this and do arithmetic on it, as it is more error prone than using the
// provided operators.
// For serializing, use FromInternalValue to reconstitute.
int64 ToInternalValue() const {
return delta_;
- }
-
- // Returns true if the time delta is the maximum time delta.
- bool is_max() const {
- return delta_ == std::numeric_limits<int64>::max();
}
#if defined(OS_POSIX)
@@ -503,50 +493,32 @@
// Inline the TimeDelta factory methods, for fast TimeDelta construction.
// static
-inline TimeDelta TimeDelta::FromDays(int days) {
- // Preserve max to prevent overflow.
- if (days == std::numeric_limits<int>::max())
- return Max();
+inline TimeDelta TimeDelta::FromDays(int64 days) {
return TimeDelta(days * Time::kMicrosecondsPerDay);
}
// static
-inline TimeDelta TimeDelta::FromHours(int hours) {
- // Preserve max to prevent overflow.
- if (hours == std::numeric_limits<int>::max())
- return Max();
+inline TimeDelta TimeDelta::FromHours(int64 hours) {
return TimeDelta(hours * Time::kMicrosecondsPerHour);
}
// static
-inline TimeDelta TimeDelta::FromMinutes(int minutes) {
- // Preserve max to prevent overflow.
- if (minutes == std::numeric_limits<int>::max())
- return Max();
+inline TimeDelta TimeDelta::FromMinutes(int64 minutes) {
return TimeDelta(minutes * Time::kMicrosecondsPerMinute);
}
// static
inline TimeDelta TimeDelta::FromSeconds(int64 secs) {
- // Preserve max to prevent overflow.
- if (secs == std::numeric_limits<int64>::max())
- return Max();
return TimeDelta(secs * Time::kMicrosecondsPerSecond);
}
// static
inline TimeDelta TimeDelta::FromMilliseconds(int64 ms) {
- // Preserve max to prevent overflow.
- if (ms == std::numeric_limits<int64>::max())
- return Max();
return TimeDelta(ms * Time::kMicrosecondsPerMillisecond);
}
// static
inline TimeDelta TimeDelta::FromMicroseconds(int64 us) {
- // Preserve max to prevent overflow.
- if (us == std::numeric_limits<int64>::max())
- return Max();
return TimeDelta(us);
}
« no previous file with comments | « no previous file | base/time/time.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698