Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/tether_host_fetcher.h" | 10 #include "chromeos/components/tether/tether_host_fetcher.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 // Make a copy of the device ID, SSID, and password to pass below before | 119 // Make a copy of the device ID, SSID, and password to pass below before |
| 120 // destroying |connect_tethering_operation_|. | 120 // destroying |connect_tethering_operation_|. |
| 121 std::string remote_device_id = remote_device.GetDeviceId(); | 121 std::string remote_device_id = remote_device.GetDeviceId(); |
| 122 std::string ssid_copy = ssid; | 122 std::string ssid_copy = ssid; |
| 123 std::string password_copy = password; | 123 std::string password_copy = password; |
| 124 | 124 |
| 125 connect_tethering_operation_->RemoveObserver(this); | 125 connect_tethering_operation_->RemoveObserver(this); |
| 126 connect_tethering_operation_.reset(); | 126 connect_tethering_operation_.reset(); |
| 127 | 127 |
| 128 wifi_hotspot_connector_->ConnectToWifiHotspot( | 128 wifi_hotspot_connector_->ConnectToWifiHotspot( |
| 129 ssid_copy, password_copy, | 129 ssid_copy, password_copy, active_host_->GetTetherNetworkGuid(), |
|
Kyle Horimoto
2017/05/03 01:53:33
Now that you pass this here, modify the tests to a
| |
| 130 base::Bind(&TetherConnector::OnWifiConnection, | 130 base::Bind(&TetherConnector::OnWifiConnection, |
| 131 weak_ptr_factory_.GetWeakPtr(), remote_device_id)); | 131 weak_ptr_factory_.GetWeakPtr(), remote_device_id)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void TetherConnector::OnConnectTetheringFailure( | 134 void TetherConnector::OnConnectTetheringFailure( |
| 135 const cryptauth::RemoteDevice& remote_device, | 135 const cryptauth::RemoteDevice& remote_device, |
| 136 ConnectTetheringResponse_ResponseCode error_code) { | 136 ConnectTetheringResponse_ResponseCode error_code) { |
| 137 if (device_id_pending_connection_ != remote_device.GetDeviceId()) { | 137 if (device_id_pending_connection_ != remote_device.GetDeviceId()) { |
| 138 // If the failure was part of a previous attempt for a different device, | 138 // If the failure was part of a previous attempt for a different device, |
| 139 // ignore it. | 139 // ignore it. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 // If the Wi-Fi network ID is empty, then the connection did not succeed. | 235 // If the Wi-Fi network ID is empty, then the connection did not succeed. |
| 236 PA_LOG(ERROR) << "Failed to connect to the hotspot belonging to the device " | 236 PA_LOG(ERROR) << "Failed to connect to the hotspot belonging to the device " |
| 237 << "with ID " | 237 << "with ID " |
| 238 << cryptauth::RemoteDevice::TruncateDeviceIdForLogs(device_id) | 238 << cryptauth::RemoteDevice::TruncateDeviceIdForLogs(device_id) |
| 239 << "."; | 239 << "."; |
| 240 | 240 |
| 241 SetConnectionFailed(); | 241 SetConnectionFailed(); |
| 242 return; | 242 return; |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool successful_association = | |
| 246 network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork( | |
| 247 device_id, wifi_network_guid); | |
| 248 if (successful_association) { | |
| 249 PA_LOG(INFO) << "Successfully connected to host device with ID " | |
| 250 << cryptauth::RemoteDevice::TruncateDeviceIdForLogs(device_id) | |
| 251 << ". Tether network ID: \"" << device_id | |
| 252 << "\", Wi-Fi network ID: \"" << wifi_network_guid << "\""; | |
| 253 } else { | |
| 254 PA_LOG(WARNING) << "Successfully connected to host device with ID " | |
| 255 << cryptauth::RemoteDevice::TruncateDeviceIdForLogs( | |
| 256 device_id) | |
| 257 << ", but failed to associate tether network with ID \"" | |
| 258 << device_id << "\" to Wi-Fi network with ID \"" | |
| 259 << wifi_network_guid << "\"."; | |
| 260 } | |
| 261 | |
| 262 SetConnectionSucceeded(device_id, wifi_network_guid); | 245 SetConnectionSucceeded(device_id, wifi_network_guid); |
| 263 } | 246 } |
| 264 | 247 |
| 265 } // namespace tether | 248 } // namespace tether |
| 266 | 249 |
| 267 } // namespace chromeos | 250 } // namespace chromeos |
| OLD | NEW |