Bug 1360328 - Dispatch a runnable to RecheckCaptivePortal instead of calling it immediately r=mcmanus
MozReview-Commit-ID: HUPJUtho7g8
--- 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,