OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bluetooth_util.h" | 5 #include "components/proximity_auth/bluetooth_util.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/numerics/safe_conversions.h" | 16 #include "base/numerics/safe_conversions.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
19 #include "base/sys_byteorder.h" | 19 #include "base/sys_byteorder.h" |
20 #include "base/task_runner_util.h" | 20 #include "base/task_runner_util.h" |
21 #include "base/threading/sequenced_worker_pool.h" | 21 #include "base/threading/sequenced_worker_pool.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
23 #include "device/bluetooth/bluetooth_device.h" | 23 #include "device/bluetooth/bluetooth_device.h" |
24 #include "device/bluetooth/bluetooth_device_chromeos.h" | |
25 #include "net/socket/socket_descriptor.h" | 24 #include "net/socket/socket_descriptor.h" |
26 | 25 |
27 // The bluez headers are (intentionally) not available within the Chromium | 26 // The bluez headers are (intentionally) not available within the Chromium |
28 // repository, so several definitions from these headers are replicated below. | 27 // repository, so several definitions from these headers are replicated below. |
29 | 28 |
30 // From <bluetooth/bluetooth.h>: | 29 // From <bluetooth/bluetooth.h>: |
31 #define BTPROTO_L2CAP 0 | 30 #define BTPROTO_L2CAP 0 |
32 struct bdaddr_t { | 31 struct bdaddr_t { |
33 uint8_t b[6]; | 32 uint8_t b[6]; |
34 } __attribute__((packed)); | 33 } __attribute__((packed)); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 base::TaskRunner* task_runner) { | 148 base::TaskRunner* task_runner) { |
150 base::PostTaskAndReplyWithResult( | 149 base::PostTaskAndReplyWithResult( |
151 task_runner, | 150 task_runner, |
152 FROM_HERE, | 151 FROM_HERE, |
153 base::Bind(&SeekDeviceByAddressImpl, | 152 base::Bind(&SeekDeviceByAddressImpl, |
154 device_address, | 153 device_address, |
155 make_scoped_refptr(task_runner)), | 154 make_scoped_refptr(task_runner)), |
156 base::Bind(&OnSeekDeviceResult, callback, error_callback)); | 155 base::Bind(&OnSeekDeviceResult, callback, error_callback)); |
157 } | 156 } |
158 | 157 |
159 void ConnectToServiceInsecurely( | |
160 device::BluetoothDevice* device, | |
161 const device::BluetoothUUID& uuid, | |
162 const BluetoothDevice::ConnectToServiceCallback& callback, | |
163 const BluetoothDevice::ConnectToServiceErrorCallback& error_callback) { | |
164 static_cast<chromeos::BluetoothDeviceChromeOS*>(device) | |
165 ->ConnectToServiceInsecurely(uuid, callback, error_callback); | |
166 } | |
167 | |
168 } // namespace bluetooth_util | 158 } // namespace bluetooth_util |
169 } // namespace proximity_auth | 159 } // namespace proximity_auth |
OLD | NEW |