Bug 1404198: Part 2h - Switch to NS_NewTimer* in gfx. r=njn
authorKris Maglione <maglione.k@gmail.com>
Sun, 15 Oct 2017 23:15:12 -0700
changeset 386361 247d3966c7ac1220c39a86b31b8a98bfbc4895fe
parent 386360 71117dd0686c940af0e41834895c86a5abf1cc4d
child 386362 e405a4ec473c3d510047fff16599a5f73a8d600b
push id96230
push usermaglione.k@gmail.com
push dateMon, 16 Oct 2017 20:44:15 +0000
treeherdermozilla-inbound@33b50e696014 [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 2h - Switch to NS_NewTimer* in gfx. r=njn MozReview-Commit-ID: 3EUyHzdkbqH
gfx/layers/apz/util/APZEventState.cpp
gfx/layers/client/TextureClientPool.cpp
gfx/thebes/gfxFcPlatformFontList.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFontInfoLoader.cpp
gfx/thebes/gfxPlatformMac.cpp
--- a/gfx/layers/apz/util/APZEventState.cpp
+++ b/gfx/layers/apz/util/APZEventState.cpp
@@ -202,17 +202,17 @@ APZEventState::ProcessSingleTap(const CS
 
   if (mTouchEndCancelled) {
     return;
   }
 
   LayoutDevicePoint ldPoint = aPoint * aScale;
 
   APZES_LOG("Scheduling timer for click event\n");
-  nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
+  nsCOMPtr<nsITimer> timer = NS_NewTimer();
   dom::TabChild* tabChild = widget->GetOwningTabChild();
 
   if (tabChild && XRE_IsContentProcess()) {
     timer->SetTarget(
       tabChild->TabGroup()->EventTargetFor(TaskCategory::Other));
   }
   RefPtr<DelayedFireSingleTapEvent> callback =
     new DelayedFireSingleTapEvent(mWidget, ldPoint, aModifiers, aClickCount,
--- a/gfx/layers/client/TextureClientPool.cpp
+++ b/gfx/layers/client/TextureClientPool.cpp
@@ -57,18 +57,18 @@ TextureClientPool::TextureClientPool(Lay
   , mInitialPoolSize(aInitialPoolSize)
   , mPoolUnusedSize(aPoolUnusedSize)
   , mOutstandingClients(0)
   , mSurfaceAllocator(aAllocator)
   , mDestroyed(false)
 {
   TCP_LOG("TexturePool %p created with maximum unused texture clients %u\n",
       this, mInitialPoolSize);
-  mShrinkTimer = do_CreateInstance("@mozilla.org/timer;1");
-  mClearTimer = do_CreateInstance("@mozilla.org/timer;1");
+  mShrinkTimer = NS_NewTimer();
+  mClearTimer = NS_NewTimer();
   if (aFormat == gfx::SurfaceFormat::UNKNOWN) {
     gfxWarning() << "Creating texture pool for SurfaceFormat::UNKNOWN format";
   }
 }
 
 TextureClientPool::~TextureClientPool()
 {
   mShrinkTimer->Cancel();
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -1245,25 +1245,23 @@ gfxFcPlatformFontList::gfxFcPlatformFont
     , mFcSubstituteCache(64)
     , mLastConfig(nullptr)
     , mAlwaysUseFontconfigGenerics(true)
 {
     // if the rescan interval is set, start the timer
     int rescanInterval = FcConfigGetRescanInterval(nullptr);
     if (rescanInterval) {
         mLastConfig = FcConfigGetCurrent();
-        mCheckFontUpdatesTimer = do_CreateInstance("@mozilla.org/timer;1");
-        if (mCheckFontUpdatesTimer) {
-          mCheckFontUpdatesTimer->InitWithNamedFuncCallback(
-            CheckFontUpdates,
-            this,
-            (rescanInterval + 1) * 1000,
-            nsITimer::TYPE_REPEATING_SLACK,
-            "gfxFcPlatformFontList::gfxFcPlatformFontList");
-        } else {
+        NS_NewTimerWithFuncCallback(getter_AddRefs(mCheckFontUpdatesTimer),
+                                    CheckFontUpdates,
+                                    this,
+                                    (rescanInterval + 1) * 1000,
+                                    nsITimer::TYPE_REPEATING_SLACK,
+                                    "gfxFcPlatformFontList::gfxFcPlatformFontList");
+        if (!mCheckFontUpdatesTimer) {
             NS_WARNING("Failure to create font updates timer");
         }
     }
 
 #ifdef MOZ_BUNDLED_FONTS
     mBundledFontsInitialized = false;
 #endif
 }
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -179,28 +179,27 @@ gfxFontCache::gfxFontCache(nsIEventTarge
     nsCOMPtr<nsIObserverService> obs = GetObserverService();
     if (obs) {
         obs->AddObserver(new Observer, "memory-pressure", false);
     }
 
 #ifndef RELEASE_OR_BETA
     // Currently disabled for release builds, due to unexplained crashes
     // during expiration; see bug 717175 & 894798.
-    mWordCacheExpirationTimer = do_CreateInstance("@mozilla.org/timer;1");
-    if (mWordCacheExpirationTimer) {
-        if (XRE_IsContentProcess() && NS_IsMainThread()) {
-            mWordCacheExpirationTimer->SetTarget(aEventTarget);
-        }
-        mWordCacheExpirationTimer->InitWithNamedFuncCallback(
-          WordCacheExpirationTimerCallback,
-          this,
-          SHAPED_WORD_TIMEOUT_SECONDS * 1000,
-          nsITimer::TYPE_REPEATING_SLACK,
-          "gfxFontCache::gfxFontCache");
+    nsIEventTarget* target = nullptr;
+    if (XRE_IsContentProcess() && NS_IsMainThread()) {
+      target = aEventTarget;
     }
+    NS_NewTimerWithFuncCallback(getter_AddRefs(mWordCacheExpirationTimer),
+                                WordCacheExpirationTimerCallback,
+                                this,
+                                SHAPED_WORD_TIMEOUT_SECONDS * 1000,
+                                nsITimer::TYPE_REPEATING_SLACK,
+                                "gfxFontCache::gfxFontCache",
+                                target);
 #endif
 }
 
 gfxFontCache::~gfxFontCache()
 {
     // Ensure the user font cache releases its references to font entries,
     // so they aren't kept alive after the font instances and font-list
     // have been shut down.
--- a/gfx/thebes/gfxFontInfoLoader.cpp
+++ b/gfx/thebes/gfxFontInfoLoader.cpp
@@ -147,17 +147,17 @@ gfxFontInfoLoader::StartLoader(uint32_t 
     if (mState != stateInitial &&
         mState != stateTimerOff &&
         mState != stateTimerOnDelay) {
         CancelLoader();
     }
 
     // set up timer
     if (!mTimer) {
-        mTimer = do_CreateInstance("@mozilla.org/timer;1");
+        mTimer = NS_NewTimer();
         if (!mTimer) {
             NS_WARNING("Failure to create font info loader timer");
             return;
         }
     }
 
     AddShutdownObserver();
 
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -394,17 +394,17 @@ public:
 
   class OSXDisplay final : public VsyncSource::Display
   {
   public:
     OSXDisplay()
       : mDisplayLink(nullptr)
     {
       MOZ_ASSERT(NS_IsMainThread());
-      mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
+      mTimer = NS_NewTimer();
     }
 
     ~OSXDisplay() override
     {
       MOZ_ASSERT(NS_IsMainThread());
     }
 
     static void RetryEnableVsync(nsITimer* aTimer, void* aOsxDisplay)