diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-11 14:06:48 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-11 14:06:48 +0000 |
commit | 7903e0262e2dda44eaa186d126cf88e2cc1470eb (patch) | |
tree | a44957a8d1a49f0c590f797c0b36de8928bd5646 /base/time.cc | |
parent | 32346a04167c5abcc16fd92bea50ec232b68e87d (diff) | |
download | chromium_src-7903e0262e2dda44eaa186d126cf88e2cc1470eb.zip chromium_src-7903e0262e2dda44eaa186d126cf88e2cc1470eb.tar.gz chromium_src-7903e0262e2dda44eaa186d126cf88e2cc1470eb.tar.bz2 |
Don't use the Windows high-resolution Time::Now hacks on Posix, the normal resultion from the time APIs there should be enough.
Review URL: http://codereview.chromium.org/2420
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time.cc')
-rw-r--r-- | base/time.cc | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/base/time.cc b/base/time.cc index eeebdc1..38f732c 100644 --- a/base/time.cc +++ b/base/time.cc @@ -8,13 +8,6 @@ #include "base/logging.h" -namespace { - -// Time between resampling the un-granular clock for this API. 60 seconds. -const int kMaxMillisecondsToAvoidDrift = 60 * Time::kMillisecondsPerSecond; - -} // namespace - // TimeDelta ------------------------------------------------------------------ // static @@ -81,47 +74,6 @@ int64 TimeDelta::InMicroseconds() const { // Time ----------------------------------------------------------------------- -int64 Time::initial_time_ = 0; -TimeTicks Time::initial_ticks_; - -// static -void Time::InitializeClock() -{ - initial_ticks_ = TimeTicks::Now(); - initial_time_ = CurrentWallclockMicroseconds(); -} - -// static -Time Time::Now() { - if (initial_time_ == 0) - InitializeClock(); - - // We implement time using the high-resolution timers so that we can get - // timeouts which are smaller than 10-15ms. If we just used - // CurrentWallclockMicroseconds(), we'd have the less-granular timer. - // - // To make this work, we initialize the clock (initial_time) and the - // counter (initial_ctr). To compute the initial time, we can check - // the number of ticks that have elapsed, and compute the delta. - // - // To avoid any drift, we periodically resync the counters to the system - // clock. - while(true) { - TimeTicks ticks = TimeTicks::Now(); - - // Calculate the time elapsed since we started our timer - TimeDelta elapsed = ticks - initial_ticks_; - - // Check if enough time has elapsed that we need to resync the clock. - if (elapsed.InMilliseconds() > kMaxMillisecondsToAvoidDrift) { - InitializeClock(); - continue; - } - - return elapsed + initial_time_; - } -} - // static Time Time::FromTimeT(time_t tt) { if (tt == 0) |