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_DISCONNECT_TETHERING_OPERATION_H_ |
| 6 #define CHROMEOS_COMPONENTS_TETHER_DISCONNECT_TETHERING_OPERATION_H_ |
| 7 |
| 8 #include "base/observer_list.h" |
| 9 #include "chromeos/components/tether/message_transfer_operation.h" |
| 10 |
| 11 namespace chromeos { |
| 12 |
| 13 namespace tether { |
| 14 |
| 15 class BleConnectionManager; |
| 16 |
| 17 // Operation which sends a disconnect message to a tether host. |
| 18 class DisconnectTetheringOperation : public MessageTransferOperation { |
| 19 public: |
| 20 class Factory { |
| 21 public: |
| 22 static std::unique_ptr<DisconnectTetheringOperation> NewInstance( |
| 23 const cryptauth::RemoteDevice& device_to_connect, |
| 24 BleConnectionManager* connection_manager); |
| 25 |
| 26 static void SetInstanceForTesting(Factory* factory); |
| 27 |
| 28 protected: |
| 29 virtual std::unique_ptr<DisconnectTetheringOperation> BuildInstance( |
| 30 const cryptauth::RemoteDevice& device_to_connect, |
| 31 BleConnectionManager* connection_manager); |
| 32 |
| 33 private: |
| 34 static Factory* factory_instance_; |
| 35 }; |
| 36 |
| 37 class Observer { |
| 38 public: |
| 39 // Alerts observers when the operation has finished. |success| is true when |
| 40 // the operation successfully sends the message and false otherwise. |
| 41 virtual void OnOperationFinished(bool success) = 0; |
| 42 }; |
| 43 |
| 44 DisconnectTetheringOperation(const cryptauth::RemoteDevice& device_to_connect, |
| 45 BleConnectionManager* connection_manager); |
| 46 ~DisconnectTetheringOperation() override; |
| 47 |
| 48 void AddObserver(Observer* observer); |
| 49 void RemoveObserver(Observer* observer); |
| 50 |
| 51 protected: |
| 52 // MessageTransferOperation: |
| 53 void OnDeviceAuthenticated( |
| 54 const cryptauth::RemoteDevice& remote_device) override; |
| 55 void OnOperationFinished() override; |
| 56 MessageType GetMessageTypeForConnection() override; |
| 57 |
| 58 private: |
| 59 friend class DisconnectTetheringOperationTest; |
| 60 |
| 61 base::ObserverList<Observer> observer_list_; |
| 62 bool has_authenticated_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(DisconnectTetheringOperation); |
| 65 }; |
| 66 |
| 67 } // namespace tether |
| 68 |
| 69 } // namespace chromeos |
| 70 |
| 71 #endif // CHROMEOS_COMPONENTS_TETHER_DISCONNECT_TETHERING_OPERATION_H_ |
OLD | NEW |