Bug 1359697 - Make CaptivePortalService not poll for status when it is in the NOT_CAPTIVE state r=mcmanus a=lizzard
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 04 May 2017 11:43:25 +0200
changeset 393985 029eee8618cf6abc8ba9506f91fece92d070e5ea
parent 393984 a2a06bf22eaddd2d59da7c8a61e328f9587ca3cd
child 393986 779f28c6c7d5e7b4e9a49f902b4ae60294bc532d
push id7321
push usercbook@mozilla.com
push dateThu, 18 May 2017 06:45:08 +0000
treeherdermozilla-beta@0884adb687d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, lizzard
bugs1359697
milestone54.0
Bug 1359697 - Make CaptivePortalService not poll for status when it is in the NOT_CAPTIVE state r=mcmanus a=lizzard MozReview-Commit-ID: BrxJfipydEj
netwerk/base/CaptivePortalService.cpp
--- a/netwerk/base/CaptivePortalService.cpp
+++ b/netwerk/base/CaptivePortalService.cpp
@@ -80,16 +80,23 @@ CaptivePortalService::RearmTimer()
 {
   LOG(("CaptivePortalService::RearmTimer\n"));
   // Start a timer to recheck
   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
   if (mTimer) {
     mTimer->Cancel();
   }
 
+  // If we have successfully determined the state, and we have never detected
+  // a captive portal, we don't need to keep polling, but will rely on events
+  // to trigger detection.
+  if (mState == NOT_CAPTIVE) {
+    return NS_OK;
+  }
+
   if (!mTimer) {
     mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
   }
 
   if (mTimer && mDelay > 0) {
     LOG(("CaptivePortalService - Reloading timer with delay %u\n", mDelay));
     return mTimer->InitWithCallback(this, mDelay, nsITimer::TYPE_ONE_SHOT);
   }