Bug 1404198: Part 2d - Switch to NS_NewTimer* in widget. r=njn
authorKris Maglione <maglione.k@gmail.com>
Sun, 15 Oct 2017 23:12:54 -0700
changeset 386548 e7c3876d6d2f31f137dd9d62c870ed6320963770
parent 386547 fa53cb4191939e1d66446f5e45175e0079197082
child 386549 474d24f4545fb096b91a6eafec3b76e528ef1092
push id32695
push userarchaeopteryx@coole-files.de
push dateTue, 17 Oct 2017 09:45:44 +0000
treeherdermozilla-central@0d9c6250f99d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1404198
milestone58.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 1404198: Part 2d - Switch to NS_NewTimer* in widget. r=njn MozReview-Commit-ID: G4S8q9DYPS0
widget/cocoa/TextInputHandler.mm
widget/cocoa/nsMacDockSupport.mm
widget/nsBaseWidget.cpp
widget/nsIdleService.cpp
widget/nsNativeTheme.cpp
widget/windows/nsDataObj.cpp
widget/windows/nsFilePicker.cpp
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -2911,17 +2911,17 @@ IMEInputHandler::SyncASCIICapableOnly()
 void
 IMEInputHandler::ResetTimer()
 {
   NS_ASSERTION(mPendingMethods != 0,
                "There are not pending methods, why this is called?");
   if (mTimer) {
     mTimer->Cancel();
   } else {
-    mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
+    mTimer = NS_NewTimer();
     NS_ENSURE_TRUE(mTimer, );
   }
   mTimer->InitWithNamedFuncCallback(FlushPendingMethods, this, 0,
                                     nsITimer::TYPE_ONE_SHOT,
                                     "IMEInputHandler::FlushPendingMethods");
 }
 
 void
--- a/widget/cocoa/nsMacDockSupport.mm
+++ b/widget/cocoa/nsMacDockSupport.mm
@@ -12,17 +12,17 @@
 NS_IMPL_ISUPPORTS(nsMacDockSupport, nsIMacDockSupport, nsITaskbarProgress)
 
 nsMacDockSupport::nsMacDockSupport()
 : mAppIcon(nil)
 , mProgressBackground(nil)
 , mProgressState(STATE_NO_PROGRESS)
 , mProgressFraction(0.0)
 {
-  mProgressTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
+  mProgressTimer = NS_NewTimer();
 }
 
 nsMacDockSupport::~nsMacDockSupport()
 {
   if (mAppIcon) {
     [mAppIcon release];
     mAppIcon = nil;
   }
@@ -128,17 +128,17 @@ void nsMacDockSupport::RedrawIconCallbac
 // Return whether to draw progress
 bool nsMacDockSupport::InitProgress()
 {
   if (mProgressState != STATE_NORMAL && mProgressState != STATE_INDETERMINATE) {
     return false;
   }
 
   if (!mAppIcon) {
-    mProgressTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
+    mProgressTimer = NS_NewTimer();
     mAppIcon = [[NSImage imageNamed:@"NSApplicationIcon"] retain];
     mProgressBackground = [mAppIcon copyWithZone:nil];
     mTheme = new nsNativeThemeCocoa();
 
     NSSize sz = [mProgressBackground size];
     mProgressBounds = CGRectMake(sz.width * 1/32, sz.height * 3/32,
                                  sz.width * 30/32, sz.height * 4/32);
     [mProgressBackground lockFocus];
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1987,18 +1987,18 @@ nsIWidget::SynthesizeNativeTouchTap(Layo
     return SynthesizeNativeTouchPoint(pointerId, TOUCH_REMOVE,
                                       aPoint, 0, 0, nullptr);
   }
 
   // initiate a long tap
   int elapse = Preferences::GetInt("ui.click_hold_context_menus.delay",
                                    TOUCH_INJECT_LONG_TAP_DEFAULT_MSEC);
   if (!mLongTapTimer) {
-    mLongTapTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
-    if (NS_FAILED(rv)) {
+    mLongTapTimer = NS_NewTimer();
+    if (!mLongTapTimer) {
       SynthesizeNativeTouchPoint(pointerId, TOUCH_CANCEL,
                                  aPoint, 0, 0, nullptr);
       return NS_ERROR_UNEXPECTED;
     }
     // Windows requires recuring events, so we set this to a smaller window
     // than the pref value.
     int timeout = elapse;
     if (timeout > TOUCH_INJECT_PUMP_TIMER_MSEC) {
--- a/widget/nsIdleService.cpp
+++ b/widget/nsIdleService.cpp
@@ -149,17 +149,17 @@ nsIdleServiceDaily::Observe(nsISupports 
                                           nsITimer::TYPE_ONE_SHOT,
                                           "nsIdleServiceDaily::Observe");
 
   return NS_OK;
 }
 
 nsIdleServiceDaily::nsIdleServiceDaily(nsIIdleService* aIdleService)
   : mIdleService(aIdleService)
-  , mTimer(do_CreateInstance(NS_TIMER_CONTRACTID))
+  , mTimer(NS_NewTimer())
   , mCategoryObservers(OBSERVER_TOPIC_IDLE_DAILY)
   , mShutdownInProgress(false)
   , mExpectedTriggerTime(0)
   , mIdleDailyTriggerWait(DAILY_SIGNIFICANT_IDLE_SERVICE_SEC)
 {
 }
 
 void
@@ -446,19 +446,18 @@ nsIdleService::AddIdleObserver(nsIObserv
   IdleListener listener(aObserver, aIdleTimeInS);
 
   if (!mArrayListeners.AppendElement(listener)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   // Create our timer callback if it's not there already.
   if (!mTimer) {
-    nsresult rv;
-    mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    mTimer = NS_NewTimer();
+    NS_ENSURE_TRUE(mTimer, NS_ERROR_OUT_OF_MEMORY);
   }
 
   // Check if the newly added observer has a smaller wait time than what we
   // are waiting for now.
   if (mDeltaToNextIdleSwitchInS > aIdleTimeInS) {
     // If it is, then this is the next to move to idle (at this point we
     // don't care if it should have switched already).
     MOZ_LOG(sLog, LogLevel::Debug,
--- a/widget/nsNativeTheme.cpp
+++ b/widget/nsNativeTheme.cpp
@@ -631,17 +631,17 @@ nsNativeTheme::QueueAnimatedContentForRe
   NS_ASSERTION(aMinimumFrameRate, "aMinimumFrameRate must be non-zero!");
   NS_ASSERTION(aMinimumFrameRate <= 1000,
                "aMinimumFrameRate must be less than 1000!");
 
   uint32_t timeout = 1000 / aMinimumFrameRate;
   timeout = std::min(mAnimatedContentTimeout, timeout);
 
   if (!mAnimatedContentTimer) {
-    mAnimatedContentTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
+    mAnimatedContentTimer = NS_NewTimer();
     NS_ENSURE_TRUE(mAnimatedContentTimer, false);
   }
 
   if (mAnimatedContentList.IsEmpty() || timeout != mAnimatedContentTimeout) {
     nsresult rv;
     if (!mAnimatedContentList.IsEmpty()) {
       rv = mAnimatedContentTimer->Cancel();
       NS_ENSURE_SUCCESS(rv, false);
--- a/widget/windows/nsDataObj.cpp
+++ b/widget/windows/nsDataObj.cpp
@@ -450,21 +450,21 @@ public:
 
   // The attach method is seperate from the constructor as we may be addref-ing
   // ourself, and we want to be sure someone has a strong reference to us.
   void Attach()
   {
     // We need to listen to both the xpcom shutdown message and our timer, and
     // fire when the first of either of these two messages is received.
     nsresult rv;
-    mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
+    rv = NS_NewTimerWithObserver(getter_AddRefs(mTimer),
+                                 this, 500, nsITimer::TYPE_ONE_SHOT);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return;
     }
-    mTimer->Init(this, 500, nsITimer::TYPE_ONE_SHOT);
 
     nsCOMPtr<nsIObserverService> observerService =
       do_GetService("@mozilla.org/observer-service;1");
     if (NS_WARN_IF(!observerService)) {
       mTimer->Cancel();
       mTimer = nullptr;
       return;
     }
--- a/widget/windows/nsFilePicker.cpp
+++ b/widget/windows/nsFilePicker.cpp
@@ -154,26 +154,25 @@ public:
     }
   }
 
 private:
   void Init(nsFilePicker* aTarget,
             nsTimerCallbackFunc aCallbackFunc,
             const char* aName)
   {
-    mPickerCallbackTimer = do_CreateInstance("@mozilla.org/timer;1");
+    NS_NewTimerWithFuncCallback(getter_AddRefs(mPickerCallbackTimer),
+                                aCallbackFunc,
+                                aTarget,
+                                kDialogTimerTimeout,
+                                nsITimer::TYPE_REPEATING_SLACK,
+                                aName);
     if (!mPickerCallbackTimer) {
       NS_WARNING("do_CreateInstance for timer failed??");
-      return;
     }
-    mPickerCallbackTimer->InitWithNamedFuncCallback(aCallbackFunc,
-                                                    aTarget,
-                                                    kDialogTimerTimeout,
-                                                    nsITimer::TYPE_REPEATING_SLACK,
-                                                    aName);
   }
   nsCOMPtr<nsITimer> mPickerCallbackTimer;
 };
 
 ///////////////////////////////////////////////////////////////////////////////
 // nsIFilePicker
 
 nsFilePicker::nsFilePicker() :