Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: chromeos/components/tether/tether_disconnector.h

Issue 2857853005: [CrOS Tether] Create TetherDisconnector, which disconnects from active tethering sessions. (Closed)
Patch Set: Test updated. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_
« no previous file with comments | « chromeos/components/tether/tether_connector_unittest.cc ('k') | chromeos/components/tether/tether_disconnector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698