OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/experimental_bluetooth_device_client.h" | 5 #include "chromeos/dbus/experimental_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 "chromeos/dbus/fake_bluetooth_device_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 virtual void RemoveObserver( | 79 virtual void RemoveObserver( |
80 ExperimentalBluetoothDeviceClient::Observer* observer) OVERRIDE { | 80 ExperimentalBluetoothDeviceClient::Observer* observer) OVERRIDE { |
81 DCHECK(observer); | 81 DCHECK(observer); |
82 observers_.RemoveObserver(observer); | 82 observers_.RemoveObserver(observer); |
83 } | 83 } |
84 | 84 |
85 // dbus::ObjectManager::Interface override. | 85 // dbus::ObjectManager::Interface override. |
86 virtual dbus::PropertySet* CreateProperties( | 86 virtual dbus::PropertySet* CreateProperties( |
87 dbus::ObjectProxy* object_proxy, | 87 dbus::ObjectProxy* object_proxy, |
88 const dbus::ObjectPath& object_path, | 88 const dbus::ObjectPath& object_path, |
89 const std::string& interface_name) { | 89 const std::string& interface_name) OVERRIDE { |
90 Properties* properties = new Properties( | 90 Properties* properties = new Properties( |
91 object_proxy, interface_name, | 91 object_proxy, |
| 92 interface_name, |
92 base::Bind(&ExperimentalBluetoothDeviceClientImpl::OnPropertyChanged, | 93 base::Bind(&ExperimentalBluetoothDeviceClientImpl::OnPropertyChanged, |
93 weak_ptr_factory_.GetWeakPtr(), | 94 weak_ptr_factory_.GetWeakPtr(), |
94 object_path)); | 95 object_path)); |
95 return static_cast<dbus::PropertySet*>(properties); | 96 return static_cast<dbus::PropertySet*>(properties); |
96 } | 97 } |
97 | 98 |
98 // ExperimentalBluetoothDeviceClient override. | 99 // ExperimentalBluetoothDeviceClient override. |
99 virtual std::vector<dbus::ObjectPath> GetDevicesForAdapter( | 100 virtual std::vector<dbus::ObjectPath> GetDevicesForAdapter( |
100 const dbus::ObjectPath& adapter_path) OVERRIDE { | 101 const dbus::ObjectPath& adapter_path) OVERRIDE { |
101 std::vector<dbus::ObjectPath> object_paths, device_paths; | 102 std::vector<dbus::ObjectPath> object_paths, device_paths; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 272 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
272 base::Bind(&ExperimentalBluetoothDeviceClientImpl::OnSuccess, | 273 base::Bind(&ExperimentalBluetoothDeviceClientImpl::OnSuccess, |
273 weak_ptr_factory_.GetWeakPtr(), callback), | 274 weak_ptr_factory_.GetWeakPtr(), callback), |
274 base::Bind(&ExperimentalBluetoothDeviceClientImpl::OnError, | 275 base::Bind(&ExperimentalBluetoothDeviceClientImpl::OnError, |
275 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 276 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
276 } | 277 } |
277 | 278 |
278 private: | 279 private: |
279 // Called by dbus::ObjectManager when an object with the device interface | 280 // Called by dbus::ObjectManager when an object with the device interface |
280 // is created. Informs observers. | 281 // is created. Informs observers. |
281 void ObjectAdded(const dbus::ObjectPath& object_path, | 282 virtual void ObjectAdded(const dbus::ObjectPath& object_path, |
282 const std::string& interface_name) OVERRIDE { | 283 const std::string& interface_name) OVERRIDE { |
283 FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, | 284 FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, |
| 285 observers_, |
284 DeviceAdded(object_path)); | 286 DeviceAdded(object_path)); |
285 } | 287 } |
286 | 288 |
287 // Called by dbus::ObjectManager when an object with the device interface | 289 // Called by dbus::ObjectManager when an object with the device interface |
288 // is removed. Informs observers. | 290 // is removed. Informs observers. |
289 void ObjectRemoved(const dbus::ObjectPath& object_path, | 291 virtual void ObjectRemoved(const dbus::ObjectPath& object_path, |
290 const std::string& interface_name) OVERRIDE { | 292 const std::string& interface_name) OVERRIDE { |
291 FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, | 293 FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, |
| 294 observers_, |
292 DeviceRemoved(object_path)); | 295 DeviceRemoved(object_path)); |
293 } | 296 } |
294 | 297 |
295 // Called by BluetoothPropertySet when a property value is changed, | 298 // Called by BluetoothPropertySet when a property value is changed, |
296 // either by result of a signal or response to a GetAll() or Get() | 299 // either by result of a signal or response to a GetAll() or Get() |
297 // call. Informs observers. | 300 // call. Informs observers. |
298 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 301 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
299 const std::string& property_name) { | 302 const std::string& property_name) { |
300 FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, | 303 FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
301 DevicePropertyChanged(object_path, property_name)); | 304 DevicePropertyChanged(object_path, property_name)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 ExperimentalBluetoothDeviceClient* ExperimentalBluetoothDeviceClient::Create( | 352 ExperimentalBluetoothDeviceClient* ExperimentalBluetoothDeviceClient::Create( |
350 DBusClientImplementationType type, | 353 DBusClientImplementationType type, |
351 dbus::Bus* bus) { | 354 dbus::Bus* bus) { |
352 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 355 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
353 return new ExperimentalBluetoothDeviceClientImpl(bus); | 356 return new ExperimentalBluetoothDeviceClientImpl(bus); |
354 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 357 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
355 return new FakeBluetoothDeviceClient(); | 358 return new FakeBluetoothDeviceClient(); |
356 } | 359 } |
357 | 360 |
358 } // namespace chromeos | 361 } // namespace chromeos |
OLD | NEW |