Bug 836872 - Use TimeStamp::NowLoRes() in nsAppShell, r=roc
authorHonza Bambas <honzab.moz@firemni.cz>
Mon, 11 Feb 2013 22:56:59 +0100
changeset 121548 cc3b4a2c1968a77daf04690167d8670d058be7a4
parent 121547 55ef31ba2298197993d75f2502bbaa430d9c334b
child 121549 0100ad335f92cc4db0e463fef9aea2905275e6d9
push id24296
push useremorley@mozilla.com
push dateTue, 12 Feb 2013 14:43:19 +0000
treeherdermozilla-central@860d7a47b675 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs836872
milestone21.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 836872 - Use TimeStamp::NowLoRes() in nsAppShell, r=roc
widget/windows/nsAppShell.cpp
widget/windows/nsAppShell.h
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -105,17 +105,17 @@ nsAppShell::~nsAppShell()
 
 nsresult
 nsAppShell::Init()
 {
 #ifdef MOZ_CRASHREPORTER
   LSPAnnotate();
 #endif
 
-  mLastNativeEventScheduled = TimeStamp::Now();
+  mLastNativeEventScheduled = TimeStamp::NowLoRes();
 
   if (!sMsgId)
     sMsgId = RegisterWindowMessageW(kAppShellEventId);
 
   sTaskbarButtonCreatedMsg = ::RegisterWindowMessageW(kTaskbarButtonEventId);
   NS_ASSERTION(sTaskbarButtonCreatedMsg, "Could not register taskbar button creation message");
 
   WNDCLASSW wc;
@@ -200,17 +200,17 @@ nsAppShell::DoProcessMoreGeckoEvents()
 
 void
 nsAppShell::ScheduleNativeEventCallback()
 {
   // Post a message to the hidden message window
   NS_ADDREF_THIS(); // will be released when the event is processed
   // Time stamp this event so we can detect cases where the event gets
   // dropping in sub classes / modal loops we do not control. 
-  mLastNativeEventScheduled = TimeStamp::Now();
+  mLastNativeEventScheduled = TimeStamp::NowLoRes();
   ::PostMessage(mEventWnd, sMsgId, 0, reinterpret_cast<LPARAM>(this));
 }
 
 bool
 nsAppShell::ProcessNextNativeEvent(bool mayWait)
 {
   // Notify ipc we are spinning a (possibly nested) gecko event loop.
   mozilla::ipc::RPCChannel::NotifyGeckoEventDispatch();
@@ -246,15 +246,18 @@ nsAppShell::ProcessNextNativeEvent(bool 
 
   // See DoProcessNextNativeEvent, mEventloopNestingLevel will be
   // one when a modal loop unwinds.
   if (mNativeCallbackPending && mEventloopNestingLevel == 1)
     DoProcessMoreGeckoEvents();
 
   // Check for starved native callbacks. If we haven't processed one
   // of these events in NATIVE_EVENT_STARVATION_LIMIT, fire one off.
-  if ((TimeStamp::Now() - mLastNativeEventScheduled) >
-      NATIVE_EVENT_STARVATION_LIMIT) {
+  static const mozilla::TimeDuration nativeEventStarvationLimit =
+    mozilla::TimeDuration::FromSeconds(NATIVE_EVENT_STARVATION_LIMIT);
+
+  if ((TimeStamp::NowLoRes() - mLastNativeEventScheduled) >
+      nativeEventStarvationLimit) {
     ScheduleNativeEventCallback();
   }
   
   return gotMessage;
 }
--- a/widget/windows/nsAppShell.h
+++ b/widget/windows/nsAppShell.h
@@ -5,18 +5,19 @@
 
 #ifndef nsAppShell_h__
 #define nsAppShell_h__
 
 #include "nsBaseAppShell.h"
 #include <windows.h>
 #include "mozilla/TimeStamp.h"
 
-// The maximum time we allow before forcing a native event callback
-#define NATIVE_EVENT_STARVATION_LIMIT mozilla::TimeDuration::FromSeconds(1)
+// The maximum time we allow before forcing a native event callback.
+// In seconds.
+#define NATIVE_EVENT_STARVATION_LIMIT 1
 
 /**
  * Native Win32 Application shell wrapper
  */
 class nsAppShell : public nsBaseAppShell
 {
 public:
   nsAppShell() :