From c2da8a30a39018aad2780e40170a9d93b7b4100d Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sun, 15 Oct 2017 23:12:54 -0700 Subject: [PATCH] Bug 1404198: Part 2d - Switch to NS_NewTimer* in widget. r=njn MozReview-Commit-ID: G4S8q9DYPS0 --HG-- extra : rebase_source : 9c6da05bf2ef3cfee551879879330a85688b1f5d --- widget/cocoa/TextInputHandler.mm | 2 +- widget/cocoa/nsMacDockSupport.mm | 4 ++-- widget/nsBaseWidget.cpp | 4 ++-- widget/nsIdleService.cpp | 7 +++---- widget/nsNativeTheme.cpp | 2 +- widget/windows/nsDataObj.cpp | 4 ++-- widget/windows/nsFilePicker.cpp | 13 ++++++------- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/widget/cocoa/TextInputHandler.mm b/widget/cocoa/TextInputHandler.mm index 550871cc9321..dfbc6bf162de 100644 --- a/widget/cocoa/TextInputHandler.mm +++ b/widget/cocoa/TextInputHandler.mm @@ -2916,7 +2916,7 @@ IMEInputHandler::ResetTimer() if (mTimer) { mTimer->Cancel(); } else { - mTimer = do_CreateInstance(NS_TIMER_CONTRACTID); + mTimer = NS_NewTimer(); NS_ENSURE_TRUE(mTimer, ); } mTimer->InitWithNamedFuncCallback(FlushPendingMethods, this, 0, diff --git a/widget/cocoa/nsMacDockSupport.mm b/widget/cocoa/nsMacDockSupport.mm index 616aae2c31b1..46c87f0554ef 100644 --- a/widget/cocoa/nsMacDockSupport.mm +++ b/widget/cocoa/nsMacDockSupport.mm @@ -17,7 +17,7 @@ nsMacDockSupport::nsMacDockSupport() , mProgressState(STATE_NO_PROGRESS) , mProgressFraction(0.0) { - mProgressTimer = do_CreateInstance(NS_TIMER_CONTRACTID); + mProgressTimer = NS_NewTimer(); } nsMacDockSupport::~nsMacDockSupport() @@ -133,7 +133,7 @@ bool nsMacDockSupport::InitProgress() } if (!mAppIcon) { - mProgressTimer = do_CreateInstance(NS_TIMER_CONTRACTID); + mProgressTimer = NS_NewTimer(); mAppIcon = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; mProgressBackground = [mAppIcon copyWithZone:nil]; mTheme = new nsNativeThemeCocoa(); diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 87173a6e6f01..d812369737ac 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1992,8 +1992,8 @@ nsIWidget::SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint, bool aLongTap, 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; diff --git a/widget/nsIdleService.cpp b/widget/nsIdleService.cpp index d2d9daf18447..e2abd5b392fa 100644 --- a/widget/nsIdleService.cpp +++ b/widget/nsIdleService.cpp @@ -154,7 +154,7 @@ nsIdleServiceDaily::Observe(nsISupports *, nsIdleServiceDaily::nsIdleServiceDaily(nsIIdleService* aIdleService) : mIdleService(aIdleService) - , mTimer(do_CreateInstance(NS_TIMER_CONTRACTID)) + , mTimer(NS_NewTimer()) , mCategoryObservers(OBSERVER_TOPIC_IDLE_DAILY) , mShutdownInProgress(false) , mExpectedTriggerTime(0) @@ -451,9 +451,8 @@ nsIdleService::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS) // 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 diff --git a/widget/nsNativeTheme.cpp b/widget/nsNativeTheme.cpp index 170ea5eaef95..cacafc060a24 100644 --- a/widget/nsNativeTheme.cpp +++ b/widget/nsNativeTheme.cpp @@ -636,7 +636,7 @@ nsNativeTheme::QueueAnimatedContentForRefresh(nsIContent* aContent, timeout = std::min(mAnimatedContentTimeout, timeout); if (!mAnimatedContentTimer) { - mAnimatedContentTimer = do_CreateInstance(NS_TIMER_CONTRACTID); + mAnimatedContentTimer = NS_NewTimer(); NS_ENSURE_TRUE(mAnimatedContentTimer, false); } diff --git a/widget/windows/nsDataObj.cpp b/widget/windows/nsDataObj.cpp index 7bdae045a894..2d06637f0e97 100755 --- a/widget/windows/nsDataObj.cpp +++ b/widget/windows/nsDataObj.cpp @@ -455,11 +455,11 @@ public: // 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 observerService = do_GetService("@mozilla.org/observer-service;1"); diff --git a/widget/windows/nsFilePicker.cpp b/widget/windows/nsFilePicker.cpp index 8926305253c7..da628ae88d21 100644 --- a/widget/windows/nsFilePicker.cpp +++ b/widget/windows/nsFilePicker.cpp @@ -159,16 +159,15 @@ private: 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 mPickerCallbackTimer; };