summaryrefslogtreecommitdiffstats
path: root/base/time_unittest.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_unittest.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_unittest.cc')
-rw-r--r--base/time_unittest.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/base/time_unittest.cc b/base/time_unittest.cc
index 43be492..5421ed1 100644
--- a/base/time_unittest.cc
+++ b/base/time_unittest.cc
@@ -479,6 +479,12 @@ TEST_F(TimeTest, ExplodeBeforeUnixEpoch) {
EXPECT_EQ(1, exploded.millisecond);
}
+TEST_F(TimeTest, Max) {
+ EXPECT_EQ(base::Time::Max(), base::Time::Max());
+ EXPECT_GT(base::Time::Max(), base::Time::Now());
+ EXPECT_GT(base::Time::Max(), base::Time());
+}
+
TEST(TimeTicks, Deltas) {
for (int index = 0; index < 50; index++) {
TimeTicks ticks_start = TimeTicks::Now();