OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ |
6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "chromeos/components/tether/connect_tethering_operation.h" | 10 #include "chromeos/components/tether/connect_tethering_operation.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 class DeviceIdTetherNetworkGuidMap; | 21 class DeviceIdTetherNetworkGuidMap; |
22 class TetherHostFetcher; | 22 class TetherHostFetcher; |
23 class TetherHostResponseRecorder; | 23 class TetherHostResponseRecorder; |
24 class WifiHotspotConnector; | 24 class WifiHotspotConnector; |
25 | 25 |
26 // Connects to a tether network. When the user initiates a connection via the | 26 // Connects to a tether network. When the user initiates a connection via the |
27 // UI, TetherConnector receives a callback from NetworkConnectionHandler and | 27 // UI, TetherConnector receives a callback from NetworkConnectionHandler and |
28 // initiates a connection by starting a ConnectTetheringOperation. When a | 28 // initiates a connection by starting a ConnectTetheringOperation. When a |
29 // response has been received from the tether host, TetherConnector connects to | 29 // response has been received from the tether host, TetherConnector connects to |
30 // the associated Wi-Fi network. | 30 // the associated Wi-Fi network. |
31 class TetherConnector : public NetworkConnectionHandler::TetherDelegate, | 31 class TetherConnector : public ConnectTetheringOperation::Observer { |
32 public ConnectTetheringOperation::Observer { | |
33 public: | 32 public: |
34 TetherConnector( | 33 TetherConnector( |
35 NetworkConnectionHandler* network_connection_handler, | |
36 NetworkStateHandler* network_state_handler, | 34 NetworkStateHandler* network_state_handler, |
37 WifiHotspotConnector* wifi_hotspot_connector, | 35 WifiHotspotConnector* wifi_hotspot_connector, |
38 ActiveHost* active_host, | 36 ActiveHost* active_host, |
39 TetherHostFetcher* tether_host_fetcher, | 37 TetherHostFetcher* tether_host_fetcher, |
40 BleConnectionManager* connection_manager, | 38 BleConnectionManager* connection_manager, |
41 TetherHostResponseRecorder* tether_host_response_recorder, | 39 TetherHostResponseRecorder* tether_host_response_recorder, |
42 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map); | 40 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map); |
43 ~TetherConnector() override; | 41 virtual ~TetherConnector(); |
44 | 42 |
45 // NetworkConnectionHandler::TetherDelegate: | 43 virtual void ConnectToNetwork( |
46 void ConnectToNetwork( | |
47 const std::string& tether_network_guid, | 44 const std::string& tether_network_guid, |
48 const base::Closure& success_callback, | 45 const base::Closure& success_callback, |
49 const network_handler::StringResultCallback& error_callback) override; | 46 const network_handler::StringResultCallback& error_callback); |
| 47 |
| 48 // Returns whether the connection attempt was successfully canceled. |
| 49 virtual bool CancelConnectionAttempt(const std::string& tether_network_guid); |
50 | 50 |
51 // ConnectTetheringOperation::Observer: | 51 // ConnectTetheringOperation::Observer: |
52 void OnSuccessfulConnectTetheringResponse( | 52 void OnSuccessfulConnectTetheringResponse( |
53 const cryptauth::RemoteDevice& remote_device, | 53 const cryptauth::RemoteDevice& remote_device, |
54 const std::string& ssid, | 54 const std::string& ssid, |
55 const std::string& password) override; | 55 const std::string& password) override; |
56 void OnConnectTetheringFailure( | 56 void OnConnectTetheringFailure( |
57 const cryptauth::RemoteDevice& remote_device, | 57 const cryptauth::RemoteDevice& remote_device, |
58 ConnectTetheringResponse_ResponseCode error_code) override; | 58 ConnectTetheringResponse_ResponseCode error_code) override; |
59 | 59 |
60 private: | 60 private: |
61 friend class TetherConnectorTest; | 61 friend class TetherConnectorTest; |
62 | 62 |
63 void SetConnectionFailed(); | 63 void SetConnectionFailed(const std::string& error_name); |
64 void SetConnectionSucceeded(const std::string& device_id, | 64 void SetConnectionSucceeded(const std::string& device_id, |
65 const std::string& wifi_network_guid); | 65 const std::string& wifi_network_guid); |
66 | 66 |
67 void OnTetherHostToConnectFetched( | 67 void OnTetherHostToConnectFetched( |
68 const std::string& device_id, | 68 const std::string& device_id, |
69 std::unique_ptr<cryptauth::RemoteDevice> tether_host_to_connect); | 69 std::unique_ptr<cryptauth::RemoteDevice> tether_host_to_connect); |
70 void OnWifiConnection(const std::string& device_id, | 70 void OnWifiConnection(const std::string& device_id, |
71 const std::string& wifi_network_guid); | 71 const std::string& wifi_network_guid); |
72 | 72 |
73 NetworkConnectionHandler* network_connection_handler_; | 73 NetworkConnectionHandler* network_connection_handler_; |
(...skipping 12 matching lines...) Expand all Loading... |
86 base::WeakPtrFactory<TetherConnector> weak_ptr_factory_; | 86 base::WeakPtrFactory<TetherConnector> weak_ptr_factory_; |
87 | 87 |
88 DISALLOW_COPY_AND_ASSIGN(TetherConnector); | 88 DISALLOW_COPY_AND_ASSIGN(TetherConnector); |
89 }; | 89 }; |
90 | 90 |
91 } // namespace tether | 91 } // namespace tether |
92 | 92 |
93 } // namespace chromeos | 93 } // namespace chromeos |
94 | 94 |
95 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ | 95 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ |
OLD | NEW |