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

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

Issue 2861603002: [CrOS Tether] Create DisconnectTetheringOperation, which sends a DisconnectTetheringRequest to a re… (Closed)
Patch Set: 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
« no previous file with comments | « chromeos/components/tether/BUILD.gn ('k') | chromeos/components/tether/disconnect_tethering_operation.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/components/tether/disconnect_tethering_operation.h
diff --git a/chromeos/components/tether/disconnect_tethering_operation.h b/chromeos/components/tether/disconnect_tethering_operation.h
new file mode 100644
index 0000000000000000000000000000000000000000..81e1e65e7f4c976d6e554a95f9c0753eac6185b5
--- /dev/null
+++ b/chromeos/components/tether/disconnect_tethering_operation.h
@@ -0,0 +1,71 @@
+// 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_DISCONNECT_TETHERING_OPERATION_H_
+#define CHROMEOS_COMPONENTS_TETHER_DISCONNECT_TETHERING_OPERATION_H_
+
+#include "base/observer_list.h"
+#include "chromeos/components/tether/message_transfer_operation.h"
+
+namespace chromeos {
+
+namespace tether {
+
+class BleConnectionManager;
+
+// Operation which sends a disconnect message to a tether host.
+class DisconnectTetheringOperation : public MessageTransferOperation {
+ public:
+ class Factory {
+ public:
+ static std::unique_ptr<DisconnectTetheringOperation> NewInstance(
+ const cryptauth::RemoteDevice& device_to_connect,
+ BleConnectionManager* connection_manager);
+
+ static void SetInstanceForTesting(Factory* factory);
+
+ protected:
+ virtual std::unique_ptr<DisconnectTetheringOperation> BuildInstance(
+ const cryptauth::RemoteDevice& device_to_connect,
+ BleConnectionManager* connection_manager);
+
+ private:
+ static Factory* factory_instance_;
+ };
+
+ class Observer {
+ public:
+ // Alerts observers when the operation has finished. |success| is true when
+ // the operation successfully sends the message and false otherwise.
+ virtual void OnOperationFinished(bool success) = 0;
+ };
+
+ DisconnectTetheringOperation(const cryptauth::RemoteDevice& device_to_connect,
+ BleConnectionManager* connection_manager);
+ ~DisconnectTetheringOperation() override;
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ protected:
+ // MessageTransferOperation:
+ void OnDeviceAuthenticated(
+ const cryptauth::RemoteDevice& remote_device) override;
+ void OnOperationFinished() override;
+ MessageType GetMessageTypeForConnection() override;
+
+ private:
+ friend class DisconnectTetheringOperationTest;
+
+ base::ObserverList<Observer> observer_list_;
+ bool has_authenticated_;
+
+ DISALLOW_COPY_AND_ASSIGN(DisconnectTetheringOperation);
+};
+
+} // namespace tether
+
+} // namespace chromeos
+
+#endif // CHROMEOS_COMPONENTS_TETHER_DISCONNECT_TETHERING_OPERATION_H_
« no previous file with comments | « chromeos/components/tether/BUILD.gn ('k') | chromeos/components/tether/disconnect_tethering_operation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698