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

Unified Diff: device/bluetooth/bluetooth_device_chromeos.cc

Issue 735893002: Add GetConnectionInfo function for BluetoothDevice, replacing the existing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile errors on other platforms Created 5 years, 11 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 | « device/bluetooth/bluetooth_device_chromeos.h ('k') | device/bluetooth/bluetooth_device_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_device_chromeos.cc
diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_chromeos.cc
index 0fe723ea51a038268b3cca99799a50253cb6414a..285b1dc1331c8d8e33c8a9fa299deb2198b319df 100644
--- a/device/bluetooth/bluetooth_device_chromeos.cc
+++ b/device/bluetooth/bluetooth_device_chromeos.cc
@@ -212,42 +212,6 @@ uint16 BluetoothDeviceChromeOS::GetDeviceID() const {
return device_id;
}
-int BluetoothDeviceChromeOS::GetRSSI() const {
- BluetoothDeviceClient::Properties* properties =
- DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties(
- object_path_);
- DCHECK(properties);
-
- if (!IsConnected()) {
- NOTIMPLEMENTED();
- return kUnknownPower;
- }
-
- return connection_monitor_started_ ? properties->connection_rssi.value()
- : kUnknownPower;
-}
-
-int BluetoothDeviceChromeOS::GetCurrentHostTransmitPower() const {
- BluetoothDeviceClient::Properties* properties =
- DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties(
- object_path_);
- DCHECK(properties);
-
- return IsConnected() && connection_monitor_started_
- ? properties->connection_tx_power.value()
- : kUnknownPower;
-}
-
-int BluetoothDeviceChromeOS::GetMaximumHostTransmitPower() const {
- BluetoothDeviceClient::Properties* properties =
- DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties(
- object_path_);
- DCHECK(properties);
-
- return IsConnected() ? properties->connection_tx_power_max.value()
- : kUnknownPower;
-}
-
bool BluetoothDeviceChromeOS::IsPaired() const {
BluetoothDeviceClient::Properties* properties =
DBusThreadManager::Get()->GetBluetoothDeviceClient()->
@@ -314,6 +278,17 @@ bool BluetoothDeviceChromeOS::ExpectingConfirmation() const {
return pairing_.get() && pairing_->ExpectingConfirmation();
}
+void BluetoothDeviceChromeOS::GetConnectionInfo(
+ const ConnectionInfoCallback& callback) {
+ // DBus method call should gracefully return an error if the device is not
+ // currently connected.
+ DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetConnInfo(
+ object_path_, base::Bind(&BluetoothDeviceChromeOS::OnGetConnInfo,
+ weak_ptr_factory_.GetWeakPtr(), callback),
+ base::Bind(&BluetoothDeviceChromeOS::OnGetConnInfoError,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+}
+
void BluetoothDeviceChromeOS::Connect(
BluetoothDevice::PairingDelegate* pairing_delegate,
const base::Closure& callback,
@@ -461,19 +436,6 @@ void BluetoothDeviceChromeOS::CreateGattConnection(
error_callback);
}
-void BluetoothDeviceChromeOS::StartConnectionMonitor(
- const base::Closure& callback,
- const ErrorCallback& error_callback) {
- DBusThreadManager::Get()->GetBluetoothDeviceClient()->StartConnectionMonitor(
- object_path_,
- base::Bind(&BluetoothDeviceChromeOS::OnStartConnectionMonitor,
- weak_ptr_factory_.GetWeakPtr(),
- callback),
- base::Bind(&BluetoothDeviceChromeOS::OnStartConnectionMonitorError,
- weak_ptr_factory_.GetWeakPtr(),
- error_callback));
-}
-
BluetoothPairingChromeOS* BluetoothDeviceChromeOS::BeginPairing(
BluetoothDevice::PairingDelegate* pairing_delegate) {
pairing_.reset(new BluetoothPairingChromeOS(this, pairing_delegate));
@@ -538,6 +500,24 @@ void BluetoothDeviceChromeOS::GattServiceRemoved(
delete service;
}
+void BluetoothDeviceChromeOS::OnGetConnInfo(
+ const ConnectionInfoCallback& callback,
+ int16 rssi,
+ int16 transmit_power,
+ int16 max_transmit_power) {
+ callback.Run(ConnectionInfo(rssi, transmit_power, max_transmit_power));
+}
+
+void BluetoothDeviceChromeOS::OnGetConnInfoError(
+ const ConnectionInfoCallback& callback,
+ const std::string& error_name,
+ const std::string& error_message) {
+ LOG(WARNING) << object_path_.value()
+ << ": Failed to get connection info: " << error_name << ": "
+ << error_message;
+ callback.Run(ConnectionInfo());
+}
+
void BluetoothDeviceChromeOS::ConnectInternal(
bool after_pairing,
const base::Closure& callback,
@@ -681,22 +661,6 @@ void BluetoothDeviceChromeOS::OnSetTrusted(bool success) {
<< ": Failed to set device as trusted";
}
-void BluetoothDeviceChromeOS::OnStartConnectionMonitor(
- const base::Closure& callback) {
- connection_monitor_started_ = true;
- callback.Run();
-}
-
-void BluetoothDeviceChromeOS::OnStartConnectionMonitorError(
- const ErrorCallback& error_callback,
- const std::string& error_name,
- const std::string& error_message) {
- LOG(WARNING) << object_path_.value()
- << ": Failed to start connection monitor: " << error_name << ": "
- << error_message;
- error_callback.Run();
-}
-
void BluetoothDeviceChromeOS::OnDisconnect(const base::Closure& callback) {
VLOG(1) << object_path_.value() << ": Disconnected";
callback.Run();
« no previous file with comments | « device/bluetooth/bluetooth_device_chromeos.h ('k') | device/bluetooth/bluetooth_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698