| 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 #ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ |
| 6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 #include <string> | 8 #include <string> |
| 10 #include <unordered_map> | |
| 11 | 9 |
| 12 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" | 11 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 15 #include "chromeos/components/tether/disconnect_tethering_operation.h" | 13 #include "chromeos/components/tether/disconnect_tethering_operation.h" |
| 16 #include "chromeos/network/network_handler_callbacks.h" | 14 #include "chromeos/network/network_handler_callbacks.h" |
| 17 | 15 |
| 18 namespace base { | |
| 19 class DictionaryValue; | |
| 20 } | |
| 21 | |
| 22 namespace chromeos { | 16 namespace chromeos { |
| 23 | 17 |
| 24 class NetworkConnectionHandler; | |
| 25 class NetworkStateHandler; | |
| 26 | |
| 27 namespace tether { | 18 namespace tether { |
| 28 | 19 |
| 29 class ActiveHost; | 20 // Disconnects from an active Tether connection. |
| 30 class BleConnectionManager; | 21 class TetherDisconnector { |
| 31 class DeviceIdTetherNetworkGuidMap; | 22 public: |
| 32 class NetworkConfigurationRemover; | 23 TetherDisconnector() {} |
| 33 class TetherConnector; | 24 virtual ~TetherDisconnector() {} |
| 34 class TetherHostFetcher; | |
| 35 | 25 |
| 36 class TetherDisconnector : public DisconnectTetheringOperation::Observer { | 26 // Disconnects from the network with GUID |tether_network_guid|. This GUID |
| 37 public: | 27 // must correspond to an active (i.e., connecting/connected) Tether network. |
| 38 TetherDisconnector( | 28 // If disconnection fails, |error_callback| is invoked with a |
| 39 NetworkConnectionHandler* network_connection_handler, | 29 // NetworkConnectionHandler error value. |
| 40 NetworkStateHandler* network_state_handler, | |
| 41 ActiveHost* active_host, | |
| 42 BleConnectionManager* ble_connection_manager, | |
| 43 NetworkConfigurationRemover* network_configuration_remover, | |
| 44 TetherConnector* tether_connector, | |
| 45 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map, | |
| 46 TetherHostFetcher* tether_host_fetcher); | |
| 47 virtual ~TetherDisconnector(); | |
| 48 | |
| 49 virtual void DisconnectFromNetwork( | 30 virtual void DisconnectFromNetwork( |
| 50 const std::string& tether_network_guid, | 31 const std::string& tether_network_guid, |
| 51 const base::Closure& success_callback, | 32 const base::Closure& success_callback, |
| 52 const network_handler::StringResultCallback& error_callback); | 33 const network_handler::StringResultCallback& error_callback) = 0; |
| 53 | |
| 54 // DisconnectTetheringOperation::Observer: | |
| 55 void OnOperationFinished(const std::string& device_id, bool success) override; | |
| 56 | 34 |
| 57 private: | 35 private: |
| 58 friend class TetherDisconnectorTest; | |
| 59 | |
| 60 void DisconnectActiveWifiConnection( | |
| 61 const std::string& tether_network_guid, | |
| 62 const std::string& wifi_network_guid, | |
| 63 const base::Closure& success_callback, | |
| 64 const network_handler::StringResultCallback& error_callback); | |
| 65 void OnSuccessfulWifiDisconnect( | |
| 66 const std::string& wifi_network_guid, | |
| 67 const base::Closure& success_callback, | |
| 68 const network_handler::StringResultCallback& error_callback); | |
| 69 void OnFailedWifiDisconnect( | |
| 70 const std::string& wifi_network_guid, | |
| 71 const base::Closure& success_callback, | |
| 72 const network_handler::StringResultCallback& error_callback, | |
| 73 const std::string& error_name, | |
| 74 std::unique_ptr<base::DictionaryValue> error_data); | |
| 75 void CleanUpAfterWifiDisconnection( | |
| 76 bool success, | |
| 77 const std::string& wifi_network_guid, | |
| 78 const base::Closure& success_callback, | |
| 79 const network_handler::StringResultCallback& error_callback); | |
| 80 void OnTetherHostFetched( | |
| 81 const std::string& device_id, | |
| 82 std::unique_ptr<cryptauth::RemoteDevice> tether_host); | |
| 83 | |
| 84 NetworkConnectionHandler* network_connection_handler_; | |
| 85 NetworkStateHandler* network_state_handler_; | |
| 86 ActiveHost* active_host_; | |
| 87 BleConnectionManager* ble_connection_manager_; | |
| 88 NetworkConfigurationRemover* network_configuration_remover_; | |
| 89 TetherConnector* tether_connector_; | |
| 90 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_; | |
| 91 TetherHostFetcher* tether_host_fetcher_; | |
| 92 | |
| 93 std::unique_ptr<DisconnectTetheringOperation> disconnect_tethering_operation_; | |
| 94 base::WeakPtrFactory<TetherDisconnector> weak_ptr_factory_; | |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(TetherDisconnector); | 36 DISALLOW_COPY_AND_ASSIGN(TetherDisconnector); |
| 97 }; | 37 }; |
| 98 | 38 |
| 99 } // namespace tether | 39 } // namespace tether |
| 100 | 40 |
| 101 } // namespace chromeos | 41 } // namespace chromeos |
| 102 | 42 |
| 103 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ | 43 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ |
| OLD | NEW |