summaryrefslogtreecommitdiffstats
path: root/base/test
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 01:51:17 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 01:51:17 +0000
commit014eb20106c8a775ebbd4c8bc258c1c42f59c928 (patch)
tree55040e433f1e88fc3ffff60a3e3e87e3cf2293c5 /base/test
parentafe9c6243f27d8f7adea756b559ab750daee900e (diff)
downloadchromium_src-014eb20106c8a775ebbd4c8bc258c1c42f59c928.zip
chromium_src-014eb20106c8a775ebbd4c8bc258c1c42f59c928.tar.gz
chromium_src-014eb20106c8a775ebbd4c8bc258c1c42f59c928.tar.bz2
Make chrome/browser/extensions use base::Clock instead of MockTimeProvider
Also replace a few instances of ad-hoc test clocks. Improve SimpleTest{,Tick}Clock a bit. BUG=166469 Review URL: https://chromiumcodereview.appspot.com/12314056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184552 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r--base/test/simple_test_clock.cc5
-rw-r--r--base/test/simple_test_clock.h8
-rw-r--r--base/test/simple_test_tick_clock.h5
3 files changed, 12 insertions, 6 deletions
diff --git a/base/test/simple_test_clock.cc b/base/test/simple_test_clock.cc
index 3bd6080..a2bdc2a 100644
--- a/base/test/simple_test_clock.cc
+++ b/base/test/simple_test_clock.cc
@@ -20,4 +20,9 @@ void SimpleTestClock::Advance(TimeDelta delta) {
now_ += delta;
}
+void SimpleTestClock::SetNow(Time now) {
+ AutoLock lock(lock_);
+ now_ = now;
+}
+
} // namespace base
diff --git a/base/test/simple_test_clock.h b/base/test/simple_test_clock.h
index a83312f..f96dabf 100644
--- a/base/test/simple_test_clock.h
+++ b/base/test/simple_test_clock.h
@@ -13,7 +13,7 @@
namespace base {
// SimpleTestClock is a Clock implementation that gives control over
-// the returned Time objects. All methods can be called from any
+// the returned Time objects. All methods may be called from any
// thread.
class SimpleTestClock : public Clock {
public:
@@ -23,10 +23,12 @@ class SimpleTestClock : public Clock {
virtual Time Now() OVERRIDE;
- // Sets the current time forward by |delta|. Safe to call from any
- // thread.
+ // Advances the clock by |delta|.
void Advance(TimeDelta delta);
+ // Sets the clock to the given time.
+ void SetNow(Time now);
+
private:
// Protects |now_|.
Lock lock_;
diff --git a/base/test/simple_test_tick_clock.h b/base/test/simple_test_tick_clock.h
index c53301b..2809774 100644
--- a/base/test/simple_test_tick_clock.h
+++ b/base/test/simple_test_tick_clock.h
@@ -13,7 +13,7 @@
namespace base {
// SimpleTestTickClock is a TickClock implementation that gives
-// control over the returned TimeTicks objects. All methods can be
+// control over the returned TimeTicks objects. All methods may be
// called from any thread.
class SimpleTestTickClock : public TickClock {
public:
@@ -23,8 +23,7 @@ class SimpleTestTickClock : public TickClock {
virtual TimeTicks NowTicks() OVERRIDE;
- // Sets the current time forward by |delta|. Safe to call from any
- // thread.
+ // Advances the clock by |delta|, which must not be negative.
void Advance(TimeDelta delta);
private: