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

Side by Side Diff: chrome/browser/net/predictor_tab_helper.cc

Issue 2910843002: [Cleanup] Move all browsertests to use ScopedFeatureList to modify features
Patch Set: Move SFL calls to constructor Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/net/predictor_tab_helper.h" 5 #include "chrome/browser/net/predictor_tab_helper.h"
6 6
7 #include "base/feature_list.h"
8 #include "chrome/browser/net/predictor.h" 7 #include "chrome/browser/net/predictor.h"
9 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/chrome_features.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/navigation_handle.h" 11 #include "content/public/browser/navigation_handle.h"
12 #include "content/public/common/browser_side_navigation_policy.h" 12 #include "content/public/common/browser_side_navigation_policy.h"
13 13
14 #if defined(OS_CHROMEOS) 14 #if defined(OS_CHROMEOS)
15 #include "chrome/browser/chromeos/profiles/profile_helper.h" 15 #include "chrome/browser/chromeos/profiles/profile_helper.h"
16 #endif // defined(OS_CHROMEOS) 16 #endif // defined(OS_CHROMEOS)
17 17
18 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper); 18 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper);
19 19
20 namespace chrome_browser_net { 20 namespace chrome_browser_net {
21 21
22 namespace {
23
24 // Triggers the preconnector on renderer-initiated navigations. This captures
25 // more navigations.
26 const base::Feature kPreconnectMore{"PreconnectMore",
27 base::FEATURE_DISABLED_BY_DEFAULT};
28
29 } // namespace
30
31 PredictorTabHelper::PredictorTabHelper(content::WebContents* web_contents) 22 PredictorTabHelper::PredictorTabHelper(content::WebContents* web_contents)
32 : content::WebContentsObserver(web_contents), 23 : content::WebContentsObserver(web_contents),
33 predicted_from_pending_entry_(false) { 24 predicted_from_pending_entry_(false) {
34 } 25 }
35 26
36 PredictorTabHelper::~PredictorTabHelper() { 27 PredictorTabHelper::~PredictorTabHelper() {
37 } 28 }
38 29
39 void PredictorTabHelper::DidStartNavigation( 30 void PredictorTabHelper::DidStartNavigation(
40 content::NavigationHandle* navigation_handle) { 31 content::NavigationHandle* navigation_handle) {
41 if (!base::FeatureList::IsEnabled(kPreconnectMore) && 32 if (!base::FeatureList::IsEnabled(features::kPreconnectMore) &&
42 (!content::IsBrowserSideNavigationEnabled() || 33 (!content::IsBrowserSideNavigationEnabled() ||
43 navigation_handle->IsRendererInitiated())) 34 navigation_handle->IsRendererInitiated()))
44 return; 35 return;
45 // Subframe navigations are handled in WitnessURLRequest. 36 // Subframe navigations are handled in WitnessURLRequest.
46 if (!navigation_handle->IsInMainFrame()) 37 if (!navigation_handle->IsInMainFrame())
47 return; 38 return;
48 if (predicted_from_pending_entry_) { 39 if (predicted_from_pending_entry_) {
49 predicted_from_pending_entry_ = false; 40 predicted_from_pending_entry_ = false;
50 return; 41 return;
51 } 42 }
(...skipping 27 matching lines...) Expand all
79 70
80 void PredictorTabHelper::PreconnectUrl(const GURL& url) { 71 void PredictorTabHelper::PreconnectUrl(const GURL& url) {
81 Profile* profile = 72 Profile* profile =
82 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 73 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
83 Predictor* predictor(profile->GetNetworkPredictor()); 74 Predictor* predictor(profile->GetNetworkPredictor());
84 if (predictor && url.SchemeIsHTTPOrHTTPS()) 75 if (predictor && url.SchemeIsHTTPOrHTTPS())
85 predictor->PreconnectUrlAndSubresources(url, GURL()); 76 predictor->PreconnectUrlAndSubresources(url, GURL());
86 } 77 }
87 78
88 } // namespace chrome_browser_net 79 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor_browsertest.cc ('k') | chrome/browser/notifications/notification_interactive_uitest_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698