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

Unified Diff: chrome/browser/chromeos/dbus/bluetooth_manager_client.cc

Issue 9302027: chrome: bluetooth: hook up the AdapterAdded signal (Closed) Base URL: http://git.chromium.org/git/chromium/src@master
Patch Set: Another attempt to change base url with a tiny change Created 8 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 | « chrome/browser/chromeos/dbus/bluetooth_manager_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/dbus/bluetooth_manager_client.cc
diff --git a/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc b/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc
index 9419e3ba2b26d4373d0ba5bcefb36f23679bb7e7..1c05334614a1d14958953be1450af2fa672aace1 100644
--- a/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc
+++ b/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc
@@ -30,6 +30,14 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient {
bluetooth_manager_proxy_->ConnectToSignal(
bluetooth_manager::kBluetoothManagerInterface,
+ bluetooth_manager::kAdapterAddedSignal,
+ base::Bind(&BluetoothManagerClientImpl::AdapterAddedReceived,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&BluetoothManagerClientImpl::AdapterAddedConnected,
+ weak_ptr_factory_.GetWeakPtr()));
+
+ bluetooth_manager_proxy_->ConnectToSignal(
+ bluetooth_manager::kBluetoothManagerInterface,
bluetooth_manager::kAdapterRemovedSignal,
base::Bind(&BluetoothManagerClientImpl::AdapterRemovedReceived,
weak_ptr_factory_.GetWeakPtr()),
@@ -79,18 +87,39 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient {
}
private:
+ // Called by dbus:: when an AdapterAdded signal is received.
+ void AdapterAddedReceived(dbus::Signal* signal) {
+ DCHECK(signal);
+ dbus::MessageReader reader(signal);
+ std::string object_path;
+ if (!reader.PopObjectPath(&object_path)) {
+ LOG(ERROR) << "AdapterAdded signal has incorrect parameters: "
+ << signal->ToString();
+ return;
+ }
+ VLOG(1) << "Adapter added: " << object_path;
+ FOR_EACH_OBSERVER(Observer, observers_, AdapterAdded(object_path));
+ }
+
+ // Called by dbus:: when the AdapterAdded signal is initially connected.
+ void AdapterAddedConnected(const std::string& interface_name,
+ const std::string& signal_name,
+ bool success) {
+ LOG_IF(WARNING, !success) << "Failed to connect to AdapterAdded signal.";
+ }
+
// Called by dbus:: when an AdapterRemoved signal is received.
void AdapterRemovedReceived(dbus::Signal* signal) {
DCHECK(signal);
dbus::MessageReader reader(signal);
- std::string adapter;
- if (!reader.PopObjectPath(&adapter)) {
+ std::string object_path;
+ if (!reader.PopObjectPath(&object_path)) {
LOG(ERROR) << "AdapterRemoved signal has incorrect parameters: "
<< signal->ToString();
return;
}
- VLOG(1) << "Adapter removed: " << adapter;
- FOR_EACH_OBSERVER(Observer, observers_, AdapterRemoved(adapter));
+ VLOG(1) << "Adapter removed: " << object_path;
+ FOR_EACH_OBSERVER(Observer, observers_, AdapterRemoved(object_path));
}
// Called by dbus:: when the AdapterRemoved signal is initially connected.
« no previous file with comments | « chrome/browser/chromeos/dbus/bluetooth_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698