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

Side by Side Diff: device/bluetooth/bluez/bluetooth_adapter_bluez.cc

Issue 2063353002: device/bluetooth: split out transport enum (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing new use in components/arc/bluetooth Created 4 years, 6 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 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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 callback, error_callback); 1274 callback, error_callback);
1274 return; 1275 return;
1275 } 1276 }
1276 1277
1277 // There are no active discovery sessions. 1278 // There are no active discovery sessions.
1278 DCHECK_EQ(num_discovery_sessions_, 0); 1279 DCHECK_EQ(num_discovery_sessions_, 0);
1279 1280
1280 if (discovery_filter) { 1281 if (discovery_filter) {
1281 discovery_request_pending_ = true; 1282 discovery_request_pending_ = true;
1282 1283
1283 std::unique_ptr<BluetoothDiscoveryFilter> df(new BluetoothDiscoveryFilter( 1284 std::unique_ptr<BluetoothDiscoveryFilter> df(
1284 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL)); 1285 new BluetoothDiscoveryFilter(device::BLUETOOTH_TRANSPORT_DUAL));
1285 df->CopyFrom(*discovery_filter); 1286 df->CopyFrom(*discovery_filter);
1286 SetDiscoveryFilter( 1287 SetDiscoveryFilter(
1287 std::move(df), 1288 std::move(df),
1288 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter, 1289 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter,
1289 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), 1290 weak_ptr_factory_.GetWeakPtr(), callback, error_callback),
1290 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError, 1291 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError,
1291 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); 1292 weak_ptr_factory_.GetWeakPtr(), callback, error_callback));
1292 return; 1293 return;
1293 } else { 1294 } else {
1294 current_filter_.reset(); 1295 current_filter_.reset();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 uint8_t transport; 1392 uint8_t transport;
1392 std::set<device::BluetoothUUID> uuids; 1393 std::set<device::BluetoothUUID> uuids;
1393 1394
1394 if (current_filter_->GetPathloss(&pathloss)) 1395 if (current_filter_->GetPathloss(&pathloss))
1395 dbus_discovery_filter.pathloss.reset(new uint16_t(pathloss)); 1396 dbus_discovery_filter.pathloss.reset(new uint16_t(pathloss));
1396 1397
1397 if (current_filter_->GetRSSI(&rssi)) 1398 if (current_filter_->GetRSSI(&rssi))
1398 dbus_discovery_filter.rssi.reset(new int16_t(rssi)); 1399 dbus_discovery_filter.rssi.reset(new int16_t(rssi));
1399 1400
1400 transport = current_filter_->GetTransport(); 1401 transport = current_filter_->GetTransport();
1401 if (transport == BluetoothDiscoveryFilter::Transport::TRANSPORT_LE) { 1402 if (transport == device::BLUETOOTH_TRANSPORT_LE) {
1402 dbus_discovery_filter.transport.reset(new std::string("le")); 1403 dbus_discovery_filter.transport.reset(new std::string("le"));
1403 } else if (transport == 1404 } else if (transport == device::BLUETOOTH_TRANSPORT_CLASSIC) {
1404 BluetoothDiscoveryFilter::Transport::TRANSPORT_CLASSIC) {
1405 dbus_discovery_filter.transport.reset(new std::string("bredr")); 1405 dbus_discovery_filter.transport.reset(new std::string("bredr"));
1406 } else if (transport == 1406 } else if (transport == device::BLUETOOTH_TRANSPORT_DUAL) {
1407 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL) {
1408 dbus_discovery_filter.transport.reset(new std::string("auto")); 1407 dbus_discovery_filter.transport.reset(new std::string("auto"));
1409 } 1408 }
1410 1409
1411 current_filter_->GetUUIDs(uuids); 1410 current_filter_->GetUUIDs(uuids);
1412 if (uuids.size()) { 1411 if (uuids.size()) {
1413 dbus_discovery_filter.uuids = std::unique_ptr<std::vector<std::string>>( 1412 dbus_discovery_filter.uuids = std::unique_ptr<std::vector<std::string>>(
1414 new std::vector<std::string>); 1413 new std::vector<std::string>);
1415 1414
1416 for (const auto& it : uuids) 1415 for (const auto& it : uuids)
1417 dbus_discovery_filter.uuids.get()->push_back(it.value()); 1416 dbus_discovery_filter.uuids.get()->push_back(it.value());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 1642
1644 void BluetoothAdapterBlueZ::RegisterApplicationOnError( 1643 void BluetoothAdapterBlueZ::RegisterApplicationOnError(
1645 const base::Closure& callback, 1644 const base::Closure& callback,
1646 const device::BluetoothGattService::ErrorCallback& error_callback, 1645 const device::BluetoothGattService::ErrorCallback& error_callback,
1647 const std::string& /* error_name */, 1646 const std::string& /* error_name */,
1648 const std::string& /* error_message */) { 1647 const std::string& /* error_message */) {
1649 RegisterApplication(callback, error_callback); 1648 RegisterApplication(callback, error_callback);
1650 } 1649 }
1651 1650
1652 } // namespace bluez 1651 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_discovery_filter_unittest.cc ('k') | device/bluetooth/bluez/bluetooth_bluez_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698