Bug 1360328 - Dispatch a runnable to RecheckCaptivePortal instead of calling it immediately r=mcmanus draft
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 08 May 2017 13:19:40 +0200
changeset 574181 7e3d9c787569352a598e0efe3393a3d9c14a637a
parent 574065 1fda52a1f3b81cf1a821155998dca637bb64e3d9
child 575381 9954c780930862a4c445c3277c2e892151e47cd3
push id57596
push uservalentin.gosu@gmail.com
push dateMon, 08 May 2017 11:20:13 +0000
reviewersmcmanus
bugs1360328
milestone55.0a1
Bug 1360328 - Dispatch a runnable to RecheckCaptivePortal instead of calling it immediately r=mcmanus MozReview-Commit-ID: HUPJUtho7g8
netwerk/base/nsIOService.cpp
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -364,20 +364,24 @@ NS_IMPL_ISUPPORTS(nsIOService,
                   nsISupportsWeakReference)
 
 ////////////////////////////////////////////////////////////////////////////////
 
 nsresult
 nsIOService::RecheckCaptivePortal()
 {
   MOZ_ASSERT(NS_IsMainThread(), "Must be called on the main thread");
-  if (mCaptivePortalService) {
-    mCaptivePortalService->RecheckCaptivePortal();
+  if (!mCaptivePortalService) {
+    return NS_OK;
   }
-  return NS_OK;
+  nsCOMPtr<nsIRunnable> task =
+    NewRunnableMethod("nsIOService::RecheckCaptivePortal",
+                      mCaptivePortalService,
+                      &nsICaptivePortalService::RecheckCaptivePortal);
+  return NS_DispatchToMainThread(task);
 }
 
 nsresult
 nsIOService::RecheckCaptivePortalIfLocalRedirect(nsIChannel* newChan)
 {
     nsresult rv;
 
     if (!mCaptivePortalService) {
@@ -402,17 +406,17 @@ nsIOService::RecheckCaptivePortalIfLocal
         // to trigger the captive portal detection right now. It can wait.
         return NS_OK;
     }
 
     NetAddr netAddr;
     PRNetAddrToNetAddr(&prAddr, &netAddr);
     if (IsIPAddrLocal(&netAddr)) {
         // Redirects to local IP addresses are probably captive portals
-        mCaptivePortalService->RecheckCaptivePortal();
+        RecheckCaptivePortal();
     }
 
     return NS_OK;
 }
 
 nsresult
 nsIOService::AsyncOnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan,
                                     uint32_t flags,