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

Side by Side Diff: chrome/browser/instant/instant_controller.cc

Issue 11788034: Adding metrics for Instant URL blacklist events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/instant/instant_controller.h" 5 #include "chrome/browser/instant/instant_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 30 matching lines...) Expand all
41 const int kUpdateBoundsDelayMS = 1000; 41 const int kUpdateBoundsDelayMS = 1000;
42 42
43 // The maximum number of times we'll load a non-Instant-supporting search engine 43 // The maximum number of times we'll load a non-Instant-supporting search engine
44 // before we give up and blacklist it for the rest of the browsing session. 44 // before we give up and blacklist it for the rest of the browsing session.
45 const int kMaxInstantSupportFailures = 10; 45 const int kMaxInstantSupportFailures = 10;
46 46
47 // If an Instant page has not been used in these many milliseconds, it is 47 // If an Instant page has not been used in these many milliseconds, it is
48 // reloaded so that the page does not become stale. 48 // reloaded so that the page does not become stale.
49 const int kStaleLoaderTimeoutMS = 3 * 3600 * 1000; 49 const int kStaleLoaderTimeoutMS = 3 * 3600 * 1000;
50 50
51 // For reporting events of interest.
52 enum InstantControllerEvent {
53 INSTANT_CONTROLLER_EVENT_URL_ADDED_TO_BLACKLIST = 0,
54 INSTANT_CONTROLLER_EVENT_URL_REMOVED_FROM_BLACKLIST = 1,
55 INSTANT_CONTROLLER_EVENT_URL_BLOCKED_BY_BLACKLIST = 2,
56 INSTANT_CONTROLLER_EVENT_MAX = 3,
57 };
58
59 void RecordEventHistogram(InstantControllerEvent event) {
60 UMA_HISTOGRAM_ENUMERATION("Instant.InstantControllerEvent",
61 event,
62 INSTANT_CONTROLLER_EVENT_MAX);
63 }
64
51 void AddSessionStorageHistogram(bool extended_enabled, 65 void AddSessionStorageHistogram(bool extended_enabled,
52 const content::WebContents* tab1, 66 const content::WebContents* tab1,
53 const content::WebContents* tab2) { 67 const content::WebContents* tab2) {
54 base::Histogram* histogram = base::BooleanHistogram::FactoryGet( 68 base::Histogram* histogram = base::BooleanHistogram::FactoryGet(
55 std::string("Instant.SessionStorageNamespace") + 69 std::string("Instant.SessionStorageNamespace") +
56 (extended_enabled ? "_Extended" : "_Instant"), 70 (extended_enabled ? "_Extended" : "_Instant"),
57 base::Histogram::kUmaTargetedHistogramFlag); 71 base::Histogram::kUmaTargetedHistogramFlag);
58 const content::SessionStorageNamespaceMap& session_storage_map1 = 72 const content::SessionStorageNamespaceMap& session_storage_map1 =
59 tab1->GetController().GetSessionStorageNamespaceMap(); 73 tab1->GetController().GetSessionStorageNamespaceMap();
60 const content::SessionStorageNamespaceMap& session_storage_map2 = 74 const content::SessionStorageNamespaceMap& session_storage_map2 =
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 const content::WebContents* contents, 818 const content::WebContents* contents,
805 bool supports_instant) { 819 bool supports_instant) {
806 if (instant_tab_ && instant_tab_->contents() == contents) { 820 if (instant_tab_ && instant_tab_->contents() == contents) {
807 if (!supports_instant) 821 if (!supports_instant)
808 MessageLoop::current()->DeleteSoon(FROM_HERE, instant_tab_.release()); 822 MessageLoop::current()->DeleteSoon(FROM_HERE, instant_tab_.release());
809 return; 823 return;
810 } 824 }
811 825
812 if (loader_ && loader_->contents() == contents) { 826 if (loader_ && loader_->contents() == contents) {
813 if (supports_instant) { 827 if (supports_instant) {
814 blacklisted_urls_.erase(loader_->instant_url()); 828 if (blacklisted_urls_.erase(loader_->instant_url())) {
829 RecordEventHistogram(
830 INSTANT_CONTROLLER_EVENT_URL_REMOVED_FROM_BLACKLIST);
831 }
815 } else { 832 } else {
816 ++blacklisted_urls_[loader_->instant_url()]; 833 ++blacklisted_urls_[loader_->instant_url()];
834 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_ADDED_TO_BLACKLIST);
817 HideInternal(); 835 HideInternal();
818 delete loader_->ReleaseContents(); 836 delete loader_->ReleaseContents();
819 MessageLoop::current()->DeleteSoon(FROM_HERE, loader_.release()); 837 MessageLoop::current()->DeleteSoon(FROM_HERE, loader_.release());
820 CreateDefaultLoader(); 838 CreateDefaultLoader();
821 } 839 }
822 content::NotificationService::current()->Notify( 840 content::NotificationService::current()->Notify(
823 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, 841 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED,
824 content::Source<InstantController>(this), 842 content::Source<InstantController>(this),
825 content::NotificationService::NoDetails()); 843 content::NotificationService::NoDetails());
826 } 844 }
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 if (!url_obj.is_valid()) 1212 if (!url_obj.is_valid())
1195 return false; 1213 return false;
1196 1214
1197 *instant_url = url_obj.spec(); 1215 *instant_url = url_obj.spec();
1198 } 1216 }
1199 } 1217 }
1200 1218
1201 std::map<std::string, int>::const_iterator iter = 1219 std::map<std::string, int>::const_iterator iter =
1202 blacklisted_urls_.find(*instant_url); 1220 blacklisted_urls_.find(*instant_url);
1203 if (iter != blacklisted_urls_.end() && 1221 if (iter != blacklisted_urls_.end() &&
1204 iter->second > kMaxInstantSupportFailures) 1222 iter->second > kMaxInstantSupportFailures) {
1223 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_BLOCKED_BY_BLACKLIST);
1205 return false; 1224 return false;
1225 }
1206 1226
1207 return true; 1227 return true;
1208 } 1228 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698