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_device_client.h" | 5 #include "chromeos/dbus/bluetooth_device_client.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 | 51 |
52 // The BluetoothDeviceClient implementation used in production. | 52 // The BluetoothDeviceClient implementation used in production. |
53 class BluetoothDeviceClientImpl: public BluetoothDeviceClient, | 53 class BluetoothDeviceClientImpl: public BluetoothDeviceClient, |
54 private BluetoothAdapterClient::Observer { | 54 private BluetoothAdapterClient::Observer { |
55 public: | 55 public: |
56 BluetoothDeviceClientImpl(dbus::Bus* bus, | 56 BluetoothDeviceClientImpl(dbus::Bus* bus, |
57 BluetoothAdapterClient* adapter_client) | 57 BluetoothAdapterClient* adapter_client) |
58 : bus_(bus), | 58 : bus_(bus), |
59 weak_ptr_factory_(this) { | 59 weak_ptr_factory_(this) { |
60 DVLOG(1) << "Creating BluetoothDeviceClientImpl"; | 60 VLOG(1) << "Creating BluetoothDeviceClientImpl"; |
61 | 61 |
62 DCHECK(adapter_client); | 62 DCHECK(adapter_client); |
63 adapter_client->AddObserver(this); | 63 adapter_client->AddObserver(this); |
64 } | 64 } |
65 | 65 |
66 virtual ~BluetoothDeviceClientImpl() { | 66 virtual ~BluetoothDeviceClientImpl() { |
67 // Clean up Properties structures | 67 // Clean up Properties structures |
68 for (ObjectMap::iterator iter = object_map_.begin(); | 68 for (ObjectMap::iterator iter = object_map_.begin(); |
69 iter != object_map_.end(); ++iter) { | 69 iter != object_map_.end(); ++iter) { |
70 Object object = iter->second; | 70 Object object = iter->second; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 const std::string& property_name) { | 281 const std::string& property_name) { |
282 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, | 282 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
283 DevicePropertyChanged(object_path, property_name)); | 283 DevicePropertyChanged(object_path, property_name)); |
284 } | 284 } |
285 | 285 |
286 // Called by dbus:: when a DisconnectRequested signal is received. | 286 // Called by dbus:: when a DisconnectRequested signal is received. |
287 void DisconnectRequestedReceived(const dbus::ObjectPath& object_path, | 287 void DisconnectRequestedReceived(const dbus::ObjectPath& object_path, |
288 dbus::Signal* signal) { | 288 dbus::Signal* signal) { |
289 DCHECK(signal); | 289 DCHECK(signal); |
290 | 290 |
291 DVLOG(1) << object_path.value() << ": Disconnect requested."; | 291 VLOG(1) << object_path.value() << ": Disconnect requested."; |
292 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, | 292 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
293 DisconnectRequested(object_path)); | 293 DisconnectRequested(object_path)); |
294 } | 294 } |
295 | 295 |
296 // Called by dbus:: when the DisconnectRequested signal is initially | 296 // Called by dbus:: when the DisconnectRequested signal is initially |
297 // connected. | 297 // connected. |
298 void DisconnectRequestedConnected(const dbus::ObjectPath& object_path, | 298 void DisconnectRequestedConnected(const dbus::ObjectPath& object_path, |
299 const std::string& interface_name, | 299 const std::string& interface_name, |
300 const std::string& signal_name, | 300 const std::string& signal_name, |
301 bool success) { | 301 bool success) { |
302 LOG_IF(WARNING, !success) << object_path.value() | 302 LOG_IF(WARNING, !success) << object_path.value() |
303 << ": Failed to connect to " | 303 << ": Failed to connect to " |
304 "DisconnectRequested signal."; | 304 "DisconnectRequested signal."; |
305 } | 305 } |
306 | 306 |
307 // Called by dbus:: when a NodeCreated signal is received. | 307 // Called by dbus:: when a NodeCreated signal is received. |
308 void NodeCreatedReceived(const dbus::ObjectPath& object_path, | 308 void NodeCreatedReceived(const dbus::ObjectPath& object_path, |
309 dbus::Signal* signal) { | 309 dbus::Signal* signal) { |
310 DCHECK(signal); | 310 DCHECK(signal); |
311 dbus::MessageReader reader(signal); | 311 dbus::MessageReader reader(signal); |
312 dbus::ObjectPath node_path; | 312 dbus::ObjectPath node_path; |
313 if (!reader.PopObjectPath(&node_path)) { | 313 if (!reader.PopObjectPath(&node_path)) { |
314 LOG(WARNING) << object_path.value() | 314 LOG(WARNING) << object_path.value() |
315 << ": NodeCreated signal has incorrect parameters: " | 315 << ": NodeCreated signal has incorrect parameters: " |
316 << signal->ToString(); | 316 << signal->ToString(); |
317 return; | 317 return; |
318 } | 318 } |
319 | 319 |
320 DVLOG(1) << object_path.value() << ": Node created: " | 320 VLOG(1) << object_path.value() << ": Node created: " |
321 << node_path.value(); | 321 << node_path.value(); |
322 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, | 322 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
323 NodeCreated(object_path, node_path)); | 323 NodeCreated(object_path, node_path)); |
324 } | 324 } |
325 | 325 |
326 // Called by dbus:: when the NodeCreated signal is initially connected. | 326 // Called by dbus:: when the NodeCreated signal is initially connected. |
327 void NodeCreatedConnected(const dbus::ObjectPath& object_path, | 327 void NodeCreatedConnected(const dbus::ObjectPath& object_path, |
328 const std::string& interface_name, | 328 const std::string& interface_name, |
329 const std::string& signal_name, | 329 const std::string& signal_name, |
330 bool success) { | 330 bool success) { |
331 LOG_IF(WARNING, !success) << object_path.value() | 331 LOG_IF(WARNING, !success) << object_path.value() |
332 << ": Failed to connect to NodeCreated signal."; | 332 << ": Failed to connect to NodeCreated signal."; |
333 } | 333 } |
334 | 334 |
335 // Called by dbus:: when a NodeRemoved signal is received. | 335 // Called by dbus:: when a NodeRemoved signal is received. |
336 void NodeRemovedReceived(const dbus::ObjectPath& object_path, | 336 void NodeRemovedReceived(const dbus::ObjectPath& object_path, |
337 dbus::Signal* signal) { | 337 dbus::Signal* signal) { |
338 DCHECK(signal); | 338 DCHECK(signal); |
339 dbus::MessageReader reader(signal); | 339 dbus::MessageReader reader(signal); |
340 dbus::ObjectPath node_path; | 340 dbus::ObjectPath node_path; |
341 if (!reader.PopObjectPath(&node_path)) { | 341 if (!reader.PopObjectPath(&node_path)) { |
342 LOG(WARNING) << object_path.value() | 342 LOG(WARNING) << object_path.value() |
343 << ": NodeRemoved signal has incorrect parameters: " | 343 << ": NodeRemoved signal has incorrect parameters: " |
344 << signal->ToString(); | 344 << signal->ToString(); |
345 return; | 345 return; |
346 } | 346 } |
347 | 347 |
348 DVLOG(1) << object_path.value() << ": Node removed: " | 348 VLOG(1) << object_path.value() << ": Node removed: " |
349 << node_path.value(); | 349 << node_path.value(); |
350 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, | 350 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
351 NodeRemoved(object_path, node_path)); | 351 NodeRemoved(object_path, node_path)); |
352 } | 352 } |
353 | 353 |
354 // Called by dbus:: when the NodeRemoved signal is initially connected. | 354 // Called by dbus:: when the NodeRemoved signal is initially connected. |
355 void NodeRemovedConnected(const dbus::ObjectPath& object_path, | 355 void NodeRemovedConnected(const dbus::ObjectPath& object_path, |
356 const std::string& interface_name, | 356 const std::string& interface_name, |
357 const std::string& signal_name, | 357 const std::string& signal_name, |
358 bool success) { | 358 bool success) { |
359 LOG_IF(WARNING, !success) << object_path.value() | 359 LOG_IF(WARNING, !success) << object_path.value() |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 DBusClientImplementationType type, | 598 DBusClientImplementationType type, |
599 dbus::Bus* bus, | 599 dbus::Bus* bus, |
600 BluetoothAdapterClient* adapter_client) { | 600 BluetoothAdapterClient* adapter_client) { |
601 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 601 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
602 return new BluetoothDeviceClientImpl(bus, adapter_client); | 602 return new BluetoothDeviceClientImpl(bus, adapter_client); |
603 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 603 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
604 return new BluetoothDeviceClientStubImpl(); | 604 return new BluetoothDeviceClientStubImpl(); |
605 } | 605 } |
606 | 606 |
607 } // namespace chromeos | 607 } // namespace chromeos |
OLD | NEW |