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

Side by Side Diff: chromeos/components/tether/tether_connector.cc

Issue 2949343002: Tether: record each type of host connection result. (Closed)
Patch Set: Remove typo. 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chromeos/components/tether/tether_connector.h" 5 #include "chromeos/components/tether/tether_connector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chromeos/components/tether/active_host.h" 8 #include "chromeos/components/tether/active_host.h"
9 #include "chromeos/components/tether/device_id_tether_network_guid_map.h" 9 #include "chromeos/components/tether/device_id_tether_network_guid_map.h"
10 #include "chromeos/components/tether/host_connection_metrics_logger.h"
10 #include "chromeos/components/tether/host_scan_cache.h" 11 #include "chromeos/components/tether/host_scan_cache.h"
11 #include "chromeos/components/tether/notification_presenter.h" 12 #include "chromeos/components/tether/notification_presenter.h"
12 #include "chromeos/components/tether/tether_host_fetcher.h" 13 #include "chromeos/components/tether/tether_host_fetcher.h"
13 #include "chromeos/components/tether/wifi_hotspot_connector.h" 14 #include "chromeos/components/tether/wifi_hotspot_connector.h"
14 #include "chromeos/network/network_handler.h" 15 #include "chromeos/network/network_handler.h"
15 #include "chromeos/network/network_state.h" 16 #include "chromeos/network/network_state.h"
16 #include "chromeos/network/network_state_handler.h" 17 #include "chromeos/network/network_state_handler.h"
17 #include "components/proximity_auth/logging/logging.h" 18 #include "components/proximity_auth/logging/logging.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 namespace tether { 22 namespace tether {
22 23
23 TetherConnector::TetherConnector( 24 TetherConnector::TetherConnector(
24 NetworkStateHandler* network_state_handler, 25 NetworkStateHandler* network_state_handler,
25 WifiHotspotConnector* wifi_hotspot_connector, 26 WifiHotspotConnector* wifi_hotspot_connector,
26 ActiveHost* active_host, 27 ActiveHost* active_host,
27 TetherHostFetcher* tether_host_fetcher, 28 TetherHostFetcher* tether_host_fetcher,
28 BleConnectionManager* connection_manager, 29 BleConnectionManager* connection_manager,
29 TetherHostResponseRecorder* tether_host_response_recorder, 30 TetherHostResponseRecorder* tether_host_response_recorder,
30 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map, 31 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map,
31 HostScanCache* host_scan_cache, 32 HostScanCache* host_scan_cache,
32 NotificationPresenter* notification_presenter) 33 NotificationPresenter* notification_presenter,
34 HostConnectionMetricsLogger* host_connection_metrics_logger)
33 : network_state_handler_(network_state_handler), 35 : network_state_handler_(network_state_handler),
34 wifi_hotspot_connector_(wifi_hotspot_connector), 36 wifi_hotspot_connector_(wifi_hotspot_connector),
35 active_host_(active_host), 37 active_host_(active_host),
36 tether_host_fetcher_(tether_host_fetcher), 38 tether_host_fetcher_(tether_host_fetcher),
37 connection_manager_(connection_manager), 39 connection_manager_(connection_manager),
38 tether_host_response_recorder_(tether_host_response_recorder), 40 tether_host_response_recorder_(tether_host_response_recorder),
39 device_id_tether_network_guid_map_(device_id_tether_network_guid_map), 41 device_id_tether_network_guid_map_(device_id_tether_network_guid_map),
40 host_scan_cache_(host_scan_cache), 42 host_scan_cache_(host_scan_cache),
41 notification_presenter_(notification_presenter), 43 notification_presenter_(notification_presenter),
44 host_connection_metrics_logger_(host_connection_metrics_logger),
42 weak_ptr_factory_(this) {} 45 weak_ptr_factory_(this) {}
43 46
44 TetherConnector::~TetherConnector() { 47 TetherConnector::~TetherConnector() {
45 if (connect_tethering_operation_) { 48 if (connect_tethering_operation_) {
46 connect_tethering_operation_->RemoveObserver(this); 49 connect_tethering_operation_->RemoveObserver(this);
47 } 50 }
48 } 51 }
49 52
50 void TetherConnector::ConnectToNetwork( 53 void TetherConnector::ConnectToNetwork(
51 const std::string& tether_network_guid, 54 const std::string& tether_network_guid,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 PA_LOG(INFO) << "Received failed ConnectTetheringResponse from device with " 170 PA_LOG(INFO) << "Received failed ConnectTetheringResponse from device with "
168 << "ID " << remote_device.GetTruncatedDeviceIdForLogs() 171 << "ID " << remote_device.GetTruncatedDeviceIdForLogs()
169 << ", but a connection to another device has already started."; 172 << ", but a connection to another device has already started.";
170 return; 173 return;
171 } 174 }
172 175
173 PA_LOG(WARNING) << "Connection to device with ID " 176 PA_LOG(WARNING) << "Connection to device with ID "
174 << remote_device.GetTruncatedDeviceIdForLogs() 177 << remote_device.GetTruncatedDeviceIdForLogs()
175 << " could not complete. Error code: " << error_code; 178 << " could not complete. Error code: " << error_code;
176 179
180 if (error_code ==
Kyle Horimoto 2017/07/05 21:49:13 You should move this to SetConnectionFailed() inst
Ryan Hansberry 2017/07/07 02:33:16 You're right that it doesn't just fail with the op
Kyle Horimoto 2017/07/07 17:06:33 Yep, I was thinking you could pass a ConnectionToH
Ryan Hansberry 2017/07/12 16:37:06 Think I've done what you were expecting -- PTAL.
181 ConnectTetheringResponse_ResponseCode::
182 ConnectTetheringResponse_ResponseCode_PROVISIONING_FAILED) {
183 host_connection_metrics_logger_->RecordConnectionToHostResult(
184 HostConnectionMetricsLogger::ConnectionToHostResult::
185 CONNECTION_RESULT_PROVISIONING_FAILED);
186 } else if (error_code ==
187 ConnectTetheringResponse_ResponseCode::
188 ConnectTetheringResponse_ResponseCode_TETHERING_TIMEOUT) {
189 const std::string& tether_network_guid =
Kyle Horimoto 2017/07/05 21:49:13 GetTetherNetworkGuidForDeviceId() doesn't return a
Ryan Hansberry 2017/07/07 02:33:16 Good catch -- fixed it at another place in this fi
190 device_id_tether_network_guid_map_->GetTetherNetworkGuidForDeviceId(
191 remote_device.GetDeviceId());
192 bool setup_was_required =
193 host_scan_cache_->DoesHostRequireSetup(tether_network_guid);
194 host_connection_metrics_logger_->RecordConnectionToHostResult(
195 setup_was_required
196 ? HostConnectionMetricsLogger::ConnectionToHostResult::
197 CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP _WAS_REQUIRED
198 : HostConnectionMetricsLogger::ConnectionToHostResult::
199 CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP _WAS_NOT_REQUIRED);
200 } else {
201 host_connection_metrics_logger_->RecordConnectionToHostResult(
202 HostConnectionMetricsLogger::ConnectionToHostResult::
203 CONNECTION_RESULT_FAILURE_UNKNOWN_ERROR);
204 }
205
177 connect_tethering_operation_->RemoveObserver(this); 206 connect_tethering_operation_->RemoveObserver(this);
178 connect_tethering_operation_.reset(); 207 connect_tethering_operation_.reset();
179 SetConnectionFailed(NetworkConnectionHandler::kErrorConnectFailed); 208 SetConnectionFailed(NetworkConnectionHandler::kErrorConnectFailed);
180 } 209 }
181 210
182 void TetherConnector::OnTetherHostToConnectFetched( 211 void TetherConnector::OnTetherHostToConnectFetched(
183 const std::string& device_id, 212 const std::string& device_id,
184 std::unique_ptr<cryptauth::RemoteDevice> tether_host_to_connect) { 213 std::unique_ptr<cryptauth::RemoteDevice> tether_host_to_connect) {
185 if (device_id_pending_connection_ != device_id) { 214 if (device_id_pending_connection_ != device_id) {
186 PA_LOG(INFO) << "Device to connect to has changed while device with ID " 215 PA_LOG(INFO) << "Device to connect to has changed while device with ID "
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 PA_LOG(ERROR) << "Failed to connect to the hotspot belonging to the device " 300 PA_LOG(ERROR) << "Failed to connect to the hotspot belonging to the device "
272 << "with ID " 301 << "with ID "
273 << cryptauth::RemoteDevice::TruncateDeviceIdForLogs(device_id) 302 << cryptauth::RemoteDevice::TruncateDeviceIdForLogs(device_id)
274 << "."; 303 << ".";
275 304
276 SetConnectionFailed(NetworkConnectionHandler::kErrorConnectFailed); 305 SetConnectionFailed(NetworkConnectionHandler::kErrorConnectFailed);
277 return; 306 return;
278 } 307 }
279 308
280 SetConnectionSucceeded(device_id, wifi_network_guid); 309 SetConnectionSucceeded(device_id, wifi_network_guid);
310
311 host_connection_metrics_logger_->RecordConnectionToHostResult(
Kyle Horimoto 2017/07/05 21:49:13 Likewise, this belongs in SetConnectionSucceeded()
Ryan Hansberry 2017/07/07 02:33:16 Done.
312 HostConnectionMetricsLogger::ConnectionToHostResult::
313 CONNECTION_RESULT_SUCCESS);
281 } 314 }
282 315
283 } // namespace tether 316 } // namespace tether
284 317
285 } // namespace chromeos 318 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698