| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "device/bluetooth/bluetooth_adapter.h" | 13 #include "device/bluetooth/bluetooth_adapter.h" |
| 14 #include "device/bluetooth/bluetooth_gatt_connection.h" | 14 #include "device/bluetooth/bluetooth_gatt_connection.h" |
| 15 #include "device/bluetooth/bluetooth_gatt_service.h" | 15 #include "device/bluetooth/bluetooth_gatt_service.h" |
| 16 #include "grit/bluetooth_strings.h" | 16 #include "grit/bluetooth_strings.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 | 18 |
| 19 namespace device { | 19 namespace device { |
| 20 | 20 |
| 21 BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter) | 21 BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter) |
| 22 : adapter_(adapter), | 22 : adapter_(adapter), services_data_(new base::DictionaryValue()) {} |
| 23 gatt_services_discovery_complete_(false), | |
| 24 services_data_(new base::DictionaryValue()) {} | |
| 25 | 23 |
| 26 BluetoothDevice::~BluetoothDevice() { | 24 BluetoothDevice::~BluetoothDevice() { |
| 27 DidDisconnectGatt(); | 25 DidDisconnectGatt(); |
| 28 } | 26 } |
| 29 | 27 |
| 30 BluetoothDevice::ConnectionInfo::ConnectionInfo() | 28 BluetoothDevice::ConnectionInfo::ConnectionInfo() |
| 31 : rssi(kUnknownPower), | 29 : rssi(kUnknownPower), |
| 32 transmit_power(kUnknownPower), | 30 transmit_power(kUnknownPower), |
| 33 max_transmit_power(kUnknownPower) {} | 31 max_transmit_power(kUnknownPower) {} |
| 34 | 32 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 const ConnectErrorCallback& error_callback) { | 207 const ConnectErrorCallback& error_callback) { |
| 210 create_gatt_connection_success_callbacks_.push_back(callback); | 208 create_gatt_connection_success_callbacks_.push_back(callback); |
| 211 create_gatt_connection_error_callbacks_.push_back(error_callback); | 209 create_gatt_connection_error_callbacks_.push_back(error_callback); |
| 212 | 210 |
| 213 if (IsGattConnected()) | 211 if (IsGattConnected()) |
| 214 return DidConnectGatt(); | 212 return DidConnectGatt(); |
| 215 | 213 |
| 216 CreateGattConnectionImpl(); | 214 CreateGattConnectionImpl(); |
| 217 } | 215 } |
| 218 | 216 |
| 219 void BluetoothDevice::SetGattServicesDiscoveryComplete(bool complete) { | |
| 220 gatt_services_discovery_complete_ = complete; | |
| 221 } | |
| 222 | |
| 223 bool BluetoothDevice::IsGattServicesDiscoveryComplete() const { | |
| 224 return gatt_services_discovery_complete_; | |
| 225 } | |
| 226 | |
| 227 std::vector<BluetoothGattService*> | 217 std::vector<BluetoothGattService*> |
| 228 BluetoothDevice::GetGattServices() const { | 218 BluetoothDevice::GetGattServices() const { |
| 229 std::vector<BluetoothGattService*> services; | 219 std::vector<BluetoothGattService*> services; |
| 230 for (const auto& iter : gatt_services_) | 220 for (const auto& iter : gatt_services_) |
| 231 services.push_back(iter.second); | 221 services.push_back(iter.second); |
| 232 return services; | 222 return services; |
| 233 } | 223 } |
| 234 | 224 |
| 235 BluetoothGattService* BluetoothDevice::GetGattService( | 225 BluetoothGattService* BluetoothDevice::GetGattService( |
| 236 const std::string& identifier) const { | 226 const std::string& identifier) const { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 base::BinaryValue::CreateWithCopiedBuffer(buffer, size)); | 337 base::BinaryValue::CreateWithCopiedBuffer(buffer, size)); |
| 348 } | 338 } |
| 349 | 339 |
| 350 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate, | 340 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate, |
| 351 const base::Closure& callback, | 341 const base::Closure& callback, |
| 352 const ConnectErrorCallback& error_callback) { | 342 const ConnectErrorCallback& error_callback) { |
| 353 NOTREACHED(); | 343 NOTREACHED(); |
| 354 } | 344 } |
| 355 | 345 |
| 356 } // namespace device | 346 } // namespace device |
| OLD | NEW |