| 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/bluez/bluetooth_adapter_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "device/bluetooth/bluetooth_common.h" |
| 21 #include "device/bluetooth/bluetooth_device.h" | 22 #include "device/bluetooth/bluetooth_device.h" |
| 22 #include "device/bluetooth/bluetooth_discovery_session_outcome.h" | 23 #include "device/bluetooth/bluetooth_discovery_session_outcome.h" |
| 23 #include "device/bluetooth/bluetooth_socket_thread.h" | 24 #include "device/bluetooth/bluetooth_socket_thread.h" |
| 24 #include "device/bluetooth/bluetooth_uuid.h" | 25 #include "device/bluetooth/bluetooth_uuid.h" |
| 25 #include "device/bluetooth/bluez/bluetooth_adapter_profile_bluez.h" | 26 #include "device/bluetooth/bluez/bluetooth_adapter_profile_bluez.h" |
| 26 #include "device/bluetooth/bluez/bluetooth_advertisement_bluez.h" | 27 #include "device/bluetooth/bluez/bluetooth_advertisement_bluez.h" |
| 27 #include "device/bluetooth/bluez/bluetooth_audio_sink_bluez.h" | 28 #include "device/bluetooth/bluez/bluetooth_audio_sink_bluez.h" |
| 28 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" | 29 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" |
| 29 #include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h" | 30 #include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h" |
| 30 #include "device/bluetooth/bluez/bluetooth_local_gatt_characteristic_bluez.h" | 31 #include "device/bluetooth/bluez/bluetooth_local_gatt_characteristic_bluez.h" |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 callback, error_callback); | 1267 callback, error_callback); |
| 1267 return; | 1268 return; |
| 1268 } | 1269 } |
| 1269 | 1270 |
| 1270 // There are no active discovery sessions. | 1271 // There are no active discovery sessions. |
| 1271 DCHECK_EQ(num_discovery_sessions_, 0); | 1272 DCHECK_EQ(num_discovery_sessions_, 0); |
| 1272 | 1273 |
| 1273 if (discovery_filter) { | 1274 if (discovery_filter) { |
| 1274 discovery_request_pending_ = true; | 1275 discovery_request_pending_ = true; |
| 1275 | 1276 |
| 1276 std::unique_ptr<BluetoothDiscoveryFilter> df(new BluetoothDiscoveryFilter( | 1277 std::unique_ptr<BluetoothDiscoveryFilter> df( |
| 1277 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL)); | 1278 new BluetoothDiscoveryFilter(device::BLUETOOTH_TRANSPORT_DUAL)); |
| 1278 df->CopyFrom(*discovery_filter); | 1279 df->CopyFrom(*discovery_filter); |
| 1279 SetDiscoveryFilter( | 1280 SetDiscoveryFilter( |
| 1280 std::move(df), | 1281 std::move(df), |
| 1281 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter, | 1282 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter, |
| 1282 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), | 1283 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), |
| 1283 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError, | 1284 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError, |
| 1284 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); | 1285 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
| 1285 return; | 1286 return; |
| 1286 } else { | 1287 } else { |
| 1287 current_filter_.reset(); | 1288 current_filter_.reset(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 uint8_t transport; | 1385 uint8_t transport; |
| 1385 std::set<device::BluetoothUUID> uuids; | 1386 std::set<device::BluetoothUUID> uuids; |
| 1386 | 1387 |
| 1387 if (current_filter_->GetPathloss(&pathloss)) | 1388 if (current_filter_->GetPathloss(&pathloss)) |
| 1388 dbus_discovery_filter.pathloss.reset(new uint16_t(pathloss)); | 1389 dbus_discovery_filter.pathloss.reset(new uint16_t(pathloss)); |
| 1389 | 1390 |
| 1390 if (current_filter_->GetRSSI(&rssi)) | 1391 if (current_filter_->GetRSSI(&rssi)) |
| 1391 dbus_discovery_filter.rssi.reset(new int16_t(rssi)); | 1392 dbus_discovery_filter.rssi.reset(new int16_t(rssi)); |
| 1392 | 1393 |
| 1393 transport = current_filter_->GetTransport(); | 1394 transport = current_filter_->GetTransport(); |
| 1394 if (transport == BluetoothDiscoveryFilter::Transport::TRANSPORT_LE) { | 1395 if (transport == device::BLUETOOTH_TRANSPORT_LE) { |
| 1395 dbus_discovery_filter.transport.reset(new std::string("le")); | 1396 dbus_discovery_filter.transport.reset(new std::string("le")); |
| 1396 } else if (transport == | 1397 } else if (transport == device::BLUETOOTH_TRANSPORT_CLASSIC) { |
| 1397 BluetoothDiscoveryFilter::Transport::TRANSPORT_CLASSIC) { | |
| 1398 dbus_discovery_filter.transport.reset(new std::string("bredr")); | 1398 dbus_discovery_filter.transport.reset(new std::string("bredr")); |
| 1399 } else if (transport == | 1399 } else if (transport == device::BLUETOOTH_TRANSPORT_DUAL) { |
| 1400 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL) { | |
| 1401 dbus_discovery_filter.transport.reset(new std::string("auto")); | 1400 dbus_discovery_filter.transport.reset(new std::string("auto")); |
| 1402 } | 1401 } |
| 1403 | 1402 |
| 1404 current_filter_->GetUUIDs(uuids); | 1403 current_filter_->GetUUIDs(uuids); |
| 1405 if (uuids.size()) { | 1404 if (uuids.size()) { |
| 1406 dbus_discovery_filter.uuids = std::unique_ptr<std::vector<std::string>>( | 1405 dbus_discovery_filter.uuids = std::unique_ptr<std::vector<std::string>>( |
| 1407 new std::vector<std::string>); | 1406 new std::vector<std::string>); |
| 1408 | 1407 |
| 1409 for (const auto& it : uuids) | 1408 for (const auto& it : uuids) |
| 1410 dbus_discovery_filter.uuids.get()->push_back(it.value()); | 1409 dbus_discovery_filter.uuids.get()->push_back(it.value()); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 | 1635 |
| 1637 void BluetoothAdapterBlueZ::RegisterApplicationOnError( | 1636 void BluetoothAdapterBlueZ::RegisterApplicationOnError( |
| 1638 const base::Closure& callback, | 1637 const base::Closure& callback, |
| 1639 const device::BluetoothGattService::ErrorCallback& error_callback, | 1638 const device::BluetoothGattService::ErrorCallback& error_callback, |
| 1640 const std::string& /* error_name */, | 1639 const std::string& /* error_name */, |
| 1641 const std::string& /* error_message */) { | 1640 const std::string& /* error_message */) { |
| 1642 RegisterApplication(callback, error_callback); | 1641 RegisterApplication(callback, error_callback); |
| 1643 } | 1642 } |
| 1644 | 1643 |
| 1645 } // namespace bluez | 1644 } // namespace bluez |
| OLD | NEW |