Bug 881804 (part 2) - Plumb docshell into predictive network actions. r=smaug
authorNicholas Hurley <hurley@todesschaf.org>
Fri, 25 Oct 2013 14:56:53 -0700
changeset 167070 85ebad9a27c9c21c8aa7e9ad78ed1de7276c869f
parent 167069 4bcbb58917c962d1e4c51ce436d4bc6fe7852754
child 167071 21813034cb0e7391311e96a614414e5c79992b37
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs881804
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 881804 (part 2) - Plumb docshell into predictive network actions. r=smaug
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -111,16 +111,17 @@
 #include "nsITabChild.h"
 #include "nsISiteSecurityService.h"
 #include "nsStructuredCloneContainer.h"
 #include "nsIStructuredCloneContainer.h"
 #ifdef MOZ_PLACES
 #include "nsIFaviconService.h"
 #include "mozIAsyncFavicons.h"
 #endif
+#include "nsINetworkSeer.h"
 
 // Editor-related
 #include "nsIEditingSession.h"
 
 #include "nsPIDOMWindow.h"
 #include "nsGlobalWindow.h"
 #include "nsPIWindowRoot.h"
 #include "nsICachingChannel.h"
@@ -7014,19 +7015,22 @@ nsDocShell::EndPageLoad(nsIWebProgress *
         else if (aStatus == NS_ERROR_DOCUMENT_NOT_CACHED) {
             // Non-caching channels will simply return NS_ERROR_OFFLINE.
             // Caching channels would have to look at their flags to work
             // out which error to return. Or we can fix up the error here.
             if (!(mLoadType & LOAD_CMD_HISTORY))
                 aStatus = NS_ERROR_OFFLINE;
             DisplayLoadError(aStatus, url, nullptr, aChannel);
         }
-  } // if we have a host
-
-  return NS_OK;
+    } // if we have a host
+    else if (url && NS_SUCCEEDED(aStatus)) {
+        mozilla::net::SeerLearnRedirect(url, aChannel, this);
+    }
+
+    return NS_OK;
 }
 
 
 //*****************************************************************************
 // nsDocShell: Content Viewer Management
 //*****************************************************************************   
 
 NS_IMETHODIMP
@@ -9403,16 +9407,19 @@ nsDocShell::InternalLoad(nsIURI * aURI,
     }
 
     nsAutoString srcdoc;
     if (aFlags & INTERNAL_LOAD_FLAGS_IS_SRCDOC)
       srcdoc = aSrcdoc;
     else
       srcdoc = NullString();
 
+    mozilla::net::SeerPredict(aURI, nullptr, nsINetworkSeer::PREDICT_LOAD,
+                              this, nullptr);
+
     nsCOMPtr<nsIRequest> req;
     rv = DoURILoad(aURI, aReferrer,
                    !(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
                    owner, aTypeHint, aFileName, aPostData, aHeadersData,
                    aFirstParty, aDocShell, getter_AddRefs(req),
                    (aFlags & INTERNAL_LOAD_FLAGS_FIRST_LOAD) != 0,
                    (aFlags & INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER) != 0,
                    (aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES) != 0,
@@ -12459,16 +12466,19 @@ nsDocShell::OnOverLink(nsIContent* aCont
   nsAutoCString spec;
   rv = aURI->GetSpec(spec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoString uStr;
   rv = textToSubURI->UnEscapeURIForUI(charset, spec, uStr);    
   NS_ENSURE_SUCCESS(rv, rv);
 
+  mozilla::net::SeerPredict(aURI, mCurrentURI, nsINetworkSeer::PREDICT_LINK,
+                            this, nullptr);
+
   if (browserChrome2) {
     nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aContent);
     rv = browserChrome2->SetStatusWithContext(nsIWebBrowserChrome::STATUS_LINK,
                                               uStr, element);
   } else {
     rv = browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_LINK, uStr.get());
   }
   return rv;