OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_manager_client.h" | 5 #include "chromeos/dbus/bluetooth_manager_client.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 BluetoothManagerClient::Properties::~Properties() { | 30 BluetoothManagerClient::Properties::~Properties() { |
31 } | 31 } |
32 | 32 |
33 | 33 |
34 // The BluetoothManagerClient implementation used in production. | 34 // The BluetoothManagerClient implementation used in production. |
35 class BluetoothManagerClientImpl : public BluetoothManagerClient { | 35 class BluetoothManagerClientImpl : public BluetoothManagerClient { |
36 public: | 36 public: |
37 explicit BluetoothManagerClientImpl(dbus::Bus* bus) | 37 explicit BluetoothManagerClientImpl(dbus::Bus* bus) |
38 : object_proxy_(NULL), | 38 : object_proxy_(NULL), |
39 weak_ptr_factory_(this) { | 39 weak_ptr_factory_(this) { |
40 DVLOG(1) << "Creating BluetoothManagerClientImpl"; | |
41 | |
42 // Create the object proxy. | 40 // Create the object proxy. |
43 DCHECK(bus); | 41 DCHECK(bus); |
44 object_proxy_ = bus->GetObjectProxy( | 42 object_proxy_ = bus->GetObjectProxy( |
45 bluetooth_manager::kBluetoothManagerServiceName, | 43 bluetooth_manager::kBluetoothManagerServiceName, |
46 dbus::ObjectPath(bluetooth_manager::kBluetoothManagerServicePath)); | 44 dbus::ObjectPath(bluetooth_manager::kBluetoothManagerServicePath)); |
47 | 45 |
48 object_proxy_->ConnectToSignal( | 46 object_proxy_->ConnectToSignal( |
49 bluetooth_manager::kBluetoothManagerInterface, | 47 bluetooth_manager::kBluetoothManagerInterface, |
50 bluetooth_manager::kAdapterAddedSignal, | 48 bluetooth_manager::kAdapterAddedSignal, |
51 base::Bind(&BluetoothManagerClientImpl::AdapterAddedReceived, | 49 base::Bind(&BluetoothManagerClientImpl::AdapterAddedReceived, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 void AdapterAddedReceived(dbus::Signal* signal) { | 144 void AdapterAddedReceived(dbus::Signal* signal) { |
147 DCHECK(signal); | 145 DCHECK(signal); |
148 dbus::MessageReader reader(signal); | 146 dbus::MessageReader reader(signal); |
149 dbus::ObjectPath object_path; | 147 dbus::ObjectPath object_path; |
150 if (!reader.PopObjectPath(&object_path)) { | 148 if (!reader.PopObjectPath(&object_path)) { |
151 LOG(WARNING) << "AdapterAdded signal has incorrect parameters: " | 149 LOG(WARNING) << "AdapterAdded signal has incorrect parameters: " |
152 << signal->ToString(); | 150 << signal->ToString(); |
153 return; | 151 return; |
154 } | 152 } |
155 | 153 |
156 DVLOG(1) << "Adapter added: " << object_path.value(); | 154 VLOG(1) << "Adapter added: " << object_path.value(); |
157 FOR_EACH_OBSERVER(Observer, observers_, AdapterAdded(object_path)); | 155 FOR_EACH_OBSERVER(Observer, observers_, AdapterAdded(object_path)); |
158 } | 156 } |
159 | 157 |
160 // Called by dbus:: when the AdapterAdded signal is initially connected. | 158 // Called by dbus:: when the AdapterAdded signal is initially connected. |
161 void AdapterAddedConnected(const std::string& interface_name, | 159 void AdapterAddedConnected(const std::string& interface_name, |
162 const std::string& signal_name, | 160 const std::string& signal_name, |
163 bool success) { | 161 bool success) { |
164 LOG_IF(WARNING, !success) << "Failed to connect to AdapterAdded signal."; | 162 LOG_IF(WARNING, !success) << "Failed to connect to AdapterAdded signal."; |
165 } | 163 } |
166 | 164 |
167 // Called by dbus:: when an AdapterRemoved signal is received. | 165 // Called by dbus:: when an AdapterRemoved signal is received. |
168 void AdapterRemovedReceived(dbus::Signal* signal) { | 166 void AdapterRemovedReceived(dbus::Signal* signal) { |
169 DCHECK(signal); | 167 DCHECK(signal); |
170 dbus::MessageReader reader(signal); | 168 dbus::MessageReader reader(signal); |
171 dbus::ObjectPath object_path; | 169 dbus::ObjectPath object_path; |
172 if (!reader.PopObjectPath(&object_path)) { | 170 if (!reader.PopObjectPath(&object_path)) { |
173 LOG(WARNING) << "AdapterRemoved signal has incorrect parameters: " | 171 LOG(WARNING) << "AdapterRemoved signal has incorrect parameters: " |
174 << signal->ToString(); | 172 << signal->ToString(); |
175 return; | 173 return; |
176 } | 174 } |
177 | 175 |
178 DVLOG(1) << "Adapter removed: " << object_path.value(); | 176 VLOG(1) << "Adapter removed: " << object_path.value(); |
179 FOR_EACH_OBSERVER(Observer, observers_, AdapterRemoved(object_path)); | 177 FOR_EACH_OBSERVER(Observer, observers_, AdapterRemoved(object_path)); |
180 } | 178 } |
181 | 179 |
182 // Called by dbus:: when the AdapterRemoved signal is initially connected. | 180 // Called by dbus:: when the AdapterRemoved signal is initially connected. |
183 void AdapterRemovedConnected(const std::string& interface_name, | 181 void AdapterRemovedConnected(const std::string& interface_name, |
184 const std::string& signal_name, | 182 const std::string& signal_name, |
185 bool success) { | 183 bool success) { |
186 LOG_IF(WARNING, !success) << "Failed to connect to AdapterRemoved signal."; | 184 LOG_IF(WARNING, !success) << "Failed to connect to AdapterRemoved signal."; |
187 } | 185 } |
188 | 186 |
189 // Called by dbus:: when a DefaultAdapterChanged signal is received. | 187 // Called by dbus:: when a DefaultAdapterChanged signal is received. |
190 void DefaultAdapterChangedReceived(dbus::Signal* signal) { | 188 void DefaultAdapterChangedReceived(dbus::Signal* signal) { |
191 DCHECK(signal); | 189 DCHECK(signal); |
192 dbus::MessageReader reader(signal); | 190 dbus::MessageReader reader(signal); |
193 dbus::ObjectPath object_path; | 191 dbus::ObjectPath object_path; |
194 if (!reader.PopObjectPath(&object_path)) { | 192 if (!reader.PopObjectPath(&object_path)) { |
195 LOG(WARNING) << "DefaultAdapterChanged signal has incorrect parameters: " | 193 LOG(WARNING) << "DefaultAdapterChanged signal has incorrect parameters: " |
196 << signal->ToString(); | 194 << signal->ToString(); |
197 return; | 195 return; |
198 } | 196 } |
199 | 197 |
200 DVLOG(1) << "Default adapter changed: " << object_path.value(); | 198 VLOG(1) << "Default adapter changed: " << object_path.value(); |
201 FOR_EACH_OBSERVER(Observer, observers_, DefaultAdapterChanged(object_path)); | 199 FOR_EACH_OBSERVER(Observer, observers_, DefaultAdapterChanged(object_path)); |
202 } | 200 } |
203 | 201 |
204 // Called by dbus:: when the DefaultAdapterChanged signal is initially | 202 // Called by dbus:: when the DefaultAdapterChanged signal is initially |
205 // connected. | 203 // connected. |
206 void DefaultAdapterChangedConnected(const std::string& interface_name, | 204 void DefaultAdapterChangedConnected(const std::string& interface_name, |
207 const std::string& signal_name, | 205 const std::string& signal_name, |
208 bool success) { | 206 bool success) { |
209 LOG_IF(WARNING, !success) | 207 LOG_IF(WARNING, !success) |
210 << "Failed to connect to DefaultAdapterChanged signal."; | 208 << "Failed to connect to DefaultAdapterChanged signal."; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 BluetoothManagerClient* BluetoothManagerClient::Create( | 363 BluetoothManagerClient* BluetoothManagerClient::Create( |
366 DBusClientImplementationType type, | 364 DBusClientImplementationType type, |
367 dbus::Bus* bus) { | 365 dbus::Bus* bus) { |
368 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 366 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
369 return new BluetoothManagerClientImpl(bus); | 367 return new BluetoothManagerClientImpl(bus); |
370 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 368 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
371 return new BluetoothManagerClientStubImpl(); | 369 return new BluetoothManagerClientStubImpl(); |
372 } | 370 } |
373 | 371 |
374 } // namespace chromeos | 372 } // namespace chromeos |
OLD | NEW |