Cleanup: Pass std::string as const reference from pdf/
[chromium-blink-merge.git] / components / proximity_auth / remote_device_life_cycle.h
blob6c4db43c3807213c05c255179d0ed62767c3ccea
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H
6 #define COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H
8 #include "base/macros.h"
10 namespace proximity_auth {
12 class Authenticator;
13 class Client;
14 class ConnectionFinder;
16 // Controls the life cycle of connecting and authenticating to a remote device.
17 // After the life cycle is started, it can be in the following states:
18 // FINDING_CONNECTION:
19 // Continuiously attempts to create a connection to the remote device.
20 // After connecting, transitions to the AUTHENTICATING state.
21 // AUTHENTICATING:
22 // Verifies that the connected device has the correct credentials. On
23 // success, transitions to SECURE_CHANNEL_ESTABLISHED; otherwise,
24 // transitions to AUTHENTICATION_FAILED.
25 // SECURE_CHANNEL_ESTABLISHED:
26 // Can send and receive messages securely from the remote device. Upon
27 // disconnection, transitions to FINDING_CONNECTION.
28 // AUTHENTICATION_FAILED:
29 // Recovery state after authentication fails. After a brief wait,
30 // transition to FINDING_CONNECTION.
31 // To stop the life cycle and clean up the connection, simply destroying this
32 // object.
33 class RemoteDeviceLifeCycle {
34 public:
35 // The possible states in the life cycle.
36 enum class State {
37 STOPPED,
38 FINDING_CONNECTION,
39 AUTHENTICATING,
40 SECURE_CHANNEL_ESTABLISHED,
41 AUTHENTICATION_FAILED,
44 // Interface for observing changes to the life cycle.
45 class Observer {
46 public:
47 virtual ~Observer() {}
49 // Called when the state in the life cycle changes.
50 virtual void OnLifeCycleStateChanged(State old_state, State new_state) = 0;
53 virtual ~RemoteDeviceLifeCycle() {}
55 // Starts the life cycle.
56 virtual void Start() = 0;
58 // Returns the current state of in the life cycle.
59 virtual State GetState() const = 0;
61 // Returns the client for sending and receiving messages. This function will
62 // only return an instance if the state is SECURE_CHANNEL_ESTABLISHED;
63 // otherwise, it will return nullptr.
64 virtual Client* GetClient() = 0;
66 // Adds an observer.
67 virtual void AddObserver(Observer* observer) = 0;
69 // Removes an observer.
70 virtual void RemoveObserver(Observer* observer) = 0;
73 } // namespace proximity_auth
75 #endif // COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H