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

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc

Issue 23455047: InstantExtended: Send search URLs to renderers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More browsertest fixes Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/search/instant_ntp_prerenderer.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/webui/ntp/ntp_user_data_logger.h" 5 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/search/search.h" 8 #include "chrome/browser/search/search.h"
9 #include "chrome/common/search_urls.h"
9 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
10 #include "content/public/browser/navigation_details.h" 11 #include "content/public/browser/navigation_details.h"
11 12
12 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger); 13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger);
13 14
14 NTPUserDataLogger::~NTPUserDataLogger() {} 15 NTPUserDataLogger::~NTPUserDataLogger() {}
15 16
16 void NTPUserDataLogger::EmitThumbnailErrorRate() { 17 void NTPUserDataLogger::EmitThumbnailErrorRate() {
17 DCHECK_LE(number_of_thumbnail_errors_, number_of_thumbnail_attempts_); 18 DCHECK_LE(number_of_thumbnail_errors_, number_of_thumbnail_attempts_);
18 if (number_of_thumbnail_attempts_ != 0) { 19 if (number_of_thumbnail_attempts_ != 0) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 NOTREACHED(); 62 NOTREACHED();
62 } 63 }
63 } 64 }
64 65
65 // content::WebContentsObserver override 66 // content::WebContentsObserver override
66 void NTPUserDataLogger::NavigationEntryCommitted( 67 void NTPUserDataLogger::NavigationEntryCommitted(
67 const content::LoadCommittedDetails& load_details) { 68 const content::LoadCommittedDetails& load_details) {
68 if (!load_details.previous_url.is_valid()) 69 if (!load_details.previous_url.is_valid())
69 return; 70 return;
70 71
71 if (chrome::MatchesOriginAndPath(ntp_url_, load_details.previous_url)) { 72 if (search::MatchesOriginAndPath(ntp_url_, load_details.previous_url)) {
72 EmitMouseoverCount(); 73 EmitMouseoverCount();
73 // Only log thumbnail error rates for Instant NTP pages, as we do not have 74 // Only log thumbnail error rates for Instant NTP pages, as we do not have
74 // this data for non-Instant NTPs. 75 // this data for non-Instant NTPs.
75 if (ntp_url_ != GURL(chrome::kChromeUINewTabURL)) 76 if (ntp_url_ != GURL(chrome::kChromeUINewTabURL))
76 EmitThumbnailErrorRate(); 77 EmitThumbnailErrorRate();
77 } 78 }
78 } 79 }
79 80
80 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) 81 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents)
81 : content::WebContentsObserver(contents), 82 : content::WebContentsObserver(contents),
82 number_of_mouseovers_(0), 83 number_of_mouseovers_(0),
83 number_of_thumbnail_attempts_(0), 84 number_of_thumbnail_attempts_(0),
84 number_of_thumbnail_errors_(0), 85 number_of_thumbnail_errors_(0),
85 number_of_fallback_thumbnails_requested_(0), 86 number_of_fallback_thumbnails_requested_(0),
86 number_of_fallback_thumbnails_used_(0) { 87 number_of_fallback_thumbnails_used_(0) {
87 } 88 }
88 89
89 size_t NTPUserDataLogger::GetPercentError(size_t errors, size_t events) const { 90 size_t NTPUserDataLogger::GetPercentError(size_t errors, size_t events) const {
90 return (100 * errors) / events; 91 return (100 * errors) / events;
91 } 92 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_ntp_prerenderer.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698