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_adapter_client.h" | 5 #include "chromeos/dbus/experimental_bluetooth_adapter_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 "chromeos/dbus/fake_bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
10 #include "dbus/bus.h" | 10 #include "dbus/bus.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 // ExperimentalBluetoothAdapterClient override. | 76 // ExperimentalBluetoothAdapterClient override. |
77 virtual void RemoveObserver( | 77 virtual void RemoveObserver( |
78 ExperimentalBluetoothAdapterClient::Observer* observer) OVERRIDE { | 78 ExperimentalBluetoothAdapterClient::Observer* observer) OVERRIDE { |
79 DCHECK(observer); | 79 DCHECK(observer); |
80 observers_.RemoveObserver(observer); | 80 observers_.RemoveObserver(observer); |
81 } | 81 } |
82 | 82 |
83 // Returns the list of adapter object paths known to the system. | 83 // Returns the list of adapter object paths known to the system. |
84 virtual std::vector<dbus::ObjectPath> GetAdapters() { | 84 virtual std::vector<dbus::ObjectPath> GetAdapters() OVERRIDE { |
85 return object_manager_->GetObjectsWithInterface( | 85 return object_manager_->GetObjectsWithInterface( |
86 bluetooth_adapter::kExperimentalBluetoothAdapterInterface); | 86 bluetooth_adapter::kExperimentalBluetoothAdapterInterface); |
87 } | 87 } |
88 | 88 |
89 // dbus::ObjectManager::Interface override. | 89 // dbus::ObjectManager::Interface override. |
90 virtual dbus::PropertySet* CreateProperties( | 90 virtual dbus::PropertySet* CreateProperties( |
91 dbus::ObjectProxy* object_proxy, | 91 dbus::ObjectProxy* object_proxy, |
92 const dbus::ObjectPath& object_path, | 92 const dbus::ObjectPath& object_path, |
93 const std::string& interface_name) { | 93 const std::string& interface_name) OVERRIDE { |
94 Properties* properties = new Properties( | 94 Properties* properties = new Properties( |
95 object_proxy, interface_name, | 95 object_proxy, |
| 96 interface_name, |
96 base::Bind(&ExperimentalBluetoothAdapterClientImpl::OnPropertyChanged, | 97 base::Bind(&ExperimentalBluetoothAdapterClientImpl::OnPropertyChanged, |
97 weak_ptr_factory_.GetWeakPtr(), | 98 weak_ptr_factory_.GetWeakPtr(), |
98 object_path)); | 99 object_path)); |
99 return static_cast<dbus::PropertySet*>(properties); | 100 return static_cast<dbus::PropertySet*>(properties); |
100 } | 101 } |
101 | 102 |
102 // ExperimentalBluetoothAdapterClient override. | 103 // ExperimentalBluetoothAdapterClient override. |
103 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) | 104 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) |
104 OVERRIDE { | 105 OVERRIDE { |
105 return static_cast<Properties*>( | 106 return static_cast<Properties*>( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 181 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
181 base::Bind(&ExperimentalBluetoothAdapterClientImpl::OnSuccess, | 182 base::Bind(&ExperimentalBluetoothAdapterClientImpl::OnSuccess, |
182 weak_ptr_factory_.GetWeakPtr(), callback), | 183 weak_ptr_factory_.GetWeakPtr(), callback), |
183 base::Bind(&ExperimentalBluetoothAdapterClientImpl::OnError, | 184 base::Bind(&ExperimentalBluetoothAdapterClientImpl::OnError, |
184 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 185 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
185 } | 186 } |
186 | 187 |
187 private: | 188 private: |
188 // Called by dbus::ObjectManager when an object with the adapter interface | 189 // Called by dbus::ObjectManager when an object with the adapter interface |
189 // is created. Informs observers. | 190 // is created. Informs observers. |
190 void ObjectAdded(const dbus::ObjectPath& object_path, | 191 virtual void ObjectAdded(const dbus::ObjectPath& object_path, |
191 const std::string& interface_name) OVERRIDE { | 192 const std::string& interface_name) OVERRIDE { |
192 FOR_EACH_OBSERVER(ExperimentalBluetoothAdapterClient::Observer, observers_, | 193 FOR_EACH_OBSERVER(ExperimentalBluetoothAdapterClient::Observer, |
| 194 observers_, |
193 AdapterAdded(object_path)); | 195 AdapterAdded(object_path)); |
194 } | 196 } |
195 | 197 |
196 // Called by dbus::ObjectManager when an object with the adapter interface | 198 // Called by dbus::ObjectManager when an object with the adapter interface |
197 // is removed. Informs observers. | 199 // is removed. Informs observers. |
198 void ObjectRemoved(const dbus::ObjectPath& object_path, | 200 virtual void ObjectRemoved(const dbus::ObjectPath& object_path, |
199 const std::string& interface_name) OVERRIDE { | 201 const std::string& interface_name) OVERRIDE { |
200 FOR_EACH_OBSERVER(ExperimentalBluetoothAdapterClient::Observer, observers_, | 202 FOR_EACH_OBSERVER(ExperimentalBluetoothAdapterClient::Observer, |
| 203 observers_, |
201 AdapterRemoved(object_path)); | 204 AdapterRemoved(object_path)); |
202 } | 205 } |
203 | 206 |
204 // Called by dbus::PropertySet when a property value is changed, | 207 // Called by dbus::PropertySet when a property value is changed, |
205 // either by result of a signal or response to a GetAll() or Get() | 208 // either by result of a signal or response to a GetAll() or Get() |
206 // call. Informs observers. | 209 // call. Informs observers. |
207 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 210 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
208 const std::string& property_name) { | 211 const std::string& property_name) { |
209 FOR_EACH_OBSERVER(ExperimentalBluetoothAdapterClient::Observer, observers_, | 212 FOR_EACH_OBSERVER(ExperimentalBluetoothAdapterClient::Observer, observers_, |
210 AdapterPropertyChanged(object_path, property_name)); | 213 AdapterPropertyChanged(object_path, property_name)); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 ExperimentalBluetoothAdapterClient* ExperimentalBluetoothAdapterClient::Create( | 262 ExperimentalBluetoothAdapterClient* ExperimentalBluetoothAdapterClient::Create( |
260 DBusClientImplementationType type, | 263 DBusClientImplementationType type, |
261 dbus::Bus* bus) { | 264 dbus::Bus* bus) { |
262 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 265 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
263 return new ExperimentalBluetoothAdapterClientImpl(bus); | 266 return new ExperimentalBluetoothAdapterClientImpl(bus); |
264 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 267 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
265 return new FakeBluetoothAdapterClient(); | 268 return new FakeBluetoothAdapterClient(); |
266 } | 269 } |
267 | 270 |
268 } // namespace chromeos | 271 } // namespace chromeos |
OLD | NEW |