Index: chromeos/components/tether/tether_disconnector.h |
diff --git a/chromeos/components/tether/tether_disconnector.h b/chromeos/components/tether/tether_disconnector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d55f626dd3cda9c54b842c0727ca13c835f72a2c |
--- /dev/null |
+++ b/chromeos/components/tether/tether_disconnector.h |
@@ -0,0 +1,110 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ |
+#define CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ |
+ |
+#include <memory> |
+#include <string> |
+#include <unordered_map> |
+ |
+#include "base/callback_forward.h" |
+#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
+#include "chromeos/components/tether/disconnect_tethering_operation.h" |
+#include "chromeos/network/network_handler_callbacks.h" |
+ |
+namespace base { |
+class DictionaryValue; |
+} |
+ |
+namespace chromeos { |
+ |
+class NetworkConnectionHandler; |
+class NetworkStateHandler; |
+ |
+namespace tether { |
+ |
+class ActiveHost; |
+class BleConnectionManager; |
+class DeviceIdTetherNetworkGuidMap; |
+class NetworkConfigurationRemover; |
+class TetherConnector; |
+class TetherHostFetcher; |
+ |
+class TetherDisconnector : public DisconnectTetheringOperation::Observer { |
+ public: |
+ TetherDisconnector( |
+ NetworkConnectionHandler* network_connection_handler, |
+ NetworkStateHandler* network_state_handler, |
+ ActiveHost* active_host, |
+ BleConnectionManager* ble_connection_manager, |
+ NetworkConfigurationRemover* network_configuration_remover, |
+ TetherConnector* tether_connector, |
+ DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map, |
+ TetherHostFetcher* tether_host_fetcher); |
+ virtual ~TetherDisconnector(); |
+ |
+ virtual void DisconnectFromNetwork( |
+ const std::string& tether_network_guid, |
+ const base::Closure& success_callback, |
+ const network_handler::StringResultCallback& error_callback); |
+ |
+ // DisconnectTetheringOperation::Observer: |
+ void OnOperationFinished(const std::string& device_id, bool success) override; |
+ |
+ private: |
+ friend class TetherDisconnectorTest; |
+ |
+ struct DisconnectCallbacks { |
+ DisconnectCallbacks( |
+ const base::Closure& success_callback, |
+ const network_handler::StringResultCallback& error_callback); |
+ ~DisconnectCallbacks(); |
+ explicit DisconnectCallbacks(const DisconnectCallbacks& other); |
+ |
+ base::Closure success_callback; |
+ network_handler::StringResultCallback error_callback; |
+ }; |
+ |
+ void DisconnectActiveWifiConnection( |
+ const std::string& tether_network_guid, |
+ const std::string& wifi_network_guid, |
+ const base::Closure& success_callback, |
+ const network_handler::StringResultCallback& error_callback); |
+ void OnSuccessfulWifiDisconnect(const std::string& wifi_network_guid); |
+ void OnFailedWifiDisconnect( |
+ const std::string& wifi_network_guid, |
+ const std::string& error_name, |
+ std::unique_ptr<base::DictionaryValue> error_data); |
+ void CleanUpAfterWifiDisconnection(bool success, |
+ const std::string& wifi_network_guid); |
+ void OnTetherHostFetched( |
+ const std::string& device_id, |
+ std::unique_ptr<cryptauth::RemoteDevice> tether_host); |
+ |
+ NetworkConnectionHandler* network_connection_handler_; |
+ NetworkStateHandler* network_state_handler_; |
+ ActiveHost* active_host_; |
+ BleConnectionManager* ble_connection_manager_; |
+ NetworkConfigurationRemover* network_configuration_remover_; |
+ TetherConnector* tether_connector_; |
+ DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_; |
+ TetherHostFetcher* tether_host_fetcher_; |
+ |
+ 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.
|
+ wifi_guid_to_callbacks_map_; |
+ std::unordered_map<std::string, std::unique_ptr<DisconnectTetheringOperation>> |
+ device_id_to_operations_map_; |
+ |
+ base::WeakPtrFactory<TetherDisconnector> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TetherDisconnector); |
+}; |
+ |
+} // namespace tether |
+ |
+} // namespace chromeos |
+ |
+#endif // CHROMEOS_COMPONENTS_TETHER_TETHER_DISCONNECTOR_H_ |