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

Side by Side Diff: chromeos/dbus/bluetooth_device_client.cc

Issue 273953002: Hook up RSSI and host transmit power Bluetooth device properties for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang warnings, test flakiness, and bluetooth.connect should succeed even if monitor fails Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/bluetooth_device_client.h ('k') | chromeos/dbus/fake_bluetooth_device_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chromeos/dbus/bluetooth_device_client.h" 5 #include "chromeos/dbus/bluetooth_device_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "dbus/bus.h" 10 #include "dbus/bus.h"
(...skipping 23 matching lines...) Expand all
34 RegisterProperty(bluetooth_device::kUUIDsProperty, &uuids); 34 RegisterProperty(bluetooth_device::kUUIDsProperty, &uuids);
35 RegisterProperty(bluetooth_device::kPairedProperty, &paired); 35 RegisterProperty(bluetooth_device::kPairedProperty, &paired);
36 RegisterProperty(bluetooth_device::kConnectedProperty, &connected); 36 RegisterProperty(bluetooth_device::kConnectedProperty, &connected);
37 RegisterProperty(bluetooth_device::kTrustedProperty, &trusted); 37 RegisterProperty(bluetooth_device::kTrustedProperty, &trusted);
38 RegisterProperty(bluetooth_device::kBlockedProperty, &blocked); 38 RegisterProperty(bluetooth_device::kBlockedProperty, &blocked);
39 RegisterProperty(bluetooth_device::kAliasProperty, &alias); 39 RegisterProperty(bluetooth_device::kAliasProperty, &alias);
40 RegisterProperty(bluetooth_device::kAdapterProperty, &adapter); 40 RegisterProperty(bluetooth_device::kAdapterProperty, &adapter);
41 RegisterProperty(bluetooth_device::kLegacyPairingProperty, &legacy_pairing); 41 RegisterProperty(bluetooth_device::kLegacyPairingProperty, &legacy_pairing);
42 RegisterProperty(bluetooth_device::kModaliasProperty, &modalias); 42 RegisterProperty(bluetooth_device::kModaliasProperty, &modalias);
43 RegisterProperty(bluetooth_device::kRSSIProperty, &rssi); 43 RegisterProperty(bluetooth_device::kRSSIProperty, &rssi);
44 RegisterProperty(bluetooth_device::kConnectionRSSI, &connection_rssi);
45 RegisterProperty(bluetooth_device::kConnectionTXPower, &connection_tx_power);
46 RegisterProperty(bluetooth_device::kConnectionTXPowerMax,
47 &connection_tx_power_max);
44 } 48 }
45 49
46 BluetoothDeviceClient::Properties::~Properties() { 50 BluetoothDeviceClient::Properties::~Properties() {
47 } 51 }
48 52
49 53
50 // The BluetoothDeviceClient implementation used in production. 54 // The BluetoothDeviceClient implementation used in production.
51 class BluetoothDeviceClientImpl 55 class BluetoothDeviceClientImpl
52 : public BluetoothDeviceClient, 56 : public BluetoothDeviceClient,
53 public dbus::ObjectManager::Interface { 57 public dbus::ObjectManager::Interface {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 264 }
261 object_proxy->CallMethodWithErrorCallback( 265 object_proxy->CallMethodWithErrorCallback(
262 &method_call, 266 &method_call,
263 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 267 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
264 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, 268 base::Bind(&BluetoothDeviceClientImpl::OnSuccess,
265 weak_ptr_factory_.GetWeakPtr(), callback), 269 weak_ptr_factory_.GetWeakPtr(), callback),
266 base::Bind(&BluetoothDeviceClientImpl::OnError, 270 base::Bind(&BluetoothDeviceClientImpl::OnError,
267 weak_ptr_factory_.GetWeakPtr(), error_callback)); 271 weak_ptr_factory_.GetWeakPtr(), error_callback));
268 } 272 }
269 273
274 // BluetoothDeviceClient override.
275 virtual void StartConnectionMonitor(
276 const dbus::ObjectPath& object_path,
277 const base::Closure& callback,
278 const ErrorCallback& error_callback) OVERRIDE {
279 dbus::MethodCall method_call(bluetooth_device::kBluetoothDeviceInterface,
280 bluetooth_device::kStartConnectionMonitor);
281
282 dbus::ObjectProxy* object_proxy =
283 object_manager_->GetObjectProxy(object_path);
284 if (!object_proxy) {
285 error_callback.Run(kUnknownDeviceError, "");
286 return;
287 }
288 object_proxy->CallMethodWithErrorCallback(
289 &method_call,
290 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
291 base::Bind(&BluetoothDeviceClientImpl::OnSuccess,
292 weak_ptr_factory_.GetWeakPtr(),
293 callback),
294 base::Bind(&BluetoothDeviceClientImpl::OnError,
295 weak_ptr_factory_.GetWeakPtr(),
296 error_callback));
297 }
298
299 // BluetoothDeviceClient override.
300 virtual void StopConnectionMonitor(
301 const dbus::ObjectPath& object_path,
302 const base::Closure& callback,
303 const ErrorCallback& error_callback) OVERRIDE {
304 dbus::MethodCall method_call(bluetooth_device::kBluetoothDeviceInterface,
305 bluetooth_device::kStopConnectionMonitor);
306
307 dbus::ObjectProxy* object_proxy =
308 object_manager_->GetObjectProxy(object_path);
309 if (!object_proxy) {
310 error_callback.Run(kUnknownDeviceError, "");
311 return;
312 }
313 object_proxy->CallMethodWithErrorCallback(
314 &method_call,
315 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
316 base::Bind(&BluetoothDeviceClientImpl::OnSuccess,
317 weak_ptr_factory_.GetWeakPtr(),
318 callback),
319 base::Bind(&BluetoothDeviceClientImpl::OnError,
320 weak_ptr_factory_.GetWeakPtr(),
321 error_callback));
322 }
323
270 protected: 324 protected:
271 virtual void Init(dbus::Bus* bus) OVERRIDE { 325 virtual void Init(dbus::Bus* bus) OVERRIDE {
272 object_manager_ = bus->GetObjectManager( 326 object_manager_ = bus->GetObjectManager(
273 bluetooth_object_manager::kBluetoothObjectManagerServiceName, 327 bluetooth_object_manager::kBluetoothObjectManagerServiceName,
274 dbus::ObjectPath( 328 dbus::ObjectPath(
275 bluetooth_object_manager::kBluetoothObjectManagerServicePath)); 329 bluetooth_object_manager::kBluetoothObjectManagerServicePath));
276 object_manager_->RegisterInterface( 330 object_manager_->RegisterInterface(
277 bluetooth_device::kBluetoothDeviceInterface, this); 331 bluetooth_device::kBluetoothDeviceInterface, this);
278 } 332 }
279 333
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 399 }
346 400
347 BluetoothDeviceClient::~BluetoothDeviceClient() { 401 BluetoothDeviceClient::~BluetoothDeviceClient() {
348 } 402 }
349 403
350 BluetoothDeviceClient* BluetoothDeviceClient::Create() { 404 BluetoothDeviceClient* BluetoothDeviceClient::Create() {
351 return new BluetoothDeviceClientImpl(); 405 return new BluetoothDeviceClientImpl();
352 } 406 }
353 407
354 } // namespace chromeos 408 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/bluetooth_device_client.h ('k') | chromeos/dbus/fake_bluetooth_device_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698