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_IMPL_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_IMPL_H |
6 #define COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_IMPL_H | 6 #define COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_IMPL_H |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "components/cryptauth/remote_device.h" |
14 #include "components/proximity_auth/authenticator.h" | 15 #include "components/proximity_auth/authenticator.h" |
15 #include "components/proximity_auth/messenger_observer.h" | 16 #include "components/proximity_auth/messenger_observer.h" |
16 #include "components/proximity_auth/remote_device.h" | |
17 #include "components/proximity_auth/remote_device_life_cycle.h" | 17 #include "components/proximity_auth/remote_device_life_cycle.h" |
18 | 18 |
19 namespace proximity_auth { | 19 namespace proximity_auth { |
20 | 20 |
21 class BluetoothThrottler; | 21 class BluetoothThrottler; |
22 class Messenger; | 22 class Messenger; |
23 class Connection; | 23 class Connection; |
24 class ConnectionFinder; | 24 class ConnectionFinder; |
25 class ProximityAuthClient; | 25 class ProximityAuthClient; |
26 class SecureContext; | 26 class SecureContext; |
27 | 27 |
28 // Implementation of RemoteDeviceLifeCycle. | 28 // Implementation of RemoteDeviceLifeCycle. |
29 class RemoteDeviceLifeCycleImpl : public RemoteDeviceLifeCycle, | 29 class RemoteDeviceLifeCycleImpl : public RemoteDeviceLifeCycle, |
30 public MessengerObserver { | 30 public MessengerObserver { |
31 public: | 31 public: |
32 // Creates the life cycle for controlling the given |remote_device|. | 32 // Creates the life cycle for controlling the given |remote_device|. |
33 // |proximity_auth_client| is not owned. | 33 // |proximity_auth_client| is not owned. |
34 RemoteDeviceLifeCycleImpl(const RemoteDevice& remote_device, | 34 RemoteDeviceLifeCycleImpl(const cryptauth::RemoteDevice& remote_device, |
35 ProximityAuthClient* proximity_auth_client); | 35 ProximityAuthClient* proximity_auth_client); |
36 ~RemoteDeviceLifeCycleImpl() override; | 36 ~RemoteDeviceLifeCycleImpl() override; |
37 | 37 |
38 // RemoteDeviceLifeCycle: | 38 // RemoteDeviceLifeCycle: |
39 void Start() override; | 39 void Start() override; |
40 RemoteDevice GetRemoteDevice() const override; | 40 cryptauth::RemoteDevice GetRemoteDevice() const override; |
41 RemoteDeviceLifeCycle::State GetState() const override; | 41 RemoteDeviceLifeCycle::State GetState() const override; |
42 Messenger* GetMessenger() override; | 42 Messenger* GetMessenger() override; |
43 void AddObserver(Observer* observer) override; | 43 void AddObserver(Observer* observer) override; |
44 void RemoveObserver(Observer* observer) override; | 44 void RemoveObserver(Observer* observer) override; |
45 | 45 |
46 protected: | 46 protected: |
47 // Creates and returns a ConnectionFinder instance for |remote_device_|. | 47 // Creates and returns a ConnectionFinder instance for |remote_device_|. |
48 // Exposed for testing. | 48 // Exposed for testing. |
49 virtual std::unique_ptr<ConnectionFinder> CreateConnectionFinder(); | 49 virtual std::unique_ptr<ConnectionFinder> CreateConnectionFinder(); |
50 | 50 |
(...skipping 16 matching lines...) Expand all Loading... |
67 void OnAuthenticationResult(Authenticator::Result result, | 67 void OnAuthenticationResult(Authenticator::Result result, |
68 std::unique_ptr<SecureContext> secure_context); | 68 std::unique_ptr<SecureContext> secure_context); |
69 | 69 |
70 // Creates the messenger which parses status updates. | 70 // Creates the messenger which parses status updates. |
71 void CreateMessenger(); | 71 void CreateMessenger(); |
72 | 72 |
73 // MessengerObserver: | 73 // MessengerObserver: |
74 void OnDisconnected() override; | 74 void OnDisconnected() override; |
75 | 75 |
76 // The remote device being controlled. | 76 // The remote device being controlled. |
77 const RemoteDevice remote_device_; | 77 const cryptauth::RemoteDevice remote_device_; |
78 | 78 |
79 // Used to grab dependencies in chrome. Not owned. | 79 // Used to grab dependencies in chrome. Not owned. |
80 ProximityAuthClient* proximity_auth_client_; | 80 ProximityAuthClient* proximity_auth_client_; |
81 | 81 |
82 // The current state in the life cycle. | 82 // The current state in the life cycle. |
83 RemoteDeviceLifeCycle::State state_; | 83 RemoteDeviceLifeCycle::State state_; |
84 | 84 |
85 // Observers added to the life cycle. Configured as NOTIFY_EXISTING_ONLY. | 85 // Observers added to the life cycle. Configured as NOTIFY_EXISTING_ONLY. |
86 base::ObserverList<Observer> observers_; | 86 base::ObserverList<Observer> observers_; |
87 | 87 |
(...skipping 25 matching lines...) Expand all Loading... |
113 base::OneShotTimer authentication_recovery_timer_; | 113 base::OneShotTimer authentication_recovery_timer_; |
114 | 114 |
115 base::WeakPtrFactory<RemoteDeviceLifeCycleImpl> weak_ptr_factory_; | 115 base::WeakPtrFactory<RemoteDeviceLifeCycleImpl> weak_ptr_factory_; |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(RemoteDeviceLifeCycleImpl); | 117 DISALLOW_COPY_AND_ASSIGN(RemoteDeviceLifeCycleImpl); |
118 }; | 118 }; |
119 | 119 |
120 } // namespace proximity_auth | 120 } // namespace proximity_auth |
121 | 121 |
122 #endif // COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_IMPL_H | 122 #endif // COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_IMPL_H |
OLD | NEW |