summaryrefslogtreecommitdiffstats
path: root/base/time.cc
diff options
context:
space:
mode:
authormkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-27 18:44:03 +0000
committermkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-27 18:44:03 +0000
commitc462cafe30bcb6156ae04ecace86f6810539d18a (patch)
tree713bc7358957740825a420b4f3746ee4b9d6e58b /base/time.cc
parentfd9ba17a49852c34493ba87838e9b68c9606146e (diff)
downloadchromium_src-c462cafe30bcb6156ae04ecace86f6810539d18a.zip
chromium_src-c462cafe30bcb6156ae04ecace86f6810539d18a.tar.gz
chromium_src-c462cafe30bcb6156ae04ecace86f6810539d18a.tar.bz2
Add 'base::Time::Max()' to explicitly refer to the end of time.
BrowingDataRemover (and, I imagine, other systems) recognized ranges bounded by null Time objects ('base::Time()') as referring to "everything". That introduces easily-forgotten complexity, which leads to avoidable mistakes in logic. This CL provides a mechanism for avoiding this sort of confusion in the future by adding the ability to explicitly refer to the end of time via 'base::Time::Max()'. It simply returns a Time object whose internal counter is set to the maximum int64, which means that simple comparisons like 'time <= end' will do The Right Thing™. BUG=144972 Review URL: https://chromiumcodereview.appspot.com/10883061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time.cc')
-rw-r--r--base/time.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/base/time.cc b/base/time.cc
index f04ebbc..7055311 100644
--- a/base/time.cc
+++ b/base/time.cc
@@ -9,6 +9,8 @@
#include <float.h>
#endif
+#include <limits>
+
#include "base/sys_string_conversions.h"
#include "base/third_party/nspr/prtime.h"
@@ -64,6 +66,11 @@ int64 TimeDelta::InMicroseconds() const {
// Time -----------------------------------------------------------------------
// static
+Time Time::Max() {
+ return Time(std::numeric_limits<int64>::max());
+}
+
+// static
Time Time::FromTimeT(time_t tt) {
if (tt == 0)
return Time(); // Preserve 0 so we can tell it doesn't exist.