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

Side by Side Diff: chrome/browser/captive_portal/captive_portal_service.cc

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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/captive_portal/captive_portal_service.h" 5 #include "chrome/browser/captive_portal/captive_portal_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 base::HistogramBase* result_duration_histogram = 85 base::HistogramBase* result_duration_histogram =
86 base::Histogram::FactoryTimeGet( 86 base::Histogram::FactoryTimeGet(
87 "CaptivePortal.ResultDuration." + CaptivePortalResultToString(result), 87 "CaptivePortal.ResultDuration." + CaptivePortalResultToString(result),
88 base::TimeDelta::FromSeconds(1), // min 88 base::TimeDelta::FromSeconds(1), // min
89 base::TimeDelta::FromHours(1), // max 89 base::TimeDelta::FromHours(1), // max
90 50, // bucket_count 90 50, // bucket_count
91 base::Histogram::kUmaTargetedHistogramFlag); 91 base::Histogram::kUmaTargetedHistogramFlag);
92 result_duration_histogram->AddTime(result_duration); 92 result_duration_histogram->AddTime(result_duration);
93 } 93 }
94 94
95 int GetHistogramEntryForDetectionResult( 95 CaptivePortalDetectionResult GetHistogramEntryForDetectionResult(
96 const captive_portal::CaptivePortalDetector::Results& results) { 96 const captive_portal::CaptivePortalDetector::Results& results) {
97 bool is_https = results.landing_url.SchemeIs("https"); 97 bool is_https = results.landing_url.SchemeIs("https");
98 bool is_ip = results.landing_url.HostIsIPAddress(); 98 bool is_ip = results.landing_url.HostIsIPAddress();
99 switch (results.result) { 99 switch (results.result) {
100 case captive_portal::RESULT_INTERNET_CONNECTED: 100 case captive_portal::RESULT_INTERNET_CONNECTED:
101 return DETECTION_RESULT_INTERNET_CONNECTED; 101 return DETECTION_RESULT_INTERNET_CONNECTED;
102 case captive_portal::RESULT_NO_RESPONSE: 102 case captive_portal::RESULT_NO_RESPONSE:
103 if (is_ip) { 103 if (is_ip) {
104 return is_https ? 104 return is_https ?
105 DETECTION_RESULT_NO_RESPONSE_HTTPS_LANDING_URL_IP_ADDRESS : 105 DETECTION_RESULT_NO_RESPONSE_HTTPS_LANDING_URL_IP_ADDRESS :
106 DETECTION_RESULT_NO_RESPONSE_IP_ADDRESS; 106 DETECTION_RESULT_NO_RESPONSE_IP_ADDRESS;
107 } 107 }
108 return is_https ? 108 return is_https ?
109 DETECTION_RESULT_NO_RESPONSE_HTTPS_LANDING_URL : 109 DETECTION_RESULT_NO_RESPONSE_HTTPS_LANDING_URL :
110 DETECTION_RESULT_NO_RESPONSE; 110 DETECTION_RESULT_NO_RESPONSE;
111 case captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL: 111 case captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL:
112 if (is_ip) { 112 if (is_ip) {
113 return is_https ? 113 return is_https ?
114 DETECTION_RESULT_BEHIND_CAPTIVE_PORTAL_HTTPS_LANDING_URL_IP_ADDRESS : 114 DETECTION_RESULT_BEHIND_CAPTIVE_PORTAL_HTTPS_LANDING_URL_IP_ADDRESS :
115 DETECTION_RESULT_BEHIND_CAPTIVE_PORTAL_IP_ADDRESS; 115 DETECTION_RESULT_BEHIND_CAPTIVE_PORTAL_IP_ADDRESS;
116 } 116 }
117 return is_https ? 117 return is_https ?
118 DETECTION_RESULT_BEHIND_CAPTIVE_PORTAL_HTTPS_LANDING_URL : 118 DETECTION_RESULT_BEHIND_CAPTIVE_PORTAL_HTTPS_LANDING_URL :
119 DETECTION_RESULT_BEHIND_CAPTIVE_PORTAL; 119 DETECTION_RESULT_BEHIND_CAPTIVE_PORTAL;
120 default: 120 default:
121 NOTREACHED(); 121 NOTREACHED();
122 return -1; 122 return DETECTION_RESULT_COUNT;
123 } 123 }
124 } 124 }
125 125
126 bool ShouldDeferToNativeCaptivePortalDetection() { 126 bool ShouldDeferToNativeCaptivePortalDetection() {
127 // On Windows 8, defer to the native captive portal detection. OSX Lion and 127 // On Windows 8, defer to the native captive portal detection. OSX Lion and
128 // later also have captive portal detection, but experimentally, this code 128 // later also have captive portal detection, but experimentally, this code
129 // works in cases its does not. 129 // works in cases its does not.
130 // 130 //
131 // TODO(mmenke): Investigate how well Windows 8's captive portal detection 131 // TODO(mmenke): Investigate how well Windows 8's captive portal detection
132 // works. 132 // works.
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return base::TimeTicks::Now(); 416 return base::TimeTicks::Now();
417 } 417 }
418 418
419 bool CaptivePortalService::DetectionInProgress() const { 419 bool CaptivePortalService::DetectionInProgress() const {
420 return state_ == STATE_CHECKING_FOR_PORTAL; 420 return state_ == STATE_CHECKING_FOR_PORTAL;
421 } 421 }
422 422
423 bool CaptivePortalService::TimerRunning() const { 423 bool CaptivePortalService::TimerRunning() const {
424 return check_captive_portal_timer_.IsRunning(); 424 return check_captive_portal_timer_.IsRunning();
425 } 425 }
OLDNEW
« no previous file with comments | « chrome/browser/android/metrics/launch_metrics.cc ('k') | chrome/browser/chromeos/app_mode/kiosk_app_launch_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698