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

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: renaming header, moving TransportMask back into filter 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_device.h" 21 #include "device/bluetooth/bluetooth_device.h"
22 #include "device/bluetooth/bluetooth_discovery_session_outcome.h" 22 #include "device/bluetooth/bluetooth_discovery_session_outcome.h"
23 #include "device/bluetooth/bluetooth_socket_thread.h" 23 #include "device/bluetooth/bluetooth_socket_thread.h"
24 #include "device/bluetooth/bluetooth_types.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"
31 #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h" 32 #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h"
32 #include "device/bluetooth/bluez/bluetooth_pairing_bluez.h" 33 #include "device/bluetooth/bluez/bluetooth_pairing_bluez.h"
33 #include "device/bluetooth/bluez/bluetooth_socket_bluez.h" 34 #include "device/bluetooth/bluez/bluetooth_socket_bluez.h"
34 #include "device/bluetooth/dbus/bluetooth_adapter_client.h" 35 #include "device/bluetooth/dbus/bluetooth_adapter_client.h"
35 #include "device/bluetooth/dbus/bluetooth_agent_manager_client.h" 36 #include "device/bluetooth/dbus/bluetooth_agent_manager_client.h"
36 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" 37 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h"
37 #include "device/bluetooth/dbus/bluetooth_device_client.h" 38 #include "device/bluetooth/dbus/bluetooth_device_client.h"
38 #include "device/bluetooth/dbus/bluetooth_gatt_application_service_provider.h" 39 #include "device/bluetooth/dbus/bluetooth_gatt_application_service_provider.h"
39 #include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" 40 #include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h"
40 #include "device/bluetooth/dbus/bluetooth_input_client.h" 41 #include "device/bluetooth/dbus/bluetooth_input_client.h"
41 #include "device/bluetooth/dbus/bluez_dbus_manager.h" 42 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
42 #include "third_party/cros_system_api/dbus/service_constants.h" 43 #include "third_party/cros_system_api/dbus/service_constants.h"
43 44
44 #if defined(OS_CHROMEOS) 45 #if defined(OS_CHROMEOS)
45 #include "chromeos/system/devicetype.h" 46 #include "chromeos/system/devicetype.h"
46 #endif 47 #endif
47 48
48 using device::BluetoothAdapter; 49 using device::BluetoothAdapter;
49 using device::BluetoothAudioSink; 50 using device::BluetoothAudioSink;
50 using device::BluetoothDevice; 51 using device::BluetoothDevice;
51 using device::BluetoothDiscoveryFilter; 52 using device::BluetoothDiscoveryFilter;
52 using device::BluetoothSocket; 53 using device::BluetoothSocket;
54 using device::BluetoothTransport;
53 using device::BluetoothUUID; 55 using device::BluetoothUUID;
54 using device::UMABluetoothDiscoverySessionOutcome; 56 using device::UMABluetoothDiscoverySessionOutcome;
55 57
56 namespace { 58 namespace {
57 59
58 // The agent path is relatively meaningless since BlueZ only permits one to 60 // The agent path is relatively meaningless since BlueZ only permits one to
59 // exist per D-Bus connection, it just has to be unique within Chromium. 61 // exist per D-Bus connection, it just has to be unique within Chromium.
60 const char kAgentPath[] = "/org/chromium/bluetooth_agent"; 62 const char kAgentPath[] = "/org/chromium/bluetooth_agent";
61 const char kGattApplicationObjectPath[] = "/gatt_application"; 63 const char kGattApplicationObjectPath[] = "/gatt_application";
62 64
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 callback, error_callback); 1268 callback, error_callback);
1267 return; 1269 return;
1268 } 1270 }
1269 1271
1270 // There are no active discovery sessions. 1272 // There are no active discovery sessions.
1271 DCHECK_EQ(num_discovery_sessions_, 0); 1273 DCHECK_EQ(num_discovery_sessions_, 0);
1272 1274
1273 if (discovery_filter) { 1275 if (discovery_filter) {
1274 discovery_request_pending_ = true; 1276 discovery_request_pending_ = true;
1275 1277
1276 std::unique_ptr<BluetoothDiscoveryFilter> df(new BluetoothDiscoveryFilter( 1278 std::unique_ptr<BluetoothDiscoveryFilter> df(
1277 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL)); 1279 new BluetoothDiscoveryFilter(BluetoothTransport::TRANSPORT_DUAL));
1278 df->CopyFrom(*discovery_filter); 1280 df->CopyFrom(*discovery_filter);
1279 SetDiscoveryFilter( 1281 SetDiscoveryFilter(
1280 std::move(df), 1282 std::move(df),
1281 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter, 1283 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter,
1282 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), 1284 weak_ptr_factory_.GetWeakPtr(), callback, error_callback),
1283 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError, 1285 base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError,
1284 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); 1286 weak_ptr_factory_.GetWeakPtr(), callback, error_callback));
1285 return; 1287 return;
1286 } else { 1288 } else {
1287 current_filter_.reset(); 1289 current_filter_.reset();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 uint8_t transport; 1386 uint8_t transport;
1385 std::set<device::BluetoothUUID> uuids; 1387 std::set<device::BluetoothUUID> uuids;
1386 1388
1387 if (current_filter_->GetPathloss(&pathloss)) 1389 if (current_filter_->GetPathloss(&pathloss))
1388 dbus_discovery_filter.pathloss.reset(new uint16_t(pathloss)); 1390 dbus_discovery_filter.pathloss.reset(new uint16_t(pathloss));
1389 1391
1390 if (current_filter_->GetRSSI(&rssi)) 1392 if (current_filter_->GetRSSI(&rssi))
1391 dbus_discovery_filter.rssi.reset(new int16_t(rssi)); 1393 dbus_discovery_filter.rssi.reset(new int16_t(rssi));
1392 1394
1393 transport = current_filter_->GetTransport(); 1395 transport = current_filter_->GetTransport();
1394 if (transport == BluetoothDiscoveryFilter::Transport::TRANSPORT_LE) { 1396 if (transport == BluetoothTransport::TRANSPORT_LE) {
1395 dbus_discovery_filter.transport.reset(new std::string("le")); 1397 dbus_discovery_filter.transport.reset(new std::string("le"));
1396 } else if (transport == 1398 } else if (transport == BluetoothTransport::TRANSPORT_CLASSIC) {
1397 BluetoothDiscoveryFilter::Transport::TRANSPORT_CLASSIC) {
1398 dbus_discovery_filter.transport.reset(new std::string("bredr")); 1399 dbus_discovery_filter.transport.reset(new std::string("bredr"));
1399 } else if (transport == 1400 } else if (transport == BluetoothTransport::TRANSPORT_DUAL) {
1400 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL) {
1401 dbus_discovery_filter.transport.reset(new std::string("auto")); 1401 dbus_discovery_filter.transport.reset(new std::string("auto"));
1402 } 1402 }
1403 1403
1404 current_filter_->GetUUIDs(uuids); 1404 current_filter_->GetUUIDs(uuids);
1405 if (uuids.size()) { 1405 if (uuids.size()) {
1406 dbus_discovery_filter.uuids = std::unique_ptr<std::vector<std::string>>( 1406 dbus_discovery_filter.uuids = std::unique_ptr<std::vector<std::string>>(
1407 new std::vector<std::string>); 1407 new std::vector<std::string>);
1408 1408
1409 for (const auto& it : uuids) 1409 for (const auto& it : uuids)
1410 dbus_discovery_filter.uuids.get()->push_back(it.value()); 1410 dbus_discovery_filter.uuids.get()->push_back(it.value());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1636
1637 void BluetoothAdapterBlueZ::RegisterApplicationOnError( 1637 void BluetoothAdapterBlueZ::RegisterApplicationOnError(
1638 const base::Closure& callback, 1638 const base::Closure& callback,
1639 const device::BluetoothGattService::ErrorCallback& error_callback, 1639 const device::BluetoothGattService::ErrorCallback& error_callback,
1640 const std::string& /* error_name */, 1640 const std::string& /* error_name */,
1641 const std::string& /* error_message */) { 1641 const std::string& /* error_message */) {
1642 RegisterApplication(callback, error_callback); 1642 RegisterApplication(callback, error_callback);
1643 } 1643 }
1644 1644
1645 } // namespace bluez 1645 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698