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

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

Issue 2078263002: Example Bluetooth ARC++ test changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@arc_tests
Patch Set: Created 4 years, 6 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
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 83f70655a493ccef325c8d925b5d089d61da1d50..1d0a6c5b07c0a400f5904f7cb72ed6cba758154c 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc
@@ -72,15 +72,6 @@ ArcBluetoothBridge::ArcBluetoothBridge(ArcBridgeService* bridge_service)
arc_bridge_service()->AddObserver(this);
}
-ArcBluetoothBridge::ArcBluetoothBridge(ArcBridgeService* bridge_service,
- bool test_flag)
- : ArcService(bridge_service), binding_(this), weak_factory_(this) {
- if (!test_flag) {
- LOG(ERROR) << "Test Constructor got called with test = false";
- }
- arc_bridge_service()->AddObserver(this);
-}
-
ArcBluetoothBridge::~ArcBluetoothBridge() {
arc_bridge_service()->RemoveObserver(this);
@@ -103,9 +94,8 @@ void ArcBluetoothBridge::OnBluetoothInstanceReady() {
return;
}
- bluetooth_instance_ = base::WrapUnique(bluetooth_instance);
- bluetooth_version_ = arc_bridge_service()->bluetooth_version();
- bluetooth_instance_->Init(binding_.CreateInterfacePtrAndBind());
+ arc_bridge_service()->bluetooth_instance()->Init(
+ binding_.CreateInterfacePtrAndBind());
}
void ArcBluetoothBridge::AdapterPresentChanged(BluetoothAdapter* adapter,
@@ -137,9 +127,10 @@ void ArcBluetoothBridge::DeviceAdded(BluetoothAdapter* adapter,
mojo::Array<mojom::BluetoothPropertyPtr> properties =
GetDeviceProperties(mojom::BluetoothPropertyType::ALL, device);
- bluetooth_instance_->OnDeviceFound(std::move(properties));
+ arc_bridge_service()->bluetooth_instance()->OnDeviceFound(
+ std::move(properties));
- if (bluetooth_version_ < kMinBtleVersion) {
+ if (arc_bridge_service()->bluetooth_version() < kMinBtleVersion) {
LOG(WARNING) << "Bluetooth instance is too old and does not support BTLE";
return;
}
@@ -149,8 +140,8 @@ void ArcBluetoothBridge::DeviceAdded(BluetoothAdapter* adapter,
int rssi = device->GetInquiryRSSI();
mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data =
GetAdvertisingData(device);
- bluetooth_instance_->OnLEDeviceFound(std::move(addr), rssi,
- std::move(adv_data));
+ arc_bridge_service()->bluetooth_instance()->OnLEDeviceFound(
+ std::move(addr), rssi, std::move(adv_data));
}
void ArcBluetoothBridge::DeviceChanged(BluetoothAdapter* adapter,
@@ -213,7 +204,7 @@ void ArcBluetoothBridge::GattServicesDiscovered(BluetoothAdapter* adapter,
if (!HasBluetoothInstance())
return;
- if (bluetooth_version_ < kMinBtleVersion) {
+ if (arc_bridge_service()->bluetooth_version() < kMinBtleVersion) {
LOG(WARNING) << "Bluetooth instance is too old and does not support BTLE";
return;
}
@@ -221,7 +212,7 @@ void ArcBluetoothBridge::GattServicesDiscovered(BluetoothAdapter* adapter,
mojom::BluetoothAddressPtr addr =
mojom::BluetoothAddress::From(device->GetAddress());
- bluetooth_instance_->OnSearchComplete(
+ arc_bridge_service()->bluetooth_instance()->OnSearchComplete(
std::move(addr), mojom::BluetoothGattStatus::GATT_SUCCESS);
}
@@ -307,8 +298,8 @@ void ArcBluetoothBridge::GetAdapterProperty(mojom::BluetoothPropertyType type) {
mojo::Array<mojom::BluetoothPropertyPtr> properties =
GetAdapterProperties(type);
- bluetooth_instance_->OnAdapterProperties(mojom::BluetoothStatus::SUCCESS,
- std::move(properties));
+ arc_bridge_service()->bluetooth_instance()->OnAdapterProperties(
+ mojom::BluetoothStatus::SUCCESS, std::move(properties));
}
void ArcBluetoothBridge::SetAdapterProperty(
@@ -318,7 +309,7 @@ void ArcBluetoothBridge::SetAdapterProperty(
return;
// TODO(smbarber): Implement SetAdapterProperty
- bluetooth_instance_->OnAdapterProperties(
+ arc_bridge_service()->bluetooth_instance()->OnAdapterProperties(
mojom::BluetoothStatus::FAIL,
mojo::Array<mojom::BluetoothPropertyPtr>::New(0));
}
@@ -342,8 +333,8 @@ void ArcBluetoothBridge::GetRemoteDeviceProperty(
status = mojom::BluetoothStatus::FAIL;
}
- bluetooth_instance_->OnRemoteDeviceProperties(status, std::move(remote_addr),
- std::move(properties));
+ arc_bridge_service()->bluetooth_instance()->OnRemoteDeviceProperties(
+ status, std::move(remote_addr), std::move(properties));
}
void ArcBluetoothBridge::SetRemoteDeviceProperty(
@@ -354,7 +345,7 @@ void ArcBluetoothBridge::SetRemoteDeviceProperty(
return;
// TODO(smbarber): Implement SetRemoteDeviceProperty
- bluetooth_instance_->OnRemoteDeviceProperties(
+ arc_bridge_service()->bluetooth_instance()->OnRemoteDeviceProperties(
mojom::BluetoothStatus::FAIL, std::move(remote_addr),
mojo::Array<mojom::BluetoothPropertyPtr>::New(0));
}
@@ -424,7 +415,7 @@ void ArcBluetoothBridge::OnDiscoveryStarted(
discovery_session_ = std::move(session);
- bluetooth_instance_->OnDiscoveryStateChanged(
+ arc_bridge_service()->bluetooth_instance()->OnDiscoveryStateChanged(
mojom::BluetoothDiscoveryState::STARTED);
SendCachedDevicesFound();
@@ -436,7 +427,7 @@ void ArcBluetoothBridge::OnDiscoveryStopped() {
discovery_session_.reset();
- bluetooth_instance_->OnDiscoveryStateChanged(
+ arc_bridge_service()->bluetooth_instance()->OnDiscoveryStateChanged(
mojom::BluetoothDiscoveryState::STOPPED);
}
@@ -545,14 +536,14 @@ void ArcBluetoothBridge::OnGattConnectStateChanged(
if (!HasBluetoothInstance())
return;
- if (bluetooth_version_ < kMinBtleVersion) {
+ if (arc_bridge_service()->bluetooth_version() < kMinBtleVersion) {
LOG(WARNING) << "Bluetooth instance is too old and does not support BTLE";
return;
}
DCHECK(addr);
- bluetooth_instance_->OnLEConnectionStateChange(
+ arc_bridge_service()->bluetooth_instance()->OnLEConnectionStateChange(
std::move(addr), connected);
}
@@ -583,8 +574,8 @@ void ArcBluetoothBridge::ConnectLEDevice(
DCHECK(device);
if (device->IsConnected()) {
- bluetooth_instance_->OnLEConnectionStateChange(std::move(remote_addr),
- true);
+ arc_bridge_service()->bluetooth_instance()->OnLEConnectionStateChange(
+ std::move(remote_addr), true);
return;
}
@@ -608,8 +599,8 @@ void ArcBluetoothBridge::DisconnectLEDevice(
DCHECK(device);
if (!device->IsConnected()) {
- bluetooth_instance_->OnLEConnectionStateChange(std::move(remote_addr),
- false);
+ arc_bridge_service()->bluetooth_instance()->OnLEConnectionStateChange(
+ std::move(remote_addr), false);
return;
}
@@ -631,7 +622,7 @@ void ArcBluetoothBridge::SearchService(mojom::BluetoothAddressPtr remote_addr) {
// Call the callback if discovery is completed
if (device->IsGattServicesDiscoveryComplete()) {
- bluetooth_instance_->OnSearchComplete(
+ arc_bridge_service()->bluetooth_instance()->OnSearchComplete(
std::move(remote_addr), mojom::BluetoothGattStatus::GATT_SUCCESS);
return;
}
@@ -757,7 +748,8 @@ void ArcBluetoothBridge::GetGattDB(mojom::BluetoothAddressPtr remote_addr) {
}
}
- bluetooth_instance_->OnGetGattDB(std::move(remote_addr), std::move(db));
+ arc_bridge_service()->bluetooth_instance()->OnGetGattDB(
+ std::move(remote_addr), std::move(db));
}
// Find Gatt Service/Characteristic/Descriptor from std::vector from UUID.
@@ -1005,18 +997,18 @@ void ArcBluetoothBridge::OnPairing(mojom::BluetoothAddressPtr addr) const {
if (!HasBluetoothInstance())
return;
- bluetooth_instance_->OnBondStateChanged(mojom::BluetoothStatus::SUCCESS,
- std::move(addr),
- mojom::BluetoothBondState::BONDING);
+ arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ mojom::BluetoothStatus::SUCCESS, std::move(addr),
+ mojom::BluetoothBondState::BONDING);
}
void ArcBluetoothBridge::OnPairedDone(mojom::BluetoothAddressPtr addr) const {
if (!HasBluetoothInstance())
return;
- bluetooth_instance_->OnBondStateChanged(mojom::BluetoothStatus::SUCCESS,
- std::move(addr),
- mojom::BluetoothBondState::BONDED);
+ arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ mojom::BluetoothStatus::SUCCESS, std::move(addr),
+ mojom::BluetoothBondState::BONDED);
}
void ArcBluetoothBridge::OnPairedError(
@@ -1025,18 +1017,18 @@ void ArcBluetoothBridge::OnPairedError(
if (!HasBluetoothInstance())
return;
- bluetooth_instance_->OnBondStateChanged(mojom::BluetoothStatus::FAIL,
- std::move(addr),
- mojom::BluetoothBondState::NONE);
+ arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ mojom::BluetoothStatus::FAIL, std::move(addr),
+ mojom::BluetoothBondState::NONE);
}
void ArcBluetoothBridge::OnForgetDone(mojom::BluetoothAddressPtr addr) const {
if (!HasBluetoothInstance())
return;
- bluetooth_instance_->OnBondStateChanged(mojom::BluetoothStatus::SUCCESS,
- std::move(addr),
- mojom::BluetoothBondState::NONE);
+ arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ mojom::BluetoothStatus::SUCCESS, std::move(addr),
+ mojom::BluetoothBondState::NONE);
}
void ArcBluetoothBridge::OnForgetError(mojom::BluetoothAddressPtr addr) const {
@@ -1049,8 +1041,8 @@ void ArcBluetoothBridge::OnForgetError(mojom::BluetoothAddressPtr addr) const {
if (device && device->IsPaired()) {
bond_state = mojom::BluetoothBondState::BONDED;
}
- bluetooth_instance_->OnBondStateChanged(mojom::BluetoothStatus::FAIL,
- std::move(addr), bond_state);
+ arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ mojom::BluetoothStatus::FAIL, std::move(addr), bond_state);
}
mojo::Array<mojom::BluetoothPropertyPtr>
@@ -1264,22 +1256,23 @@ void ArcBluetoothBridge::SendCachedDevicesFound() const {
mojo::Array<mojom::BluetoothPropertyPtr> properties =
GetDeviceProperties(mojom::BluetoothPropertyType::ALL, device);
- bluetooth_instance_->OnDeviceFound(std::move(properties));
+ arc_bridge_service()->bluetooth_instance()->OnDeviceFound(
+ std::move(properties));
- if (bluetooth_version_ >= kMinBtleVersion) {
+ if (arc_bridge_service()->bluetooth_version() >= kMinBtleVersion) {
mojom::BluetoothAddressPtr addr =
mojom::BluetoothAddress::From(device->GetAddress());
int rssi = device->GetInquiryRSSI();
mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data =
GetAdvertisingData(device);
- bluetooth_instance_->OnLEDeviceFound(std::move(addr), rssi,
- std::move(adv_data));
+ arc_bridge_service()->bluetooth_instance()->OnLEDeviceFound(
+ std::move(addr), rssi, std::move(adv_data));
}
}
}
bool ArcBluetoothBridge::HasBluetoothInstance() const {
- if (!bluetooth_instance_) {
+ if (!arc_bridge_service()->bluetooth_instance()) {
LOG(WARNING) << "no Bluetooth instance available";
return false;
}
@@ -1300,17 +1293,18 @@ void ArcBluetoothBridge::SendCachedPairedDevices() const {
mojo::Array<mojom::BluetoothPropertyPtr> properties =
GetDeviceProperties(mojom::BluetoothPropertyType::ALL, device);
- bluetooth_instance_->OnDeviceFound(std::move(properties));
+ arc_bridge_service()->bluetooth_instance()->OnDeviceFound(
+ std::move(properties));
mojom::BluetoothAddressPtr addr =
mojom::BluetoothAddress::From(device->GetAddress());
- if (bluetooth_version_ >= kMinBtleVersion) {
+ if (arc_bridge_service()->bluetooth_version() >= kMinBtleVersion) {
int rssi = device->GetInquiryRSSI();
mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data =
GetAdvertisingData(device);
- bluetooth_instance_->OnLEDeviceFound(addr->Clone(), rssi,
- std::move(adv_data));
+ arc_bridge_service()->bluetooth_instance()->OnLEDeviceFound(
+ addr->Clone(), rssi, std::move(adv_data));
}
// OnBondStateChanged must be called with mojom::BluetoothBondState::BONDING
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698