OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ |
| 6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "chromeos/components/tether/connect_tethering_operation.h" |
| 11 #include "chromeos/network/network_connect.h" |
| 12 |
| 13 namespace chromeos { |
| 14 |
| 15 class NetworkStateHandler; |
| 16 |
| 17 namespace tether { |
| 18 |
| 19 class ActiveHost; |
| 20 class BleConnectionManager; |
| 21 class DeviceIdTetherNetworkGuidMap; |
| 22 class HostScanDevicePrioritizer; |
| 23 class TetherHostFetcher; |
| 24 class WifiHotspotConnector; |
| 25 |
| 26 // Connects to a tether network. When the user initiates a connection via the |
| 27 // UI, TetherConnector receives a callback from NetworkConnect and initiates a |
| 28 // connection by starting a ConnectTetheringOperation. When a response has been |
| 29 // received from the tether host, TetherConnector connects to the associated |
| 30 // Wi-Fi network. |
| 31 class TetherConnector : public NetworkConnect::TetherDelegate, |
| 32 public ConnectTetheringOperation::Observer { |
| 33 public: |
| 34 TetherConnector( |
| 35 WifiHotspotConnector* wifi_hotspot_connector, |
| 36 ActiveHost* active_host, |
| 37 TetherHostFetcher* tether_host_fetcher, |
| 38 BleConnectionManager* connection_manager, |
| 39 HostScanDevicePrioritizer* host_scan_device_prioritizer, |
| 40 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map); |
| 41 ~TetherConnector() override; |
| 42 |
| 43 // NetworkConnect::TetherDelegate: |
| 44 void ConnectToNetwork(const std::string& guid) override; |
| 45 |
| 46 // ConnectTetheringOperation::Observer: |
| 47 void OnSuccessfulConnectTetheringResponse( |
| 48 const cryptauth::RemoteDevice& remote_device, |
| 49 const std::string& ssid, |
| 50 const std::string& password) override; |
| 51 void OnConnectTetheringFailure( |
| 52 const cryptauth::RemoteDevice& remote_device, |
| 53 ConnectTetheringResponse_ResponseCode error_code) override; |
| 54 |
| 55 private: |
| 56 friend class TetherConnectorTest; |
| 57 |
| 58 TetherConnector( |
| 59 NetworkConnect* network_connect, |
| 60 NetworkStateHandler* network_state_handler, |
| 61 WifiHotspotConnector* wifi_hotspot_connector, |
| 62 ActiveHost* active_host, |
| 63 TetherHostFetcher* tether_host_fetcher, |
| 64 BleConnectionManager* connection_manager, |
| 65 HostScanDevicePrioritizer* host_scan_device_prioritizer, |
| 66 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map); |
| 67 |
| 68 void SetDisconnected(); |
| 69 void SetConnected(const std::string& device_id, |
| 70 const std::string& wifi_network_guid); |
| 71 |
| 72 void OnTetherHostToConnectFetched( |
| 73 const std::string& device_id, |
| 74 std::unique_ptr<cryptauth::RemoteDevice> tether_host_to_connect); |
| 75 void OnWifiConnection(const std::string& device_id, |
| 76 const std::string& wifi_network_guid); |
| 77 |
| 78 NetworkConnect* network_connect_; |
| 79 NetworkStateHandler* network_state_handler_; |
| 80 WifiHotspotConnector* wifi_hotspot_connector_; |
| 81 ActiveHost* active_host_; |
| 82 TetherHostFetcher* tether_host_fetcher_; |
| 83 BleConnectionManager* connection_manager_; |
| 84 HostScanDevicePrioritizer* host_scan_device_prioritizer_; |
| 85 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_; |
| 86 |
| 87 std::string device_id_pending_connection_; |
| 88 std::unique_ptr<ConnectTetheringOperation> connect_tethering_operation_; |
| 89 base::WeakPtrFactory<TetherConnector> weak_ptr_factory_; |
| 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(TetherConnector); |
| 92 }; |
| 93 |
| 94 } // namespace tether |
| 95 |
| 96 } // namespace chromeos |
| 97 |
| 98 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ |
OLD | NEW |