This commit is contained in:
Cameron Kaiser 2017-05-06 17:12:54 -07:00
parent 8e58b5c8fb
commit 8d665811de
2 changed files with 19 additions and 0 deletions

View File

@ -144,6 +144,9 @@
#include "nsComputedDOMStyle.h"
#include "mozilla/Preferences.h"
#include "nsIIOService.h"
#include "nsISpeculativeConnect.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -2991,6 +2994,15 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor)
EventStateManager::SetActiveManager(
aVisitor.mPresContext->EventStateManager(), this);
// OK, we're pretty sure we're going to load, so warm up a speculative
// connection to be sure we have one ready when we open the channel.
nsCOMPtr<nsISpeculativeConnect>
speculator(do_QueryInterface(nsContentUtils::GetIOService()));
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(handler);
// We need bug 1304219 for this part, but this will suffice for now.
//speculator->SpeculativeConnect2(absURI, NodePrincipal(), ir);
speculator->SpeculativeConnect(absURI, ir);
}
}
}

View File

@ -1836,6 +1836,13 @@ nsIOService::SpeculativeConnectInternal(nsIURI *aURI,
nsIInterfaceRequestor *aCallbacks,
bool aAnonymous)
{
bool isHTTP, isHTTPS;
if (!(NS_SUCCEEDED(aURI->SchemeIs("http", &isHTTP)) && isHTTP) &&
!(NS_SUCCEEDED(aURI->SchemeIs("https", &isHTTPS)) && isHTTPS)) {
// We don't speculatively connect to non-HTTP[S] URIs.
return NS_OK;
}
// Check for proxy information. If there is a proxy configured then a
// speculative connect should not be performed because the potential
// reward is slim with tcp peers closely located to the browser.