OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_device.h" | 5 #include "device/bluetooth/bluetooth_device.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "device/bluetooth/bluetooth_adapter.h" | 15 #include "device/bluetooth/bluetooth_adapter.h" |
16 #include "device/bluetooth/bluetooth_gatt_connection.h" | 16 #include "device/bluetooth/bluetooth_gatt_connection.h" |
17 #include "device/bluetooth/bluetooth_gatt_service.h" | 17 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
18 #include "grit/bluetooth_strings.h" | 18 #include "grit/bluetooth_strings.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 | 20 |
21 namespace device { | 21 namespace device { |
22 | 22 |
23 BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter) | 23 BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter) |
24 : adapter_(adapter), | 24 : adapter_(adapter), |
25 gatt_services_discovery_complete_(false), | 25 gatt_services_discovery_complete_(false), |
26 services_data_(new base::DictionaryValue()) {} | 26 services_data_(new base::DictionaryValue()) {} |
27 | 27 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 | 253 |
254 void BluetoothDevice::SetGattServicesDiscoveryComplete(bool complete) { | 254 void BluetoothDevice::SetGattServicesDiscoveryComplete(bool complete) { |
255 gatt_services_discovery_complete_ = complete; | 255 gatt_services_discovery_complete_ = complete; |
256 } | 256 } |
257 | 257 |
258 bool BluetoothDevice::IsGattServicesDiscoveryComplete() const { | 258 bool BluetoothDevice::IsGattServicesDiscoveryComplete() const { |
259 return gatt_services_discovery_complete_; | 259 return gatt_services_discovery_complete_; |
260 } | 260 } |
261 | 261 |
262 std::vector<BluetoothGattService*> | 262 std::vector<BluetoothRemoteGattService*> BluetoothDevice::GetGattServices() |
263 BluetoothDevice::GetGattServices() const { | 263 const { |
264 std::vector<BluetoothGattService*> services; | 264 std::vector<BluetoothRemoteGattService*> services; |
265 for (const auto& iter : gatt_services_) | 265 for (const auto& iter : gatt_services_) |
266 services.push_back(iter.second); | 266 services.push_back(iter.second); |
267 return services; | 267 return services; |
268 } | 268 } |
269 | 269 |
270 BluetoothGattService* BluetoothDevice::GetGattService( | 270 BluetoothRemoteGattService* BluetoothDevice::GetGattService( |
271 const std::string& identifier) const { | 271 const std::string& identifier) const { |
272 return gatt_services_.get(identifier); | 272 return gatt_services_.get(identifier); |
273 } | 273 } |
274 | 274 |
275 // static | 275 // static |
276 std::string BluetoothDevice::CanonicalizeAddress(const std::string& address) { | 276 std::string BluetoothDevice::CanonicalizeAddress(const std::string& address) { |
277 std::string canonicalized = address; | 277 std::string canonicalized = address; |
278 if (address.size() == 12) { | 278 if (address.size() == 12) { |
279 // Might be an address in the format "1A2B3C4D5E6F". Add separators. | 279 // Might be an address in the format "1A2B3C4D5E6F". Add separators. |
280 for (size_t i = 2; i < canonicalized.size(); i += 3) { | 280 for (size_t i = 2; i < canonicalized.size(); i += 3) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 base::BinaryValue::CreateWithCopiedBuffer(buffer, size)); | 381 base::BinaryValue::CreateWithCopiedBuffer(buffer, size)); |
382 } | 382 } |
383 | 383 |
384 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate, | 384 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate, |
385 const base::Closure& callback, | 385 const base::Closure& callback, |
386 const ConnectErrorCallback& error_callback) { | 386 const ConnectErrorCallback& error_callback) { |
387 NOTREACHED(); | 387 NOTREACHED(); |
388 } | 388 } |
389 | 389 |
390 } // namespace device | 390 } // namespace device |
OLD | NEW |