Index: chromeos/components/tether/tether_connector.cc |
diff --git a/chromeos/components/tether/tether_connector.cc b/chromeos/components/tether/tether_connector.cc |
index ee34c45041305f63f17e5e79e9226f1312daf6b7..be84f71c8ba21d895fcb3de7d18144b14699879f 100644 |
--- a/chromeos/components/tether/tether_connector.cc |
+++ b/chromeos/components/tether/tether_connector.cc |
@@ -7,6 +7,7 @@ |
#include "base/bind.h" |
#include "chromeos/components/tether/active_host.h" |
#include "chromeos/components/tether/device_id_tether_network_guid_map.h" |
+#include "chromeos/components/tether/host_connection_metrics_logger.h" |
#include "chromeos/components/tether/host_scan_cache.h" |
#include "chromeos/components/tether/notification_presenter.h" |
#include "chromeos/components/tether/tether_host_fetcher.h" |
@@ -29,7 +30,8 @@ TetherConnector::TetherConnector( |
TetherHostResponseRecorder* tether_host_response_recorder, |
DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map, |
HostScanCache* host_scan_cache, |
- NotificationPresenter* notification_presenter) |
+ NotificationPresenter* notification_presenter, |
+ HostConnectionMetricsLogger* host_connection_metrics_logger) |
: network_state_handler_(network_state_handler), |
wifi_hotspot_connector_(wifi_hotspot_connector), |
active_host_(active_host), |
@@ -39,6 +41,7 @@ TetherConnector::TetherConnector( |
device_id_tether_network_guid_map_(device_id_tether_network_guid_map), |
host_scan_cache_(host_scan_cache), |
notification_presenter_(notification_presenter), |
+ host_connection_metrics_logger_(host_connection_metrics_logger), |
weak_ptr_factory_(this) {} |
TetherConnector::~TetherConnector() { |
@@ -119,7 +122,10 @@ bool TetherConnector::CancelConnectionAttempt( |
connect_tethering_operation_.reset(); |
} |
- SetConnectionFailed(NetworkConnectionHandler::kErrorConnectCanceled); |
+ SetConnectionFailed( |
+ NetworkConnectionHandler::kErrorConnectCanceled, |
+ HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ CONNECTION_RESULT_FAILURE_CLIENT_CONNECTION_CANCELED_BY_USER); |
return true; |
} |
@@ -174,9 +180,48 @@ void TetherConnector::OnConnectTetheringFailure( |
<< remote_device.GetTruncatedDeviceIdForLogs() |
<< " could not complete. Error code: " << error_code; |
+ HostConnectionMetricsLogger::ConnectionToHostResult connection_to_host_result; |
Kyle Horimoto
2017/07/12 17:23:21
Move this to a helper function, and remove the com
Ryan Hansberry
2017/07/12 17:51:17
Oops :) Done.
|
+ if (error_code == |
+ ConnectTetheringResponse_ResponseCode:: |
+ ConnectTetheringResponse_ResponseCode_PROVISIONING_FAILED) { |
+ // host_connection_metrics_logger_->RecordConnectionToHostResult( |
+ // HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ // CONNECTION_RESULT_PROVISIONING_FAILED); |
+ connection_to_host_result = HostConnectionMetricsLogger:: |
+ ConnectionToHostResult::CONNECTION_RESULT_PROVISIONING_FAILED; |
+ } else if (error_code == |
+ ConnectTetheringResponse_ResponseCode:: |
+ ConnectTetheringResponse_ResponseCode_TETHERING_TIMEOUT) { |
+ const std::string tether_network_guid = |
+ device_id_tether_network_guid_map_->GetTetherNetworkGuidForDeviceId( |
+ remote_device.GetDeviceId()); |
+ bool setup_was_required = |
+ host_scan_cache_->DoesHostRequireSetup(tether_network_guid); |
+ // host_connection_metrics_logger_->RecordConnectionToHostResult( |
+ // setup_was_required |
+ // ? HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ // CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP_WAS_REQUIRED |
+ // : HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ // CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP_WAS_NOT_REQUIRED); |
+ |
+ connection_to_host_result = |
+ setup_was_required |
+ ? HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP_WAS_REQUIRED |
+ : HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP_WAS_NOT_REQUIRED; |
+ } else { |
+ // host_connection_metrics_logger_->RecordConnectionToHostResult( |
+ // HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ // CONNECTION_RESULT_FAILURE_UNKNOWN_ERROR); |
+ connection_to_host_result = HostConnectionMetricsLogger:: |
+ ConnectionToHostResult::CONNECTION_RESULT_FAILURE_UNKNOWN_ERROR; |
+ } |
+ |
connect_tethering_operation_->RemoveObserver(this); |
connect_tethering_operation_.reset(); |
- SetConnectionFailed(NetworkConnectionHandler::kErrorConnectFailed); |
+ SetConnectionFailed(NetworkConnectionHandler::kErrorConnectFailed, |
+ connection_to_host_result); |
} |
void TetherConnector::OnTetherHostToConnectFetched( |
@@ -193,13 +238,19 @@ void TetherConnector::OnTetherHostToConnectFetched( |
PA_LOG(ERROR) << "Could not fetch tether host with device ID " |
<< cryptauth::RemoteDevice::TruncateDeviceIdForLogs(device_id) |
<< ". Cannot connect."; |
- SetConnectionFailed(NetworkConnectionHandler::kErrorConnectFailed); |
+ SetConnectionFailed( |
+ NetworkConnectionHandler::kErrorConnectFailed, |
+ HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ CONNECTION_RESULT_FAILURE_CLIENT_CONNECTION_INTERNAL_ERROR); |
+ // host_connection_metrics_logger_->RecordConnectionToHostResult( |
Kyle Horimoto
2017/07/12 17:23:21
Remove.
Ryan Hansberry
2017/07/12 17:51:17
Done.
|
+ // HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ // CONNECTION_RESULT_FAILURE_CLIENT_CONNECTION_INTERNAL_ERROR); |
return; |
} |
DCHECK(device_id == tether_host_to_connect->GetDeviceId()); |
- const std::string& tether_network_guid = |
+ const std::string tether_network_guid = |
device_id_tether_network_guid_map_->GetTetherNetworkGuidForDeviceId( |
device_id); |
connect_tethering_operation_ = |
@@ -211,7 +262,10 @@ void TetherConnector::OnTetherHostToConnectFetched( |
connect_tethering_operation_->Initialize(); |
} |
-void TetherConnector::SetConnectionFailed(const std::string& error_name) { |
+void TetherConnector::SetConnectionFailed( |
+ const std::string& error_name, |
+ HostConnectionMetricsLogger::ConnectionToHostResult |
+ connection_to_host_result) { |
DCHECK(!device_id_pending_connection_.empty()); |
DCHECK(!error_callback_.is_null()); |
@@ -226,6 +280,9 @@ void TetherConnector::SetConnectionFailed(const std::string& error_name) { |
error_callback.Run(error_name); |
active_host_->SetActiveHostDisconnected(); |
+ |
+ host_connection_metrics_logger_->RecordConnectionToHostResult( |
+ connection_to_host_result); |
} |
void TetherConnector::SetConnectionSucceeded( |
@@ -235,6 +292,10 @@ void TetherConnector::SetConnectionSucceeded( |
DCHECK(device_id_pending_connection_ == device_id); |
DCHECK(!success_callback_.is_null()); |
+ host_connection_metrics_logger_->RecordConnectionToHostResult( |
+ HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ CONNECTION_RESULT_SUCCESS); |
+ |
notification_presenter_->RemoveSetupRequiredNotification(); |
// Save a copy of the callback before resetting it below. |
@@ -273,7 +334,14 @@ void TetherConnector::OnWifiConnection(const std::string& device_id, |
<< cryptauth::RemoteDevice::TruncateDeviceIdForLogs(device_id) |
<< "."; |
- SetConnectionFailed(NetworkConnectionHandler::kErrorConnectFailed); |
+ // host_connection_metrics_logger_->RecordConnectionToHostResult( |
Kyle Horimoto
2017/07/12 17:23:21
Remove.
Ryan Hansberry
2017/07/12 17:51:17
Done.
|
+ // HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ // CONNECTION_RESULT_FAILURE_CLIENT_CONNECTION_TIMEOUT); |
+ |
+ SetConnectionFailed( |
+ NetworkConnectionHandler::kErrorConnectFailed, |
+ HostConnectionMetricsLogger::ConnectionToHostResult:: |
+ CONNECTION_RESULT_FAILURE_CLIENT_CONNECTION_TIMEOUT); |
return; |
} |