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

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

Issue 254763005: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial patches. Created 6 years, 8 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/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/net/predictor.h" 8 #include "chrome/browser/net/predictor.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/common/frame_navigate_params.h" 13 #include "content/public/common/frame_navigate_params.h"
14 #include "net/base/url_constants.h"
14 15
15 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper); 16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper);
16 17
17 using content::BrowserThread; 18 using content::BrowserThread;
18 19
19 namespace { 20 namespace {
20 21
21 bool IsUserLinkNavigationRequest(content::PageTransition page_transition) { 22 bool IsUserLinkNavigationRequest(content::PageTransition page_transition) {
22 bool is_link = (content::PageTransitionStripQualifier(page_transition) == 23 bool is_link = (content::PageTransitionStripQualifier(page_transition) ==
23 content::PAGE_TRANSITION_LINK); 24 content::PAGE_TRANSITION_LINK);
(...skipping 18 matching lines...) Expand all
42 } 43 }
43 44
44 void PredictorTabHelper::DidStartNavigationToPendingEntry( 45 void PredictorTabHelper::DidStartNavigationToPendingEntry(
45 const GURL& url, 46 const GURL& url,
46 content::NavigationController::ReloadType reload_type) { 47 content::NavigationController::ReloadType reload_type) {
47 Profile* profile = 48 Profile* profile =
48 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 49 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
49 chrome_browser_net::Predictor* predictor = profile->GetNetworkPredictor(); 50 chrome_browser_net::Predictor* predictor = profile->GetNetworkPredictor();
50 if (!predictor) 51 if (!predictor)
51 return; 52 return;
52 if (url.SchemeIs(content::kHttpScheme) || url.SchemeIs(content::kHttpsScheme)) 53 if (url.SchemeIs(net::kHttpScheme) || url.SchemeIs(net::kHttpsScheme))
53 predictor->PreconnectUrlAndSubresources(url, GURL()); 54 predictor->PreconnectUrlAndSubresources(url, GURL());
54 } 55 }
55 56
56 void PredictorTabHelper::DidNavigateMainFrame( 57 void PredictorTabHelper::DidNavigateMainFrame(
57 const content::LoadCommittedDetails& details, 58 const content::LoadCommittedDetails& details,
58 const content::FrameNavigateParams& params) { 59 const content::FrameNavigateParams& params) {
59 if (!IsUserLinkNavigationRequest(params.transition) || 60 if (!IsUserLinkNavigationRequest(params.transition) ||
60 !(params.url.SchemeIsHTTPOrHTTPS())) 61 !(params.url.SchemeIsHTTPOrHTTPS()))
61 return; 62 return;
62 63
63 Profile* profile = Profile::FromBrowserContext( 64 Profile* profile = Profile::FromBrowserContext(
64 web_contents()->GetBrowserContext()); 65 web_contents()->GetBrowserContext());
65 Predictor* predictor = profile->GetNetworkPredictor(); 66 Predictor* predictor = profile->GetNetworkPredictor();
66 if (predictor) { 67 if (predictor) {
67 BrowserThread::PostTask( 68 BrowserThread::PostTask(
68 BrowserThread::IO, 69 BrowserThread::IO,
69 FROM_HERE, 70 FROM_HERE,
70 base::Bind(&Predictor::RecordLinkNavigation, 71 base::Bind(&Predictor::RecordLinkNavigation,
71 base::Unretained(predictor), 72 base::Unretained(predictor),
72 params.url)); 73 params.url));
73 } 74 }
74 } 75 }
75 76
76 } // namespace chrome_browser_net 77 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698