Bug 1359697 - Make CaptivePortalService not poll for status when it is in the NOT_CAPTIVE state r=mcmanus a=lizzard FIREFOX_53_0_3_BUILD1 FIREFOX_53_0_3_RELEASE
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 04 May 2017 11:43:25 +0200
changeset 595768 1fe643b3421a27640a61a3b2b8b0986c7234e314
parent 595767 4fba047d14bc02d62bf1fd5a83e7a03686960ddb
child 595769 efb2b9c1a185f8703d1b38b49c2b3debdeb598f7
push id64447
push usermozilla@kaply.com
push dateFri, 16 Jun 2017 21:19:48 +0000
reviewersmcmanus, lizzard
bugs1359697
milestone53.0.3
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);
   }