Bug 655413 - Don't bump timer frequency in the IPC code. r=cjones
authorAnselmo Diaz <adbugz@mailinator.com>
Sun, 03 Jun 2012 08:09:28 +0200
changeset 101088 47e32a81f9dd58584165d324cf54323af733c5c2
parent 101087 d168da99e94727db6eb77a7810e00518457ed1d7
child 101089 c9491fa6ac54d92cbaae5e9854324930debeefb4
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs655413
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 655413 - Don't bump timer frequency in the IPC code. r=cjones
ipc/chromium/src/base/time_win.cc
--- a/ipc/chromium/src/base/time_win.cc
+++ b/ipc/chromium/src/base/time_win.cc
@@ -222,69 +222,38 @@ DWORD timeGetTimeWrapper() {
 
 DWORD (*tick_function)(void) = &timeGetTimeWrapper;
 
 // We use timeGetTime() to implement TimeTicks::Now().  This can be problematic
 // because it returns the number of milliseconds since Windows has started,
 // which will roll over the 32-bit value every ~49 days.  We try to track
 // rollover ourselves, which works if TimeTicks::Now() is called at least every
 // 49 days.
-class NowSingleton : public base::SystemMonitor::PowerObserver {
+class NowSingleton {
  public:
   NowSingleton()
     : rollover_(TimeDelta::FromMilliseconds(0)),
-      last_seen_(0),
-      hi_res_clock_enabled_(false) {
-    base::SystemMonitor* system = base::SystemMonitor::Get();
-    system->AddObserver(this);
-    UseHiResClock(!system->BatteryPower());
-  }
-
-  ~NowSingleton() {
-    UseHiResClock(false);
-    base::SystemMonitor* monitor = base::SystemMonitor::Get();
-    if (monitor)
-      monitor->RemoveObserver(this);
+      last_seen_(0) {
   }
 
   TimeDelta Now() {
     AutoLock locked(lock_);
     // We should hold the lock while calling tick_function to make sure that
     // we keep our last_seen_ stay correctly in sync.
     DWORD now = tick_function();
     if (now < last_seen_)
       rollover_ += TimeDelta::FromMilliseconds(GG_LONGLONG(0x100000000));  // ~49.7 days.
     last_seen_ = now;
     return TimeDelta::FromMilliseconds(now) + rollover_;
   }
 
-  // Interfaces for monitoring Power changes.
-  void OnPowerStateChange(base::SystemMonitor* system) {
-    UseHiResClock(!system->BatteryPower());
-  }
-
-  void OnSuspend(base::SystemMonitor* system) {}
-  void OnResume(base::SystemMonitor* system) {}
-
  private:
-  // Enable or disable the faster multimedia timer.
-  void UseHiResClock(bool enabled) {
-    if (enabled == hi_res_clock_enabled_)
-      return;
-    if (enabled)
-      timeBeginPeriod(1);
-    else
-      timeEndPeriod(1);
-    hi_res_clock_enabled_ = enabled;
-  }
-
   Lock lock_;  // To protected last_seen_ and rollover_.
   TimeDelta rollover_;  // Accumulation of time lost due to rollover.
   DWORD last_seen_;  // The last timeGetTime value we saw, to detect rollover.
-  bool hi_res_clock_enabled_;
 
   DISALLOW_COPY_AND_ASSIGN(NowSingleton);
 };
 
 // Overview of time counters:
 // (1) CPU cycle counter. (Retrieved via RDTSC)
 // The CPU counter provides the highest resolution time stamp and is the least
 // expensive to retrieve. However, the CPU counter is unreliable and should not