Index: chromecast/net/connectivity_checker_impl.cc |
diff --git a/chromecast/net/connectivity_checker_impl.cc b/chromecast/net/connectivity_checker_impl.cc |
index 392ca8addaf5330b6128ded46b01c211e534d5c6..b32a7b7c23cb36b86ac45d49692fdcbd7ac5a13b 100644 |
--- a/chromecast/net/connectivity_checker_impl.cc |
+++ b/chromecast/net/connectivity_checker_impl.cc |
@@ -8,6 +8,9 @@ |
#include "base/logging.h" |
#include "base/memory/ptr_util.h" |
#include "base/message_loop/message_loop.h" |
+#include "base/values.h" |
+#include "chromecast/base/metrics/cast_metrics_helper.h" |
+#include "chromecast/base/serializers.h" |
#include "chromecast/net/net_switches.h" |
#include "net/base/request_priority.h" |
#include "net/http/http_response_headers.h" |
@@ -42,6 +45,9 @@ const char kDefaultConnectivityCheckUrl[] = |
// downtime is less than 3 seconds. |
const char kNetworkChangedDelayInSeconds = 3; |
+const char kMetricNameNetworkConnectivityErrorType[] = |
+ "Network.Connectivity.ErrorType"; |
wzhong
2016/05/12 22:48:52
Network.ConnectivityChecking.ErrorType
bcf
2016/05/13 03:05:20
Done.
|
+ |
} // namespace |
ConnectivityCheckerImpl::ConnectivityCheckerImpl( |
@@ -174,7 +180,7 @@ void ConnectivityCheckerImpl::OnResponseStarted(net::URLRequest* request) { |
return; |
} |
VLOG(1) << "Connectivity check failed: " << http_response_code; |
- OnUrlRequestError(); |
+ OnUrlRequestError(ErrorType::BAD_HTTP_STATUS); |
timeout_.Cancel(); |
} |
@@ -189,11 +195,17 @@ void ConnectivityCheckerImpl::OnSSLCertificateError( |
bool fatal) { |
LOG(ERROR) << "OnSSLCertificateError: cert_status=" << ssl_info.cert_status; |
net::SSLClientSocket::ClearSessionCache(); |
- OnUrlRequestError(); |
+ OnUrlRequestError(ErrorType::SSL_CERTIFICATE_ERROR); |
timeout_.Cancel(); |
} |
-void ConnectivityCheckerImpl::OnUrlRequestError() { |
+void ConnectivityCheckerImpl::OnUrlRequestError(ErrorType type) { |
+ // Only record a metric for the initial disconnect event |
wzhong
2016/05/12 22:48:52
I think we should record the event when we declare
bcf
2016/05/13 03:05:20
Done.
|
+ if (check_errors_ == 0) { |
+ metrics::CastMetricsHelper::GetInstance()->RecordEventWithValue( |
+ kMetricNameNetworkConnectivityErrorType, static_cast<int>(type)); |
+ } |
+ |
++check_errors_; |
if (check_errors_ > kNumErrorsToNotifyOffline) { |
check_errors_ = kNumErrorsToNotifyOffline; |
@@ -208,7 +220,7 @@ void ConnectivityCheckerImpl::OnUrlRequestError() { |
void ConnectivityCheckerImpl::OnUrlRequestTimeout() { |
LOG(ERROR) << "time out"; |
- OnUrlRequestError(); |
+ OnUrlRequestError(ErrorType::REQUEST_TIMEOUT); |
} |
void ConnectivityCheckerImpl::Cancel() { |