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

Unified Diff: chromecast/net/connectivity_checker_impl.cc

Issue 1974723002: [Chromecast] Add metric reporting to ConnectivityCheckerImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Add CastMetricsHelper::RecordEventWithValue Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/net/connectivity_checker_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « chromecast/net/connectivity_checker_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698