Bug 1359697 - Make CaptivePortalService not poll for status when it is in the NOT_CAPTIVE state r=mcmanus
MozReview-Commit-ID: BrxJfipydEj
--- 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);
}