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

Side by Side Diff: components/proximity_auth/ble/bluetooth_low_energy_connection_finder.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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
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/ble/bluetooth_low_energy_connection_finder.h " 5 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h "
6 6
7 #include <string> 7 #include <string>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
16 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h" 17 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h"
17 #include "components/proximity_auth/ble/bluetooth_low_energy_device_whitelist.h" 18 #include "components/proximity_auth/ble/bluetooth_low_energy_device_whitelist.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Note: It's possible to connect to the paired directly, so when using 204 // Note: It's possible to connect to the paired directly, so when using
204 // FIND_PAIRED_DEVICE strategy this is not necessary. However, the discovery 205 // FIND_PAIRED_DEVICE strategy this is not necessary. However, the discovery
205 // doesn't add a lot of latency, and the makes the code path for both 206 // doesn't add a lot of latency, and the makes the code path for both
206 // strategies more similar. 207 // strategies more similar.
207 StartDiscoverySession(); 208 StartDiscoverySession();
208 } 209 }
209 210
210 void BluetoothLowEnergyConnectionFinder::OnDiscoverySessionStarted( 211 void BluetoothLowEnergyConnectionFinder::OnDiscoverySessionStarted(
211 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { 212 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) {
212 PA_LOG(INFO) << "Discovery session started"; 213 PA_LOG(INFO) << "Discovery session started";
213 discovery_session_ = discovery_session.Pass(); 214 discovery_session_ = std::move(discovery_session);
214 } 215 }
215 216
216 void BluetoothLowEnergyConnectionFinder::OnStartDiscoverySessionError() { 217 void BluetoothLowEnergyConnectionFinder::OnStartDiscoverySessionError() {
217 PA_LOG(WARNING) << "Error starting discovery session"; 218 PA_LOG(WARNING) << "Error starting discovery session";
218 } 219 }
219 220
220 void BluetoothLowEnergyConnectionFinder::StartDiscoverySession() { 221 void BluetoothLowEnergyConnectionFinder::StartDiscoverySession() {
221 DCHECK(adapter_); 222 DCHECK(adapter_);
222 if (discovery_session_ && discovery_session_->IsActive()) { 223 if (discovery_session_ && discovery_session_->IsActive()) {
223 PA_LOG(INFO) << "Discovery session already active"; 224 PA_LOG(INFO) << "Discovery session already active";
224 return; 225 return;
225 } 226 }
226 227
227 // Discover only low energy (LE) devices with strong enough signal. 228 // Discover only low energy (LE) devices with strong enough signal.
228 scoped_ptr<BluetoothDiscoveryFilter> filter(new BluetoothDiscoveryFilter( 229 scoped_ptr<BluetoothDiscoveryFilter> filter(new BluetoothDiscoveryFilter(
229 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE)); 230 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE));
230 filter->SetRSSI(kMinDiscoveryRSSI); 231 filter->SetRSSI(kMinDiscoveryRSSI);
231 232
232 adapter_->StartDiscoverySessionWithFilter( 233 adapter_->StartDiscoverySessionWithFilter(
233 filter.Pass(), 234 std::move(filter),
234 base::Bind(&BluetoothLowEnergyConnectionFinder::OnDiscoverySessionStarted, 235 base::Bind(&BluetoothLowEnergyConnectionFinder::OnDiscoverySessionStarted,
235 weak_ptr_factory_.GetWeakPtr()), 236 weak_ptr_factory_.GetWeakPtr()),
236 base::Bind( 237 base::Bind(
237 &BluetoothLowEnergyConnectionFinder::OnStartDiscoverySessionError, 238 &BluetoothLowEnergyConnectionFinder::OnStartDiscoverySessionError,
238 weak_ptr_factory_.GetWeakPtr())); 239 weak_ptr_factory_.GetWeakPtr()));
239 } 240 }
240 241
241 void BluetoothLowEnergyConnectionFinder::StopDiscoverySession() { 242 void BluetoothLowEnergyConnectionFinder::StopDiscoverySession() {
242 PA_LOG(INFO) << "Stopping discovery session"; 243 PA_LOG(INFO) << "Stopping discovery session";
243 // Destroying the discovery session also stops it. 244 // Destroying the discovery session also stops it.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // (see crbug.com/497841). 304 // (see crbug.com/497841).
304 std::vector<BluetoothDevice*> devices = adapter_->GetDevices(); 305 std::vector<BluetoothDevice*> devices = adapter_->GetDevices();
305 for (const auto& device : devices) { 306 for (const auto& device : devices) {
306 if (device->GetAddress() == device_address) 307 if (device->GetAddress() == device_address)
307 return device; 308 return device;
308 } 309 }
309 return nullptr; 310 return nullptr;
310 } 311 }
311 312
312 void BluetoothLowEnergyConnectionFinder::InvokeCallbackAsync() { 313 void BluetoothLowEnergyConnectionFinder::InvokeCallbackAsync() {
313 connection_callback_.Run(connection_.Pass()); 314 connection_callback_.Run(std::move(connection_));
314 } 315 }
315 316
316 } // namespace proximity_auth 317 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698