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

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

Issue 2900253005: BLE advertiser
Patch Set: Created 3 years, 7 months 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
« no previous file with comments | « components/proximity_auth/remote_device_life_cycle_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/time/default_tick_clock.h" 14 #include "base/time/default_tick_clock.h"
15 #include "components/cryptauth/bluetooth_throttler_impl.h" 15 #include "components/cryptauth/bluetooth_throttler_impl.h"
16 #include "components/cryptauth/connection_finder.h" 16 #include "components/cryptauth/connection_finder.h"
17 #include "components/cryptauth/device_to_device_authenticator.h" 17 #include "components/cryptauth/device_to_device_authenticator.h"
18 #include "components/cryptauth/secure_context.h" 18 #include "components/cryptauth/secure_context.h"
19 #include "components/cryptauth/secure_message_delegate.h" 19 #include "components/cryptauth/secure_message_delegate.h"
20 #include "components/proximity_auth/bluetooth_connection.h" 20 #include "components/proximity_auth/bluetooth_connection.h"
21 #include "components/proximity_auth/bluetooth_connection_finder.h" 21 #include "components/proximity_auth/bluetooth_connection_finder.h"
22 #include "components/proximity_auth/bluetooth_low_energy_advertiser.h"
22 #include "components/proximity_auth/bluetooth_low_energy_connection_finder.h" 23 #include "components/proximity_auth/bluetooth_low_energy_connection_finder.h"
23 #include "components/proximity_auth/logging/logging.h" 24 #include "components/proximity_auth/logging/logging.h"
24 #include "components/proximity_auth/messenger_impl.h" 25 #include "components/proximity_auth/messenger_impl.h"
25 #include "components/proximity_auth/proximity_auth_client.h" 26 #include "components/proximity_auth/proximity_auth_client.h"
26 #include "components/proximity_auth/switches.h" 27 #include "components/proximity_auth/switches.h"
27 28
28 namespace proximity_auth { 29 namespace proximity_auth {
29 30
30 namespace { 31 namespace {
31 32
(...skipping 17 matching lines...) Expand all
49 bluetooth_throttler_(cryptauth::BluetoothThrottlerImpl::GetInstance()), 50 bluetooth_throttler_(cryptauth::BluetoothThrottlerImpl::GetInstance()),
50 weak_ptr_factory_(this) {} 51 weak_ptr_factory_(this) {}
51 52
52 RemoteDeviceLifeCycleImpl::~RemoteDeviceLifeCycleImpl() {} 53 RemoteDeviceLifeCycleImpl::~RemoteDeviceLifeCycleImpl() {}
53 54
54 void RemoteDeviceLifeCycleImpl::Start() { 55 void RemoteDeviceLifeCycleImpl::Start() {
55 PA_LOG(INFO) << "Life cycle for " << remote_device_.bluetooth_address 56 PA_LOG(INFO) << "Life cycle for " << remote_device_.bluetooth_address
56 << " started."; 57 << " started.";
57 DCHECK(state_ == RemoteDeviceLifeCycle::State::STOPPED); 58 DCHECK(state_ == RemoteDeviceLifeCycle::State::STOPPED);
58 FindConnection(); 59 FindConnection();
60
61 advertiser_ = base::MakeUnique<BluetoothLowEnergyAdvertiser>();
62 advertiser_->Advertise();
59 } 63 }
60 64
61 cryptauth::RemoteDevice RemoteDeviceLifeCycleImpl::GetRemoteDevice() const { 65 cryptauth::RemoteDevice RemoteDeviceLifeCycleImpl::GetRemoteDevice() const {
62 return remote_device_; 66 return remote_device_;
63 } 67 }
64 68
65 cryptauth::Connection* RemoteDeviceLifeCycleImpl::GetConnection() const { 69 cryptauth::Connection* RemoteDeviceLifeCycleImpl::GetConnection() const {
66 if (connection_) 70 if (connection_)
67 return connection_.get(); 71 return connection_.get();
68 if (messenger_) 72 if (messenger_)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); 182 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED);
179 } 183 }
180 184
181 void RemoteDeviceLifeCycleImpl::OnDisconnected() { 185 void RemoteDeviceLifeCycleImpl::OnDisconnected() {
182 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); 186 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED);
183 messenger_.reset(); 187 messenger_.reset();
184 FindConnection(); 188 FindConnection();
185 } 189 }
186 190
187 } // namespace proximity_auth 191 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/remote_device_life_cycle_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698