OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H |
6 #define COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H | 6 #define COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/cryptauth/connection.h" |
9 #include "components/cryptauth/remote_device.h" | 10 #include "components/cryptauth/remote_device.h" |
10 | 11 |
11 namespace proximity_auth { | 12 namespace proximity_auth { |
12 | 13 |
13 class Messenger; | 14 class Messenger; |
14 | 15 |
15 // Controls the life cycle of connecting and authenticating to a remote device. | 16 // Controls the life cycle of connecting and authenticating to a remote device. |
16 // After the life cycle is started, it can be in the following states: | 17 // After the life cycle is started, it can be in the following states: |
17 // FINDING_CONNECTION: | 18 // FINDING_CONNECTION: |
18 // Continuiously attempts to create a connection to the remote device. | 19 // Continuiously attempts to create a connection to the remote device. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 }; | 51 }; |
51 | 52 |
52 virtual ~RemoteDeviceLifeCycle() {} | 53 virtual ~RemoteDeviceLifeCycle() {} |
53 | 54 |
54 // Starts the life cycle. | 55 // Starts the life cycle. |
55 virtual void Start() = 0; | 56 virtual void Start() = 0; |
56 | 57 |
57 // Returns the RemoteDevice instance that this life cycle manages. | 58 // Returns the RemoteDevice instance that this life cycle manages. |
58 virtual cryptauth::RemoteDevice GetRemoteDevice() const = 0; | 59 virtual cryptauth::RemoteDevice GetRemoteDevice() const = 0; |
59 | 60 |
| 61 // Returns the current Connection, or null if the device is not yet connected. |
| 62 virtual cryptauth::Connection* GetConnection() const = 0; |
| 63 |
60 // Returns the current state of in the life cycle. | 64 // Returns the current state of in the life cycle. |
61 virtual State GetState() const = 0; | 65 virtual State GetState() const = 0; |
62 | 66 |
63 // Returns the client for sending and receiving messages. This function will | 67 // Returns the client for sending and receiving messages. This function will |
64 // only return an instance if the state is SECURE_CHANNEL_ESTABLISHED; | 68 // only return an instance if the state is SECURE_CHANNEL_ESTABLISHED; |
65 // otherwise, it will return nullptr. | 69 // otherwise, it will return nullptr. |
66 virtual Messenger* GetMessenger() = 0; | 70 virtual Messenger* GetMessenger() = 0; |
67 | 71 |
68 // Adds an observer. | 72 // Adds an observer. |
69 virtual void AddObserver(Observer* observer) = 0; | 73 virtual void AddObserver(Observer* observer) = 0; |
70 | 74 |
71 // Removes an observer. | 75 // Removes an observer. |
72 virtual void RemoveObserver(Observer* observer) = 0; | 76 virtual void RemoveObserver(Observer* observer) = 0; |
73 }; | 77 }; |
74 | 78 |
75 } // namespace proximity_auth | 79 } // namespace proximity_auth |
76 | 80 |
77 #endif // COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H | 81 #endif // COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H |
OLD | NEW |