OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "device/bluetooth/bluetooth_adapter_bluez.h" | 5 #include "device/bluetooth/bluetooth_adapter_bluez.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/location.h" | 11 #include "base/location.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
13 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
15 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "device/bluetooth/bluetooth_adapter_profile_bluez.h" | 18 #include "device/bluetooth/bluetooth_adapter_profile_bluez.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 weak_ptr_factory_.GetWeakPtr(), callback, | 339 weak_ptr_factory_.GetWeakPtr(), callback, |
339 error_callback, audio_sink), | 340 error_callback, audio_sink), |
340 error_callback); | 341 error_callback); |
341 } | 342 } |
342 | 343 |
343 void BluetoothAdapterBlueZ::RegisterAdvertisement( | 344 void BluetoothAdapterBlueZ::RegisterAdvertisement( |
344 scoped_ptr<device::BluetoothAdvertisement::Data> advertisement_data, | 345 scoped_ptr<device::BluetoothAdvertisement::Data> advertisement_data, |
345 const CreateAdvertisementCallback& callback, | 346 const CreateAdvertisementCallback& callback, |
346 const CreateAdvertisementErrorCallback& error_callback) { | 347 const CreateAdvertisementErrorCallback& error_callback) { |
347 scoped_refptr<BluetoothAdvertisementBlueZ> advertisement( | 348 scoped_refptr<BluetoothAdvertisementBlueZ> advertisement( |
348 new BluetoothAdvertisementBlueZ(advertisement_data.Pass(), this)); | 349 new BluetoothAdvertisementBlueZ(std::move(advertisement_data), this)); |
349 advertisement->Register(base::Bind(callback, advertisement), error_callback); | 350 advertisement->Register(base::Bind(callback, advertisement), error_callback); |
350 } | 351 } |
351 | 352 |
352 void BluetoothAdapterBlueZ::RemovePairingDelegateInternal( | 353 void BluetoothAdapterBlueZ::RemovePairingDelegateInternal( |
353 BluetoothDevice::PairingDelegate* pairing_delegate) { | 354 BluetoothDevice::PairingDelegate* pairing_delegate) { |
354 // Check if any device is using the pairing delegate. | 355 // Check if any device is using the pairing delegate. |
355 // If so, clear the pairing context which will make any responses no-ops. | 356 // If so, clear the pairing context which will make any responses no-ops. |
356 for (DevicesMap::const_iterator iter = devices_.begin(); | 357 for (DevicesMap::const_iterator iter = devices_.begin(); |
357 iter != devices_.end(); ++iter) { | 358 iter != devices_.end(); ++iter) { |
358 BluetoothDeviceBlueZ* device_bluez = | 359 BluetoothDeviceBlueZ* device_bluez = |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 // There are no active discovery sessions. | 1192 // There are no active discovery sessions. |
1192 DCHECK_EQ(num_discovery_sessions_, 0); | 1193 DCHECK_EQ(num_discovery_sessions_, 0); |
1193 | 1194 |
1194 if (discovery_filter) { | 1195 if (discovery_filter) { |
1195 discovery_request_pending_ = true; | 1196 discovery_request_pending_ = true; |
1196 | 1197 |
1197 scoped_ptr<BluetoothDiscoveryFilter> df(new BluetoothDiscoveryFilter( | 1198 scoped_ptr<BluetoothDiscoveryFilter> df(new BluetoothDiscoveryFilter( |
1198 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL)); | 1199 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL)); |
1199 df->CopyFrom(*discovery_filter); | 1200 df->CopyFrom(*discovery_filter); |
1200 SetDiscoveryFilter( | 1201 SetDiscoveryFilter( |
1201 df.Pass(), | 1202 std::move(df), |
1202 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter, | 1203 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter, |
1203 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), | 1204 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), |
1204 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError, | 1205 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError, |
1205 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); | 1206 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
1206 return; | 1207 return; |
1207 } else { | 1208 } else { |
1208 current_filter_.reset(); | 1209 current_filter_.reset(); |
1209 } | 1210 } |
1210 | 1211 |
1211 // This is the first request to start device discovery. | 1212 // This is the first request to start device discovery. |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 | 1504 |
1504 // If the queued request resulted in a pending call, then let it | 1505 // If the queued request resulted in a pending call, then let it |
1505 // asynchonously process the remaining queued requests once the pending | 1506 // asynchonously process the remaining queued requests once the pending |
1506 // call returns. | 1507 // call returns. |
1507 if (discovery_request_pending_) | 1508 if (discovery_request_pending_) |
1508 return; | 1509 return; |
1509 } | 1510 } |
1510 } | 1511 } |
1511 | 1512 |
1512 } // namespace bluez | 1513 } // namespace bluez |
OLD | NEW |