Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ | |
| 6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 #include <unordered_map> | |
| 11 | |
| 12 #include "base/callback_forward.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/weak_ptr.h" | |
| 15 #include "chromeos/components/tether/disconnect_tethering_operation.h" | |
| 16 #include "chromeos/network/network_handler_callbacks.h" | |
| 17 | |
| 18 namespace base { | |
| 19 class DictionaryValue; | |
| 20 } | |
| 21 | |
| 22 namespace chromeos { | |
| 23 | |
| 24 class NetworkConnectionHandler; | |
| 25 class NetworkStateHandler; | |
| 26 | |
| 27 namespace tether { | |
| 28 | |
| 29 class ActiveHost; | |
| 30 class BleConnectionManager; | |
| 31 class DeviceIdTetherNetworkGuidMap; | |
| 32 class NetworkConfigurationRemover; | |
| 33 class TetherConnector; | |
| 34 class TetherHostFetcher; | |
| 35 | |
| 36 class TetherDisconnector : public DisconnectTetheringOperation::Observer { | |
| 37 public: | |
| 38 TetherDisconnector( | |
| 39 NetworkConnectionHandler* network_connection_handler, | |
| 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( | |
| 50 const std::string& tether_network_guid, | |
| 51 const base::Closure& success_callback, | |
| 52 const network_handler::StringResultCallback& error_callback); | |
| 53 | |
| 54 // DisconnectTetheringOperation::Observer: | |
| 55 void OnOperationFinished(const std::string& device_id, bool success) override; | |
| 56 | |
| 57 private: | |
| 58 friend class TetherDisconnectorTest; | |
| 59 | |
| 60 struct DisconnectCallbacks { | |
| 61 DisconnectCallbacks( | |
| 62 const base::Closure& success_callback, | |
| 63 const network_handler::StringResultCallback& error_callback); | |
| 64 ~DisconnectCallbacks(); | |
| 65 explicit DisconnectCallbacks(const DisconnectCallbacks& other); | |
| 66 | |
| 67 base::Closure success_callback; | |
| 68 network_handler::StringResultCallback error_callback; | |
| 69 }; | |
| 70 | |
| 71 void DisconnectActiveWifiConnection( | |
| 72 const std::string& tether_network_guid, | |
| 73 const std::string& wifi_network_guid, | |
| 74 const base::Closure& success_callback, | |
| 75 const network_handler::StringResultCallback& error_callback); | |
| 76 void OnSuccessfulWifiDisconnect(const std::string& wifi_network_guid); | |
| 77 void OnFailedWifiDisconnect( | |
| 78 const std::string& wifi_network_guid, | |
| 79 const std::string& error_name, | |
| 80 std::unique_ptr<base::DictionaryValue> error_data); | |
| 81 void CleanUpAfterWifiDisconnection(bool success, | |
| 82 const std::string& wifi_network_guid); | |
| 83 void OnTetherHostFetched( | |
| 84 const std::string& device_id, | |
| 85 std::unique_ptr<cryptauth::RemoteDevice> tether_host); | |
| 86 | |
| 87 NetworkConnectionHandler* network_connection_handler_; | |
| 88 NetworkStateHandler* network_state_handler_; | |
| 89 ActiveHost* active_host_; | |
| 90 BleConnectionManager* ble_connection_manager_; | |
| 91 NetworkConfigurationRemover* network_configuration_remover_; | |
| 92 TetherConnector* tether_connector_; | |
| 93 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_; | |
| 94 TetherHostFetcher* tether_host_fetcher_; | |
| 95 | |
| 96 std::unordered_map<std::string, DisconnectCallbacks> | |
|
Ryan Hansberry
2017/05/04 01:23:00
Why do we need these maps? I can't foresee why we
Kyle Horimoto
2017/05/04 01:42:38
Done.
| |
| 97 wifi_guid_to_callbacks_map_; | |
| 98 std::unordered_map<std::string, std::unique_ptr<DisconnectTetheringOperation>> | |
| 99 device_id_to_operations_map_; | |
| 100 | |
| 101 base::WeakPtrFactory<TetherDisconnector> weak_ptr_factory_; | |
| 102 | |
| 103 DISALLOW_COPY_AND_ASSIGN(TetherDisconnector); | |
| 104 }; | |
| 105 | |
| 106 } // namespace tether | |
| 107 | |
| 108 } // namespace chromeos | |
| 109 | |
| 110 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ | |
| OLD | NEW |