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

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

Issue 16514008: Add metrics for calculating precision/recall of link navigation pre-connect triggers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove PRERENDER flag change Created 7 years, 4 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/predictor_tab_helper.h"
6
7 #include "chrome/browser/net/predictor.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/common/frame_navigate_params.h"
11
12 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper);
13
14 using content::BrowserThread;
15
16 namespace {
17
18 bool IsUserLinkNavigationRequest(content::PageTransition page_transition) {
19 bool is_link = (content::PageTransitionStripQualifier(page_transition) ==
20 content::PAGE_TRANSITION_LINK);
21 bool is_forward_back = (page_transition &
22 content::PAGE_TRANSITION_FORWARD_BACK) != 0;
23 // Tracking navigation session including client-side redirect
24 // is currently not supported.
25 bool is_client_redirect = (page_transition &
26 content::PAGE_TRANSITION_CLIENT_REDIRECT) != 0;
27 return is_link && !is_forward_back && !is_client_redirect;
28 }
29
30 } // namespace
31
32 namespace chrome_browser_net {
33
34 PredictorTabHelper::PredictorTabHelper(content::WebContents* web_contents)
35 : content::WebContentsObserver(web_contents) {
36 }
37
38 PredictorTabHelper::~PredictorTabHelper() {
39 }
40
41 void PredictorTabHelper::DidNavigateMainFrame(
42 const content::LoadCommittedDetails& details,
43 const content::FrameNavigateParams& params) {
44 if (!IsUserLinkNavigationRequest(params.transition) ||
45 !(params.url.SchemeIs("http") || params.url.SchemeIs("https")))
46 return;
47
48 Profile* profile = Profile::FromBrowserContext(
49 web_contents()->GetBrowserContext());
50 Predictor* predictor = profile->GetNetworkPredictor();
51 if (predictor) {
52 BrowserThread::PostTask(
53 BrowserThread::IO,
54 FROM_HERE,
55 base::Bind(&Predictor::RecordLinkNavigation,
56 base::Unretained(predictor),
57 params.url));
58 }
59 }
60
61 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor_tab_helper.h ('k') | chrome/browser/renderer_host/chrome_render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698