Bug 1359697 - Make CaptivePortalService not poll for status when it is in the NOT_CAPTIVE state r=mcmanus draft
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 04 May 2017 11:43:25 +0200
changeset 572559 780f49bd3b6dcf0682f9368c53c0a04c03e0616b
parent 572425 4a6a71f4aa22e4dc3961884ce505ce34bdd799a2
child 627056 00a0611a11c032caf0ccc91f67a59149ba214d3e
push id57111
push uservalentin.gosu@gmail.com
push dateThu, 04 May 2017 09:45:07 +0000
reviewersmcmanus
bugs1359697
milestone55.0a1
Bug 1359697 - Make CaptivePortalService not poll for status when it is in the NOT_CAPTIVE state r=mcmanus 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);
   }