Bug 1304219 - Part 2: Update speculativeConnect() to speculativeConnect2() for Necko. r=hurley
authorTim Huang <tihuang@mozilla.com>
Wed, 26 Oct 2016 11:14:41 +0800
changeset 347973 89c941e929e33f40e380f20e20058bd962d1c299
parent 347972 b03f99accc585b2c850307398cc2500028e6bd8e
child 347974 a8a2dc984ce6fa927f259927f23cb008bd7a3957
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershurley
bugs1304219
milestone52.0a1
Bug 1304219 - Part 2: Update speculativeConnect() to speculativeConnect2() for Necko. r=hurley
netwerk/base/Predictor.cpp
netwerk/base/nsIOService.cpp
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -967,17 +967,17 @@ Predictor::PredictForLink(nsIURI *target
     sourceURI->SchemeIs("https", &isSSL);
     if (isSSL) {
       // We don't want to predict from an HTTPS page, to avoid info leakage
       PREDICTOR_LOG(("    Not predicting for link hover - on an SSL page"));
       return;
     }
   }
 
-  mSpeculativeService->SpeculativeConnect(targetURI, nullptr);
+  mSpeculativeService->SpeculativeConnect2(targetURI, nullptr, nullptr);
   if (verifier) {
     PREDICTOR_LOG(("    sending verification"));
     verifier->OnPredictPreconnect(targetURI);
   }
 }
 
 // This is the driver for prediction based on a new pageload.
 static const uint8_t MAX_PAGELOAD_DEPTH = 10;
@@ -1355,17 +1355,17 @@ Predictor::RunPredictions(nsIURI *referr
   }
 
   len = preconnects.Length();
   for (i = 0; i < len; ++i) {
     PREDICTOR_LOG(("    doing preconnect"));
     nsCOMPtr<nsIURI> uri = preconnects[i];
     ++totalPredictions;
     ++totalPreconnects;
-    mSpeculativeService->SpeculativeConnect(uri, this);
+    mSpeculativeService->SpeculativeConnect2(uri, nullptr, this);
     predicted = true;
     if (verifier) {
       PREDICTOR_LOG(("    sending preconnect verification"));
       verifier->OnPredictPreconnect(uri);
     }
   }
 
   len = preresolves.Length();
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -1747,22 +1747,28 @@ IOServiceProxyCallback::OnProxyAvailable
     if (NS_FAILED(rv))
         return NS_OK;
 
     nsCOMPtr<nsISpeculativeConnect> speculativeHandler =
         do_QueryInterface(handler);
     if (!speculativeHandler)
         return NS_OK;
 
+    nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
+    nsCOMPtr<nsIPrincipal> principal;
+    if (loadInfo) {
+      principal = loadInfo->LoadingPrincipal();
+    }
+
     nsLoadFlags loadFlags = 0;
     channel->GetLoadFlags(&loadFlags);
     if (loadFlags & nsIRequest::LOAD_ANONYMOUS) {
-        speculativeHandler->SpeculativeAnonymousConnect(uri, mCallbacks);
+        speculativeHandler->SpeculativeAnonymousConnect2(uri, principal, mCallbacks);
     } else {
-        speculativeHandler->SpeculativeConnect(uri, mCallbacks);
+        speculativeHandler->SpeculativeConnect2(uri, principal, mCallbacks);
     }
 
     return NS_OK;
 }
 
 nsresult
 nsIOService::SpeculativeConnectInternal(nsIURI *aURI,
                                         nsIPrincipal *aPrincipal,