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

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

Issue 2190483003: arc: Revamp the ArcBridgeService interface (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@2785
Patch Set: One less diff line Created 4 years, 5 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 | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | components/arc/clipboard/arc_clipboard_bridge.h » ('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 67132380a9bc9d34d7216dea920d98123f977df2..7b9600b24880f8e9154676b06b7ed82fc91b5355 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc
@@ -71,11 +71,11 @@ ArcBluetoothBridge::ArcBluetoothBridge(ArcBridgeService* bridge_service)
VLOG(1) << "no bluetooth adapter available";
}
- arc_bridge_service()->AddObserver(this);
+ arc_bridge_service()->bluetooth()->AddObserver(this);
}
ArcBluetoothBridge::~ArcBluetoothBridge() {
- arc_bridge_service()->RemoveObserver(this);
+ arc_bridge_service()->bluetooth()->RemoveObserver(this);
if (bluetooth_adapter_)
bluetooth_adapter_->RemoveObserver(this);
@@ -90,17 +90,15 @@ void ArcBluetoothBridge::OnAdapterInitialized(
bluetooth_adapter_->AddObserver(this);
}
-void ArcBluetoothBridge::OnBluetoothInstanceReady() {
+void ArcBluetoothBridge::OnInstanceReady() {
mojom::BluetoothInstance* bluetooth_instance =
- arc_bridge_service()->bluetooth_instance();
+ arc_bridge_service()->bluetooth()->instance();
if (!bluetooth_instance) {
LOG(ERROR) << "OnBluetoothInstanceReady called, "
<< "but no bluetooth instance found";
return;
}
-
- arc_bridge_service()->bluetooth_instance()->Init(
- binding_.CreateInterfacePtrAndBind());
+ bluetooth_instance->Init(binding_.CreateInterfacePtrAndBind());
}
void ArcBluetoothBridge::AdapterPoweredChanged(BluetoothAdapter* adapter,
@@ -123,7 +121,7 @@ void ArcBluetoothBridge::DeviceAdded(BluetoothAdapter* adapter,
mojo::Array<mojom::BluetoothPropertyPtr> properties =
GetDeviceProperties(mojom::BluetoothPropertyType::ALL, device);
- arc_bridge_service()->bluetooth_instance()->OnDeviceFound(
+ arc_bridge_service()->bluetooth()->instance()->OnDeviceFound(
std::move(properties));
if (!CheckBluetoothInstanceVersion(kMinBtleVersion))
@@ -134,7 +132,7 @@ void ArcBluetoothBridge::DeviceAdded(BluetoothAdapter* adapter,
int rssi = device->GetInquiryRSSI();
mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data =
GetAdvertisingData(device);
- arc_bridge_service()->bluetooth_instance()->OnLEDeviceFound(
+ arc_bridge_service()->bluetooth()->instance()->OnLEDeviceFound(
std::move(addr), rssi, std::move(adv_data));
}
@@ -204,7 +202,7 @@ void ArcBluetoothBridge::GattServicesDiscovered(BluetoothAdapter* adapter,
mojom::BluetoothAddressPtr addr =
mojom::BluetoothAddress::From(device->GetAddress());
- arc_bridge_service()->bluetooth_instance()->OnSearchComplete(
+ arc_bridge_service()->bluetooth()->instance()->OnSearchComplete(
std::move(addr), mojom::BluetoothGattStatus::GATT_SUCCESS);
}
@@ -269,7 +267,7 @@ void ArcBluetoothBridge::GattCharacteristicValueChanged(
char_id->inst_id = ConvertGattIdentifierToId(characteristic->GetIdentifier());
char_id->uuid = mojom::BluetoothUUID::From(characteristic->GetUUID());
- arc_bridge_service()->bluetooth_instance()->OnGattNotify(
+ arc_bridge_service()->bluetooth()->instance()->OnGattNotify(
std::move(address), std::move(service_id), std::move(char_id),
true /* is_notify */, mojo::Array<uint8_t>::From(value));
}
@@ -313,7 +311,7 @@ void ArcBluetoothBridge::GetAdapterProperty(mojom::BluetoothPropertyType type) {
mojo::Array<mojom::BluetoothPropertyPtr> properties =
GetAdapterProperties(type);
- arc_bridge_service()->bluetooth_instance()->OnAdapterProperties(
+ arc_bridge_service()->bluetooth()->instance()->OnAdapterProperties(
mojom::BluetoothStatus::SUCCESS, std::move(properties));
}
@@ -324,7 +322,7 @@ void ArcBluetoothBridge::SetAdapterProperty(
return;
// TODO(smbarber): Implement SetAdapterProperty
- arc_bridge_service()->bluetooth_instance()->OnAdapterProperties(
+ arc_bridge_service()->bluetooth()->instance()->OnAdapterProperties(
mojom::BluetoothStatus::FAIL,
mojo::Array<mojom::BluetoothPropertyPtr>::New(0));
}
@@ -348,7 +346,7 @@ void ArcBluetoothBridge::GetRemoteDeviceProperty(
status = mojom::BluetoothStatus::FAIL;
}
- arc_bridge_service()->bluetooth_instance()->OnRemoteDeviceProperties(
+ arc_bridge_service()->bluetooth()->instance()->OnRemoteDeviceProperties(
status, std::move(remote_addr), std::move(properties));
}
@@ -360,7 +358,7 @@ void ArcBluetoothBridge::SetRemoteDeviceProperty(
return;
// TODO(smbarber): Implement SetRemoteDeviceProperty
- arc_bridge_service()->bluetooth_instance()->OnRemoteDeviceProperties(
+ arc_bridge_service()->bluetooth()->instance()->OnRemoteDeviceProperties(
mojom::BluetoothStatus::FAIL, std::move(remote_addr),
mojo::Array<mojom::BluetoothPropertyPtr>::New(0));
}
@@ -430,7 +428,7 @@ void ArcBluetoothBridge::OnDiscoveryStarted(
discovery_session_ = std::move(session);
- arc_bridge_service()->bluetooth_instance()->OnDiscoveryStateChanged(
+ arc_bridge_service()->bluetooth()->instance()->OnDiscoveryStateChanged(
mojom::BluetoothDiscoveryState::STARTED);
SendCachedDevicesFound();
@@ -442,7 +440,7 @@ void ArcBluetoothBridge::OnDiscoveryStopped() {
discovery_session_.reset();
- arc_bridge_service()->bluetooth_instance()->OnDiscoveryStateChanged(
+ arc_bridge_service()->bluetooth()->instance()->OnDiscoveryStateChanged(
mojom::BluetoothDiscoveryState::STOPPED);
}
@@ -556,7 +554,7 @@ void ArcBluetoothBridge::OnGattConnectStateChanged(
DCHECK(addr);
- arc_bridge_service()->bluetooth_instance()->OnLEConnectionStateChange(
+ arc_bridge_service()->bluetooth()->instance()->OnLEConnectionStateChange(
std::move(addr), connected);
}
@@ -587,7 +585,7 @@ void ArcBluetoothBridge::ConnectLEDevice(
DCHECK(device);
if (device->IsConnected()) {
- arc_bridge_service()->bluetooth_instance()->OnLEConnectionStateChange(
+ arc_bridge_service()->bluetooth()->instance()->OnLEConnectionStateChange(
std::move(remote_addr), true);
return;
}
@@ -612,7 +610,7 @@ void ArcBluetoothBridge::DisconnectLEDevice(
DCHECK(device);
if (!device->IsConnected()) {
- arc_bridge_service()->bluetooth_instance()->OnLEConnectionStateChange(
+ arc_bridge_service()->bluetooth()->instance()->OnLEConnectionStateChange(
std::move(remote_addr), false);
return;
}
@@ -635,7 +633,7 @@ void ArcBluetoothBridge::SearchService(mojom::BluetoothAddressPtr remote_addr) {
// Call the callback if discovery is completed
if (device->IsGattServicesDiscoveryComplete()) {
- arc_bridge_service()->bluetooth_instance()->OnSearchComplete(
+ arc_bridge_service()->bluetooth()->instance()->OnSearchComplete(
std::move(remote_addr), mojom::BluetoothGattStatus::GATT_SUCCESS);
return;
}
@@ -761,7 +759,7 @@ void ArcBluetoothBridge::GetGattDB(mojom::BluetoothAddressPtr remote_addr) {
}
}
- arc_bridge_service()->bluetooth_instance()->OnGetGattDB(
+ arc_bridge_service()->bluetooth()->instance()->OnGetGattDB(
std::move(remote_addr), std::move(db));
}
@@ -1023,7 +1021,7 @@ void ArcBluetoothBridge::OnPairing(mojom::BluetoothAddressPtr addr) const {
if (!HasBluetoothInstance())
return;
- arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ arc_bridge_service()->bluetooth()->instance()->OnBondStateChanged(
mojom::BluetoothStatus::SUCCESS, std::move(addr),
mojom::BluetoothBondState::BONDING);
}
@@ -1032,7 +1030,7 @@ void ArcBluetoothBridge::OnPairedDone(mojom::BluetoothAddressPtr addr) const {
if (!HasBluetoothInstance())
return;
- arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ arc_bridge_service()->bluetooth()->instance()->OnBondStateChanged(
mojom::BluetoothStatus::SUCCESS, std::move(addr),
mojom::BluetoothBondState::BONDED);
}
@@ -1043,7 +1041,7 @@ void ArcBluetoothBridge::OnPairedError(
if (!HasBluetoothInstance())
return;
- arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ arc_bridge_service()->bluetooth()->instance()->OnBondStateChanged(
mojom::BluetoothStatus::FAIL, std::move(addr),
mojom::BluetoothBondState::NONE);
}
@@ -1052,7 +1050,7 @@ void ArcBluetoothBridge::OnForgetDone(mojom::BluetoothAddressPtr addr) const {
if (!HasBluetoothInstance())
return;
- arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ arc_bridge_service()->bluetooth()->instance()->OnBondStateChanged(
mojom::BluetoothStatus::SUCCESS, std::move(addr),
mojom::BluetoothBondState::NONE);
}
@@ -1067,7 +1065,7 @@ void ArcBluetoothBridge::OnForgetError(mojom::BluetoothAddressPtr addr) const {
if (device && device->IsPaired()) {
bond_state = mojom::BluetoothBondState::BONDED;
}
- arc_bridge_service()->bluetooth_instance()->OnBondStateChanged(
+ arc_bridge_service()->bluetooth()->instance()->OnBondStateChanged(
mojom::BluetoothStatus::FAIL, std::move(addr), bond_state);
}
@@ -1281,23 +1279,23 @@ void ArcBluetoothBridge::SendCachedDevicesFound() const {
mojo::Array<mojom::BluetoothPropertyPtr> properties =
GetDeviceProperties(mojom::BluetoothPropertyType::ALL, device);
- arc_bridge_service()->bluetooth_instance()->OnDeviceFound(
+ arc_bridge_service()->bluetooth()->instance()->OnDeviceFound(
std::move(properties));
- if (arc_bridge_service()->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);
- arc_bridge_service()->bluetooth_instance()->OnLEDeviceFound(
+ arc_bridge_service()->bluetooth()->instance()->OnLEDeviceFound(
std::move(addr), rssi, std::move(adv_data));
}
}
}
bool ArcBluetoothBridge::HasBluetoothInstance() const {
- if (!arc_bridge_service()->bluetooth_instance()) {
+ if (!arc_bridge_service()->bluetooth()->instance()) {
LOG(WARNING) << "no Bluetooth instance available";
return false;
}
@@ -1318,17 +1316,17 @@ void ArcBluetoothBridge::SendCachedPairedDevices() const {
mojo::Array<mojom::BluetoothPropertyPtr> properties =
GetDeviceProperties(mojom::BluetoothPropertyType::ALL, device);
- arc_bridge_service()->bluetooth_instance()->OnDeviceFound(
+ arc_bridge_service()->bluetooth()->instance()->OnDeviceFound(
std::move(properties));
mojom::BluetoothAddressPtr addr =
mojom::BluetoothAddress::From(device->GetAddress());
- if (arc_bridge_service()->bluetooth_version() >= kMinBtleVersion) {
+ if (arc_bridge_service()->bluetooth()->version() >= kMinBtleVersion) {
int rssi = device->GetInquiryRSSI();
mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data =
GetAdvertisingData(device);
- arc_bridge_service()->bluetooth_instance()->OnLEDeviceFound(
+ arc_bridge_service()->bluetooth()->instance()->OnLEDeviceFound(
addr->Clone(), rssi, std::move(adv_data));
}
@@ -1343,8 +1341,8 @@ void ArcBluetoothBridge::SendCachedPairedDevices() const {
}
bool ArcBluetoothBridge::CheckBluetoothInstanceVersion(
- int32_t version_need) const {
- int32_t version = arc_bridge_service()->bluetooth_version();
+ uint32_t version_need) const {
+ uint32_t version = arc_bridge_service()->bluetooth()->version();
if (version >= version_need)
return true;
LOG(WARNING) << "Bluetooth instance is too old (version " << version
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | components/arc/clipboard/arc_clipboard_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698