Bug 1312954 - Part 11: Updating speculativeConnect to speculativeConnect2 for Fennec. r?sebastian draft
authorTim Huang <tihuang@mozilla.com>
Fri, 20 Jan 2017 15:32:51 +0800
changeset 466005 7253d331cfd56af9597e165aed0c83e3eb9f9b8a
parent 466004 56dffc33d182c507e989dad9398ae813d4153e2e
child 466112 2638a5aa3270c34658aacae0ad5614493e3518b4
push id42767
push userbmo:tihuang@mozilla.com
push dateWed, 25 Jan 2017 04:18:41 +0000
reviewerssebastian
bugs1312954
milestone54.0a1
Bug 1312954 - Part 11: Updating speculativeConnect to speculativeConnect2 for Fennec. r?sebastian
mobile/android/chrome/content/browser.js
widget/android/nsAppShell.cpp
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -4635,17 +4635,19 @@ var BrowserEventHandler = {
     this._inCluster = aEvent.hitCluster;
     if (this._inCluster) {
       return;  // No highlight for a cluster of links
     }
 
     let uri = this._getLinkURI(target);
     if (uri) {
       try {
-        Services.io.QueryInterface(Ci.nsISpeculativeConnect).speculativeConnect(uri, null);
+        Services.io.QueryInterface(Ci.nsISpeculativeConnect).speculativeConnect2(uri,
+                                                                                 target.ownerDocument.nodePrincipal,
+                                                                                 null);
       } catch (e) {}
     }
     this._doTapHighlight(target);
   },
 
   _getLinkURI: function(aElement) {
     if (aElement.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
         ((aElement instanceof Ci.nsIDOMHTMLAnchorElement && aElement.href) ||
@@ -6862,17 +6864,21 @@ var Tabs = {
           this.expireLruTab();
         }
         break;
       case "Session:Prefetch":
         if (aData) {
           try {
             let uri = Services.io.newURI(aData);
             if (uri && !this._domains.has(uri.host)) {
-              Services.io.QueryInterface(Ci.nsISpeculativeConnect).speculativeConnect(uri, null);
+              Services.io.QueryInterface(Ci.nsISpeculativeConnect).speculativeConnect2(uri,
+                                                                                       BrowserApp.selectedBrowser
+                                                                                                 .contentDocument
+                                                                                                 .nodePrincipal,
+                                                                                       null);
               this._domains.add(uri.host);
             }
           } catch (e) {}
         }
         break;
       case "network:link-status-changed":
         if (["down", "unknown", "up"].indexOf(aData) == -1) {
           return;
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -130,17 +130,20 @@ public:
         if (!specConn) {
             return;
         }
 
         nsCOMPtr<nsIURI> uri = nsAppShell::ResolveURI(aUriStr->ToCString());
         if (!uri) {
             return;
         }
-        specConn->SpeculativeConnect(uri, nullptr);
+
+        OriginAttributes attrs;
+        nsCOMPtr<nsIPrincipal> principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
+        specConn->SpeculativeConnect2(uri, principal, nullptr);
     }
 
     static void WaitOnGecko()
     {
         struct NoOpEvent : nsAppShell::Event {
             void Run() override {}
         };
         nsAppShell::SyncRunEvent(NoOpEvent());