OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_COMPONENTS_TETHER_CONNECT_TETHERING_OPERATION_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_CONNECT_TETHERING_OPERATION_H_ |
6 #define CHROMEOS_COMPONENTS_TETHER_CONNECT_TETHERING_OPERATION_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_CONNECT_TETHERING_OPERATION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 BleConnectionManager* connection_manager, | 43 BleConnectionManager* connection_manager, |
44 HostScanDevicePrioritizer* host_scan_device_prioritizer); | 44 HostScanDevicePrioritizer* host_scan_device_prioritizer); |
45 | 45 |
46 private: | 46 private: |
47 static Factory* factory_instance_; | 47 static Factory* factory_instance_; |
48 }; | 48 }; |
49 | 49 |
50 class Observer { | 50 class Observer { |
51 public: | 51 public: |
52 virtual void OnSuccessfulConnectTetheringResponse( | 52 virtual void OnSuccessfulConnectTetheringResponse( |
53 const cryptauth::RemoteDevice& remote_device, | |
53 const std::string& ssid, | 54 const std::string& ssid, |
54 const std::string& password) = 0; | 55 const std::string& password) = 0; |
55 virtual void OnConnectTetheringFailure( | 56 virtual void OnConnectTetheringFailure( |
57 const cryptauth::RemoteDevice& remote_device, | |
56 ConnectTetheringResponse_ResponseCode error_code) = 0; | 58 ConnectTetheringResponse_ResponseCode error_code) = 0; |
57 }; | 59 }; |
58 | 60 |
59 ConnectTetheringOperation( | 61 ConnectTetheringOperation( |
60 const cryptauth::RemoteDevice& device_to_connect, | 62 const cryptauth::RemoteDevice& device_to_connect, |
61 BleConnectionManager* connection_manager, | 63 BleConnectionManager* connection_manager, |
62 HostScanDevicePrioritizer* host_scan_device_prioritizer); | 64 HostScanDevicePrioritizer* host_scan_device_prioritizer); |
63 ~ConnectTetheringOperation() override; | 65 ~ConnectTetheringOperation() override; |
64 | 66 |
65 void AddObserver(Observer* observer); | 67 void AddObserver(Observer* observer); |
66 void RemoveObserver(Observer* observer); | 68 void RemoveObserver(Observer* observer); |
67 | 69 |
68 protected: | 70 protected: |
69 // MessageTransferOperation: | 71 // MessageTransferOperation: |
70 void OnDeviceAuthenticated( | 72 void OnDeviceAuthenticated( |
71 const cryptauth::RemoteDevice& remote_device) override; | 73 const cryptauth::RemoteDevice& remote_device) override; |
72 void OnMessageReceived(std::unique_ptr<MessageWrapper> message_wrapper, | 74 void OnMessageReceived(std::unique_ptr<MessageWrapper> message_wrapper, |
73 const cryptauth::RemoteDevice& remote_device) override; | 75 const cryptauth::RemoteDevice& remote_device) override; |
74 void OnOperationFinished() override; | 76 void OnOperationFinished() override; |
75 MessageType GetMessageTypeForConnection() override; | 77 MessageType GetMessageTypeForConnection() override; |
76 | |
77 private: | |
78 friend class ConnectTetheringOperationTest; | |
79 | |
80 void NotifyObserversOfSuccessfulResponse(const std::string& ssid, | 78 void NotifyObserversOfSuccessfulResponse(const std::string& ssid, |
81 const std::string& password); | 79 const std::string& password); |
82 void NotifyObserversOfConnectionFailure( | 80 void NotifyObserversOfConnectionFailure( |
83 ConnectTetheringResponse_ResponseCode error_code); | 81 ConnectTetheringResponse_ResponseCode error_code); |
84 | 82 |
83 private: | |
84 friend class ConnectTetheringOperationTest; | |
85 | |
86 cryptauth::RemoteDevice remote_device_; | |
85 HostScanDevicePrioritizer* host_scan_device_prioritizer_; | 87 HostScanDevicePrioritizer* host_scan_device_prioritizer_; |
86 bool has_authenticated_; | 88 |
89 // These values are saved in OnMessageReceived() and returned in | |
90 // OnOperationFinished(). | |
91 std::string ssid_to_return_; | |
92 std::string password_to_return_; | |
93 ConnectTetheringResponse_ResponseCode error_code_to_return_; | |
Jeremy Klein
2017/04/06 21:04:15
nit: I'd call this response_code_to_return to matc
Kyle Horimoto
2017/04/06 21:33:52
I'd like to keep it as is. We only use that variab
| |
94 | |
87 base::ObserverList<Observer> observer_list_; | 95 base::ObserverList<Observer> observer_list_; |
88 | 96 |
89 DISALLOW_COPY_AND_ASSIGN(ConnectTetheringOperation); | 97 DISALLOW_COPY_AND_ASSIGN(ConnectTetheringOperation); |
90 }; | 98 }; |
91 | 99 |
92 } // namespace tether | 100 } // namespace tether |
93 | 101 |
94 } // namespace chromeos | 102 } // namespace chromeos |
95 | 103 |
96 #endif // CHROMEOS_COMPONENTS_TETHER_CONNECT_TETHERING_OPERATION_H_ | 104 #endif // CHROMEOS_COMPONENTS_TETHER_CONNECT_TETHERING_OPERATION_H_ |
OLD | NEW |