Added UMA records for OOBE portal detection.

Added UMA records for:
* portal detection result
* portal detection duration
* discrepancy with shill's result

BUG=174047
TEST=Manual tests on Lumpy


Review URL: https://chromiumcodereview.appspot.com/12211111

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181999 0039d316-1c4b-4281-b951-d872f2087c98
parent cdf0b283
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
...@@ -55,6 +56,8 @@ std::string CaptivePortalStatusString( ...@@ -55,6 +56,8 @@ std::string CaptivePortalStatusString(
case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED:
return l10n_util::GetStringUTF8( return l10n_util::GetStringUTF8(
IDS_CHROMEOS_CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED); IDS_CHROMEOS_CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED);
case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT:
NOTREACHED();
} }
return l10n_util::GetStringUTF8( return l10n_util::GetStringUTF8(
IDS_CHROMEOS_CAPTIVE_PORTAL_STATUS_UNRECOGNIZED); IDS_CHROMEOS_CAPTIVE_PORTAL_STATUS_UNRECOGNIZED);
...@@ -239,6 +242,8 @@ void NetworkPortalDetector::DetectCaptivePortal(const base::TimeDelta& delay) { ...@@ -239,6 +242,8 @@ void NetworkPortalDetector::DetectCaptivePortal(const base::TimeDelta& delay) {
min_time_between_attempts_ - elapsed_time > next_attempt_delay_) { min_time_between_attempts_ - elapsed_time > next_attempt_delay_) {
next_attempt_delay_ = min_time_between_attempts_ - elapsed_time; next_attempt_delay_ = min_time_between_attempts_ - elapsed_time;
} }
} else {
detection_start_time_ = GetCurrentTimeTicks();
} }
detection_task_.Reset( detection_task_.Reset(
base::Bind(&NetworkPortalDetector::DetectCaptivePortalTask, base::Bind(&NetworkPortalDetector::DetectCaptivePortalTask,
...@@ -366,6 +371,11 @@ void NetworkPortalDetector::SetCaptivePortalState( ...@@ -366,6 +371,11 @@ void NetworkPortalDetector::SetCaptivePortalState(
const CaptivePortalState& state) { const CaptivePortalState& state) {
DCHECK(network); DCHECK(network);
if (!detection_start_time_.is_null()) {
UMA_HISTOGRAM_TIMES("CaptivePortal.OOBE.DetectionDuration",
GetCurrentTimeTicks() - detection_start_time_);
}
CaptivePortalStateMap::const_iterator it = CaptivePortalStateMap::const_iterator it =
portal_state_map_.find(network->service_path()); portal_state_map_.find(network->service_path());
if (it == portal_state_map_.end() || if (it == portal_state_map_.end() ||
......
...@@ -44,7 +44,8 @@ class NetworkPortalDetector ...@@ -44,7 +44,8 @@ class NetworkPortalDetector
CAPTIVE_PORTAL_STATUS_OFFLINE = 1, CAPTIVE_PORTAL_STATUS_OFFLINE = 1,
CAPTIVE_PORTAL_STATUS_ONLINE = 2, CAPTIVE_PORTAL_STATUS_ONLINE = 2,
CAPTIVE_PORTAL_STATUS_PORTAL = 3, CAPTIVE_PORTAL_STATUS_PORTAL = 3,
CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED = 4 CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED = 4,
CAPTIVE_PORTAL_STATUS_COUNT
}; };
struct CaptivePortalState { struct CaptivePortalState {
...@@ -213,6 +214,9 @@ class NetworkPortalDetector ...@@ -213,6 +214,9 @@ class NetworkPortalDetector
// active network. // active network.
base::TimeDelta min_time_between_attempts_; base::TimeDelta min_time_between_attempts_;
// Start time of portal detection.
base::TimeTicks detection_start_time_;
// Start time of portal detection attempt. // Start time of portal detection attempt.
base::TimeTicks attempt_start_time_; base::TimeTicks attempt_start_time_;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "base/string16.h" #include "base/string16.h"
#include "base/string_util.h" #include "base/string_util.h"
...@@ -196,6 +197,69 @@ NetworkPortalDetector::CaptivePortalState GetCaptivePortalState( ...@@ -196,6 +197,69 @@ NetworkPortalDetector::CaptivePortalState GetCaptivePortalState(
return detector->GetCaptivePortalState(network); return detector->GetCaptivePortalState(network);
} }
void RecordDiscrepancyWithShill(
const Network* network,
const NetworkPortalDetector::CaptivePortalStatus status) {
if (network->online()) {
UMA_HISTOGRAM_ENUMERATION(
"CaptivePortal.OOBE.DiscrepancyWithShill.Online",
status,
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT);
} else if (network->restricted_pool()) {
UMA_HISTOGRAM_ENUMERATION(
"CaptivePortal.OOBE.DiscrepancyWithShill.RestrictedPool",
status,
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT);
} else {
UMA_HISTOGRAM_ENUMERATION(
"CaptivePortal.OOBE.DiscrepancyWithShill.Offline",
status,
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT);
}
}
// Record state and descripancies with shill (e.g. shill thinks that
// network is online but NetworkPortalDetector claims that it's behind
// portal) for the network identified by |service_path|.
void RecordNetworkPortalDetectorStats(const std::string& service_path) {
const Network* network = FindNetworkByPath(service_path);
if (!network)
return;
NetworkPortalDetector::CaptivePortalState state =
GetCaptivePortalState(service_path);
if (state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN)
return;
UMA_HISTOGRAM_ENUMERATION("CaptivePortal.OOBE.DetectionResult",
state.status,
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT);
switch (state.status) {
case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN:
NOTREACHED();
break;
case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE:
if (network->online() || network->restricted_pool())
RecordDiscrepancyWithShill(network, state.status);
break;
case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE:
if (!network->online())
RecordDiscrepancyWithShill(network, state.status);
break;
case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL:
if (!network->restricted_pool())
RecordDiscrepancyWithShill(network, state.status);
break;
case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED:
if (!network->online())
RecordDiscrepancyWithShill(network, state.status);
break;
case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT:
NOTREACHED();
break;
}
}
} // namespace } // namespace
// SigninScreenHandler implementation ------------------------------------------ // SigninScreenHandler implementation ------------------------------------------
...@@ -553,6 +617,11 @@ void SigninScreenHandler::UpdateStateInternal( ...@@ -553,6 +617,11 @@ void SigninScreenHandler::UpdateStateInternal(
<< "network_id=" << network_id << ", " << "network_id=" << network_id << ", "
<< "reason=" << reason << ", " << "reason=" << reason << ", "
<< "is_under_captive_portal=" << is_under_captive_portal; << "is_under_captive_portal=" << is_under_captive_portal;
// Record portal detection stats only if we're going to show or
// change state of the error screen.
RecordNetworkPortalDetectorStats(service_path);
if (is_proxy_error) { if (is_proxy_error) {
error_screen_actor_->ShowProxyError(); error_screen_actor_->ShowProxyError();
} else if (is_under_captive_portal) { } else if (is_under_captive_portal) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment