Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: components/proximity_auth/remote_device_life_cycle_impl.cc

Issue 2561203002: Migrate weave-related classes from proximity_auth/ble to cryptauth/ble. (Closed)
Patch Set: Moved all general classes from proximity_auth to cryptauth. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/location.h" 10 #include "base/location.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "base/time/default_tick_clock.h" 13 #include "base/time/default_tick_clock.h"
14 #include "components/cryptauth/bluetooth_throttler_impl.h"
14 #include "components/cryptauth/secure_message_delegate.h" 15 #include "components/cryptauth/secure_message_delegate.h"
15 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h" 16 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h"
16 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h " 17 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h "
17 #include "components/proximity_auth/bluetooth_connection.h" 18 #include "components/proximity_auth/bluetooth_connection.h"
18 #include "components/proximity_auth/bluetooth_connection_finder.h" 19 #include "components/proximity_auth/bluetooth_connection_finder.h"
19 #include "components/proximity_auth/bluetooth_throttler_impl.h"
20 #include "components/proximity_auth/device_to_device_authenticator.h" 20 #include "components/proximity_auth/device_to_device_authenticator.h"
21 #include "components/proximity_auth/logging/logging.h" 21 #include "components/proximity_auth/logging/logging.h"
22 #include "components/proximity_auth/messenger_impl.h" 22 #include "components/proximity_auth/messenger_impl.h"
23 #include "components/proximity_auth/proximity_auth_client.h" 23 #include "components/proximity_auth/proximity_auth_client.h"
24 #include "components/proximity_auth/secure_context.h" 24 #include "components/proximity_auth/secure_context.h"
25 25
26 namespace proximity_auth { 26 namespace proximity_auth {
27 27
28 namespace { 28 namespace {
29 29
(...skipping 10 matching lines...) Expand all
40 40
41 } // namespace 41 } // namespace
42 42
43 RemoteDeviceLifeCycleImpl::RemoteDeviceLifeCycleImpl( 43 RemoteDeviceLifeCycleImpl::RemoteDeviceLifeCycleImpl(
44 const cryptauth::RemoteDevice& remote_device, 44 const cryptauth::RemoteDevice& remote_device,
45 ProximityAuthClient* proximity_auth_client) 45 ProximityAuthClient* proximity_auth_client)
46 : remote_device_(remote_device), 46 : remote_device_(remote_device),
47 proximity_auth_client_(proximity_auth_client), 47 proximity_auth_client_(proximity_auth_client),
48 state_(RemoteDeviceLifeCycle::State::STOPPED), 48 state_(RemoteDeviceLifeCycle::State::STOPPED),
49 observers_(base::ObserverList<Observer>::NOTIFY_EXISTING_ONLY), 49 observers_(base::ObserverList<Observer>::NOTIFY_EXISTING_ONLY),
50 bluetooth_throttler_(new BluetoothThrottlerImpl( 50 bluetooth_throttler_(new cryptauth::BluetoothThrottlerImpl(
51 base::WrapUnique(new base::DefaultTickClock()))), 51 base::WrapUnique(new base::DefaultTickClock()))),
52 weak_ptr_factory_(this) {} 52 weak_ptr_factory_(this) {}
53 53
54 RemoteDeviceLifeCycleImpl::~RemoteDeviceLifeCycleImpl() {} 54 RemoteDeviceLifeCycleImpl::~RemoteDeviceLifeCycleImpl() {}
55 55
56 void RemoteDeviceLifeCycleImpl::Start() { 56 void RemoteDeviceLifeCycleImpl::Start() {
57 PA_LOG(INFO) << "Life cycle for " << remote_device_.bluetooth_address 57 PA_LOG(INFO) << "Life cycle for " << remote_device_.bluetooth_address
58 << " started."; 58 << " started.";
59 DCHECK(state_ == RemoteDeviceLifeCycle::State::STOPPED); 59 DCHECK(state_ == RemoteDeviceLifeCycle::State::STOPPED);
60 FindConnection(); 60 FindConnection();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 void RemoteDeviceLifeCycleImpl::FindConnection() { 114 void RemoteDeviceLifeCycleImpl::FindConnection() {
115 connection_finder_ = CreateConnectionFinder(); 115 connection_finder_ = CreateConnectionFinder();
116 connection_finder_->Find( 116 connection_finder_->Find(
117 base::Bind(&RemoteDeviceLifeCycleImpl::OnConnectionFound, 117 base::Bind(&RemoteDeviceLifeCycleImpl::OnConnectionFound,
118 weak_ptr_factory_.GetWeakPtr())); 118 weak_ptr_factory_.GetWeakPtr()));
119 TransitionToState(RemoteDeviceLifeCycle::State::FINDING_CONNECTION); 119 TransitionToState(RemoteDeviceLifeCycle::State::FINDING_CONNECTION);
120 } 120 }
121 121
122 void RemoteDeviceLifeCycleImpl::OnConnectionFound( 122 void RemoteDeviceLifeCycleImpl::OnConnectionFound(
123 std::unique_ptr<Connection> connection) { 123 std::unique_ptr<cryptauth::Connection> connection) {
124 DCHECK(state_ == RemoteDeviceLifeCycle::State::FINDING_CONNECTION); 124 DCHECK(state_ == RemoteDeviceLifeCycle::State::FINDING_CONNECTION);
125 connection_ = std::move(connection); 125 connection_ = std::move(connection);
126 authenticator_ = CreateAuthenticator(); 126 authenticator_ = CreateAuthenticator();
127 authenticator_->Authenticate( 127 authenticator_->Authenticate(
128 base::Bind(&RemoteDeviceLifeCycleImpl::OnAuthenticationResult, 128 base::Bind(&RemoteDeviceLifeCycleImpl::OnAuthenticationResult,
129 weak_ptr_factory_.GetWeakPtr())); 129 weak_ptr_factory_.GetWeakPtr()));
130 TransitionToState(RemoteDeviceLifeCycle::State::AUTHENTICATING); 130 TransitionToState(RemoteDeviceLifeCycle::State::AUTHENTICATING);
131 } 131 }
132 132
133 void RemoteDeviceLifeCycleImpl::OnAuthenticationResult( 133 void RemoteDeviceLifeCycleImpl::OnAuthenticationResult(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); 166 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED);
167 } 167 }
168 168
169 void RemoteDeviceLifeCycleImpl::OnDisconnected() { 169 void RemoteDeviceLifeCycleImpl::OnDisconnected() {
170 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); 170 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED);
171 messenger_.reset(); 171 messenger_.reset();
172 FindConnection(); 172 FindConnection();
173 } 173 }
174 174
175 } // namespace proximity_auth 175 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698