Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1873)

Unified Diff: chrome/browser/net/predictor_tab_helper.cc

Issue 1813553004: Change net's predictor_tab_helper to use the new content Navigation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asvitkine@ review - added variations to feature Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/predictor_tab_helper.cc
diff --git a/chrome/browser/net/predictor_tab_helper.cc b/chrome/browser/net/predictor_tab_helper.cc
index a6f59ba2f947eb775eec68ea6fe52e6d787ea772..2c82e540433854677c65f678f8a53c033e05eb3d 100644
--- a/chrome/browser/net/predictor_tab_helper.cc
+++ b/chrome/browser/net/predictor_tab_helper.cc
@@ -4,16 +4,27 @@
#include "chrome/browser/net/predictor_tab_helper.h"
-#include "base/command_line.h"
+#include "base/feature_list.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
+#include "components/variations/variations_associated_data.h"
+#include "content/public/browser/navigation_handle.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper);
namespace chrome_browser_net {
+namespace {
+
+// Triggers the preconnector on the new navigation api. This captures more
+// navigations.
+const base::Feature kPreconnectMore{"PreconnectMore",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
+} // namespace
+
PredictorTabHelper::PredictorTabHelper(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents) {
}
@@ -21,15 +32,32 @@ PredictorTabHelper::PredictorTabHelper(content::WebContents* web_contents)
PredictorTabHelper::~PredictorTabHelper() {
}
+void PredictorTabHelper::DidStartNavigation(
+ content::NavigationHandle* navigation_handle) {
+ if (!base::FeatureList::IsEnabled(kPreconnectMore))
+ return;
+ // Subframe navigations require a param check.
+ if (!navigation_handle->IsInMainFrame() &&
+ variations::GetVariationParamValue("PreconnectMore",
+ "preconnect_subframes") != "true") {
+ return;
+ }
+ PreconnectUrl(navigation_handle->GetURL());
+}
+
void PredictorTabHelper::DidStartNavigationToPendingEntry(
const GURL& url,
content::NavigationController::ReloadType reload_type) {
+ // The standard way to preconnect based on navigation.
+ if (!base::FeatureList::IsEnabled(kPreconnectMore))
+ PreconnectUrl(url);
+}
+
+void PredictorTabHelper::PreconnectUrl(const GURL& url) {
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
chrome_browser_net::Predictor* predictor = profile->GetNetworkPredictor();
- if (!predictor)
- return;
- if (url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme))
+ if (predictor && url.SchemeIsHTTPOrHTTPS())
predictor->PreconnectUrlAndSubresources(url, GURL());
}
« no previous file with comments | « chrome/browser/net/predictor_tab_helper.h ('k') | testing/variations/fieldtrial_testing_config_android.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698