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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 410 |
411 canonicalized[i] = base::ToUpperASCII(canonicalized[i]); | 411 canonicalized[i] = base::ToUpperASCII(canonicalized[i]); |
412 } | 412 } |
413 } | 413 } |
414 | 414 |
415 return canonicalized; | 415 return canonicalized; |
416 } | 416 } |
417 | 417 |
418 std::string BluetoothDevice::GetIdentifier() const { return GetAddress(); } | 418 std::string BluetoothDevice::GetIdentifier() const { return GetAddress(); } |
419 | 419 |
420 void BluetoothDevice::UpdateAdvertisementData(int8_t rssi, | 420 void BluetoothDevice::UpdateAdvertisementData( |
421 UUIDList advertised_uuids, | 421 int8_t rssi, |
422 ServiceDataMap service_data, | 422 const std::string* advertised_name, |
423 const int8_t* tx_power) { | 423 UUIDList advertised_uuids, |
| 424 ServiceDataMap service_data, |
| 425 const int8_t* tx_power) { |
424 UpdateTimestamp(); | 426 UpdateTimestamp(); |
425 | 427 |
426 inquiry_rssi_ = rssi; | 428 inquiry_rssi_ = rssi; |
427 | 429 |
| 430 if (advertised_name != nullptr) { |
| 431 advertised_name_ = *advertised_name; |
| 432 } else { |
| 433 advertised_name_ = base::nullopt; |
| 434 } |
| 435 |
428 device_uuids_.ReplaceAdvertisedUUIDs(std::move(advertised_uuids)); | 436 device_uuids_.ReplaceAdvertisedUUIDs(std::move(advertised_uuids)); |
429 service_data_ = std::move(service_data); | 437 service_data_ = std::move(service_data); |
430 | 438 |
431 if (tx_power != nullptr) { | 439 if (tx_power != nullptr) { |
432 inquiry_tx_power_ = *tx_power; | 440 inquiry_tx_power_ = *tx_power; |
433 } else { | 441 } else { |
434 inquiry_tx_power_ = base::nullopt; | 442 inquiry_tx_power_ = base::nullopt; |
435 } | 443 } |
436 } | 444 } |
437 | 445 |
438 void BluetoothDevice::ClearAdvertisementData() { | 446 void BluetoothDevice::ClearAdvertisementData() { |
439 inquiry_rssi_ = base::nullopt; | 447 inquiry_rssi_ = base::nullopt; |
| 448 advertised_name_ = base::nullopt; |
440 device_uuids_.ClearAdvertisedUUIDs(); | 449 device_uuids_.ClearAdvertisedUUIDs(); |
441 service_data_.clear(); | 450 service_data_.clear(); |
442 inquiry_tx_power_ = base::nullopt; | 451 inquiry_tx_power_ = base::nullopt; |
443 GetAdapter()->NotifyDeviceChanged(this); | 452 GetAdapter()->NotifyDeviceChanged(this); |
444 } | 453 } |
445 | 454 |
446 void BluetoothDevice::DidConnectGatt() { | 455 void BluetoothDevice::DidConnectGatt() { |
447 for (const auto& callback : create_gatt_connection_success_callbacks_) { | 456 for (const auto& callback : create_gatt_connection_success_callbacks_) { |
448 callback.Run( | 457 callback.Run( |
449 base::MakeUnique<BluetoothGattConnection>(adapter_, GetAddress())); | 458 base::MakeUnique<BluetoothGattConnection>(adapter_, GetAddress())); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 if (power < INT8_MIN) { | 524 if (power < INT8_MIN) { |
516 return INT8_MIN; | 525 return INT8_MIN; |
517 } | 526 } |
518 if (power > INT8_MAX) { | 527 if (power > INT8_MAX) { |
519 return INT8_MAX; | 528 return INT8_MAX; |
520 } | 529 } |
521 return static_cast<int8_t>(power); | 530 return static_cast<int8_t>(power); |
522 } | 531 } |
523 | 532 |
524 } // namespace device | 533 } // namespace device |
OLD | NEW |