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 #include "components/proximity_auth/remote_device_life_cycle_impl.h" | 5 #include "components/proximity_auth/remote_device_life_cycle_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) { | 85 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) { |
86 observers_.RemoveObserver(observer); | 86 observers_.RemoveObserver(observer); |
87 } | 87 } |
88 | 88 |
89 std::unique_ptr<cryptauth::ConnectionFinder> | 89 std::unique_ptr<cryptauth::ConnectionFinder> |
90 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() { | 90 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() { |
91 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 91 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
92 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { | 92 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { |
93 cryptauth::RemoteBeaconSeedFetcher fetcher( | |
94 proximity_auth_client_->GetCryptAuthDeviceManager()); | |
95 std::vector<cryptauth::BeaconSeed> beacon_seeds; | |
96 if (!fetcher.FetchSeedsForDevice(remote_device_, &beacon_seeds)) { | |
97 PA_LOG(ERROR) << "Unable to fetch BeaconSeeds for " | |
98 << remote_device_.name; | |
99 return nullptr; | |
100 } | |
101 | |
102 return base::MakeUnique<BluetoothLowEnergyConnectionFinder>( | 93 return base::MakeUnique<BluetoothLowEnergyConnectionFinder>( |
103 remote_device_, beacon_seeds, bluetooth_throttler_); | 94 remote_device_, bluetooth_throttler_); |
104 } else { | 95 } else { |
105 return base::MakeUnique<BluetoothConnectionFinder>( | 96 return base::MakeUnique<BluetoothConnectionFinder>( |
106 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID), | 97 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID), |
107 base::TimeDelta::FromSeconds(3)); | 98 base::TimeDelta::FromSeconds(3)); |
108 } | 99 } |
109 } | 100 } |
110 | 101 |
111 std::unique_ptr<cryptauth::Authenticator> | 102 std::unique_ptr<cryptauth::Authenticator> |
112 RemoteDeviceLifeCycleImpl::CreateAuthenticator() { | 103 RemoteDeviceLifeCycleImpl::CreateAuthenticator() { |
113 return base::MakeUnique<cryptauth::DeviceToDeviceAuthenticator>( | 104 return base::MakeUnique<cryptauth::DeviceToDeviceAuthenticator>( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 178 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
188 } | 179 } |
189 | 180 |
190 void RemoteDeviceLifeCycleImpl::OnDisconnected() { | 181 void RemoteDeviceLifeCycleImpl::OnDisconnected() { |
191 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 182 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
192 messenger_.reset(); | 183 messenger_.reset(); |
193 FindConnection(); | 184 FindConnection(); |
194 } | 185 } |
195 | 186 |
196 } // namespace proximity_auth | 187 } // namespace proximity_auth |
OLD | NEW |