| 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 <iterator> | 7 #include <iterator> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 305 |
| 306 const std::vector<uint8_t>* BluetoothDevice::GetServiceDataForUUID( | 306 const std::vector<uint8_t>* BluetoothDevice::GetServiceDataForUUID( |
| 307 const BluetoothUUID& uuid) const { | 307 const BluetoothUUID& uuid) const { |
| 308 auto it = service_data_.find(uuid); | 308 auto it = service_data_.find(uuid); |
| 309 if (it != service_data_.end()) { | 309 if (it != service_data_.end()) { |
| 310 return &it->second; | 310 return &it->second; |
| 311 } | 311 } |
| 312 return nullptr; | 312 return nullptr; |
| 313 } | 313 } |
| 314 | 314 |
| 315 const BluetoothDevice::ManufacturerDataMap& |
| 316 BluetoothDevice::GetManufacturerData() const { |
| 317 return manufacturer_data_; |
| 318 } |
| 319 |
| 320 BluetoothDevice::ManufacturerIDSet BluetoothDevice::GetManufacturerDataIDs() |
| 321 const { |
| 322 ManufacturerIDSet manufacturer_data_ids; |
| 323 for (const auto& manufacturer_data_pair : manufacturer_data_) { |
| 324 manufacturer_data_ids.insert(manufacturer_data_pair.first); |
| 325 } |
| 326 return manufacturer_data_ids; |
| 327 } |
| 328 |
| 329 const std::vector<uint8_t>* BluetoothDevice::GetManufacturerDataForID( |
| 330 const ManufacturerID manufacturerID) const { |
| 331 auto it = manufacturer_data_.find(manufacturerID); |
| 332 if (it != manufacturer_data_.end()) { |
| 333 return &it->second; |
| 334 } |
| 335 return nullptr; |
| 336 } |
| 337 |
| 315 base::Optional<int8_t> BluetoothDevice::GetInquiryRSSI() const { | 338 base::Optional<int8_t> BluetoothDevice::GetInquiryRSSI() const { |
| 316 return inquiry_rssi_; | 339 return inquiry_rssi_; |
| 317 } | 340 } |
| 318 | 341 |
| 319 base::Optional<int8_t> BluetoothDevice::GetInquiryTxPower() const { | 342 base::Optional<int8_t> BluetoothDevice::GetInquiryTxPower() const { |
| 320 return inquiry_tx_power_; | 343 return inquiry_tx_power_; |
| 321 } | 344 } |
| 322 | 345 |
| 346 base::Optional<uint8_t> BluetoothDevice::GetAdvertisingDataFlags() const { |
| 347 return base::nullopt; |
| 348 } |
| 349 |
| 323 void BluetoothDevice::CreateGattConnection( | 350 void BluetoothDevice::CreateGattConnection( |
| 324 const GattConnectionCallback& callback, | 351 const GattConnectionCallback& callback, |
| 325 const ConnectErrorCallback& error_callback) { | 352 const ConnectErrorCallback& error_callback) { |
| 326 create_gatt_connection_success_callbacks_.push_back(callback); | 353 create_gatt_connection_success_callbacks_.push_back(callback); |
| 327 create_gatt_connection_error_callbacks_.push_back(error_callback); | 354 create_gatt_connection_error_callbacks_.push_back(error_callback); |
| 328 | 355 |
| 329 if (IsGattConnected()) | 356 if (IsGattConnected()) |
| 330 return DidConnectGatt(); | 357 return DidConnectGatt(); |
| 331 | 358 |
| 332 CreateGattConnectionImpl(); | 359 CreateGattConnectionImpl(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 if (power < INT8_MIN) { | 515 if (power < INT8_MIN) { |
| 489 return INT8_MIN; | 516 return INT8_MIN; |
| 490 } | 517 } |
| 491 if (power > INT8_MAX) { | 518 if (power > INT8_MAX) { |
| 492 return INT8_MAX; | 519 return INT8_MAX; |
| 493 } | 520 } |
| 494 return static_cast<int8_t>(power); | 521 return static_cast<int8_t>(power); |
| 495 } | 522 } |
| 496 | 523 |
| 497 } // namespace device | 524 } // namespace device |
| OLD | NEW |