Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: components/arc/bluetooth/arc_bluetooth_bridge.cc

Issue 2228953003: bluetooth: Change GetInquiryTxPower and GetInquiryRSSI to return optional. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: TIL value_or Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/arc/common/bluetooth.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/bluetooth/arc_bluetooth_bridge.cc
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.cc b/components/arc/bluetooth/arc_bluetooth_bridge.cc
index dbc6747b662299696c5c1ebb56d1a9f069e3b04c..b2d4166620e1654a40b182023e183a5298e09c02 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc
@@ -249,11 +249,12 @@ void ArcBluetoothBridge::DeviceAdded(BluetoothAdapter* adapter,
mojom::BluetoothAddressPtr addr =
mojom::BluetoothAddress::From(device->GetAddress());
- int rssi = device->GetInquiryRSSI();
+ base::Optional<int8_t> rssi = device->GetInquiryRSSI();
mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data =
GetAdvertisingData(device);
arc_bridge_service()->bluetooth()->instance()->OnLEDeviceFound(
- std::move(addr), rssi, std::move(adv_data));
+ std::move(addr), rssi.value_or(mojom::kUnknownPower),
+ std::move(adv_data));
}
void ArcBluetoothBridge::DeviceChanged(BluetoothAdapter* adapter,
@@ -1133,8 +1134,8 @@ void ArcBluetoothBridge::ReadRemoteRssi(
const ReadRemoteRssiCallback& callback) {
BluetoothDevice* device =
bluetooth_adapter_->GetDevice(remote_addr->To<std::string>());
- int rssi = device->GetInquiryRSSI();
- callback.Run(rssi);
+ base::Optional<int8_t> rssi = device->GetInquiryRSSI();
+ callback.Run(rssi.value_or(mojom::kUnknownPower));
}
void ArcBluetoothBridge::OpenBluetoothSocket(
@@ -1420,7 +1421,8 @@ ArcBluetoothBridge::GetDeviceProperties(mojom::BluetoothPropertyType type,
if (type == mojom::BluetoothPropertyType::ALL ||
type == mojom::BluetoothPropertyType::REMOTE_RSSI) {
mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
- btp->set_remote_rssi(device->GetInquiryRSSI());
+ base::Optional<int8_t> rssi = device->GetInquiryRSSI();
+ btp->set_remote_rssi(rssi.value_or(mojom::kUnknownPower));
properties.push_back(std::move(btp));
}
// TODO(smbarber): Add remote version info
@@ -1577,11 +1579,12 @@ void ArcBluetoothBridge::SendCachedDevicesFound() const {
if (arc_bridge_service()->bluetooth()->version() >= kMinBtleVersion) {
mojom::BluetoothAddressPtr addr =
mojom::BluetoothAddress::From(device->GetAddress());
- int rssi = device->GetInquiryRSSI();
+ base::Optional<int8_t> rssi = device->GetInquiryRSSI();
mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data =
GetAdvertisingData(device);
arc_bridge_service()->bluetooth()->instance()->OnLEDeviceFound(
- std::move(addr), rssi, std::move(adv_data));
+ std::move(addr), rssi.value_or(mojom::kUnknownPower),
+ std::move(adv_data));
}
}
}
@@ -1615,11 +1618,12 @@ void ArcBluetoothBridge::SendCachedPairedDevices() const {
mojom::BluetoothAddress::From(device->GetAddress());
if (arc_bridge_service()->bluetooth()->version() >= kMinBtleVersion) {
- int rssi = device->GetInquiryRSSI();
+ base::Optional<int8_t> rssi = device->GetInquiryRSSI();
mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data =
GetAdvertisingData(device);
arc_bridge_service()->bluetooth()->instance()->OnLEDeviceFound(
- addr->Clone(), rssi, std::move(adv_data));
+ addr->Clone(), rssi.value_or(mojom::kUnknownPower),
+ std::move(adv_data));
}
// OnBondStateChanged must be called with mojom::BluetoothBondState::BONDING
« no previous file with comments | « no previous file | components/arc/common/bluetooth.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698