| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/bluetooth_device_client.h" | 5 #include "chromeos/dbus/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 "dbus/bus.h" | 10 #include "dbus/bus.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 BluetoothDeviceClientImpl() | 59 BluetoothDeviceClientImpl() |
| 60 : object_manager_(NULL), weak_ptr_factory_(this) {} | 60 : object_manager_(NULL), weak_ptr_factory_(this) {} |
| 61 | 61 |
| 62 virtual ~BluetoothDeviceClientImpl() { | 62 virtual ~BluetoothDeviceClientImpl() { |
| 63 object_manager_->UnregisterInterface( | 63 object_manager_->UnregisterInterface( |
| 64 bluetooth_device::kBluetoothDeviceInterface); | 64 bluetooth_device::kBluetoothDeviceInterface); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // BluetoothDeviceClient override. | 67 // BluetoothDeviceClient override. |
| 68 virtual void AddObserver(BluetoothDeviceClient::Observer* observer) | 68 virtual void AddObserver(BluetoothDeviceClient::Observer* observer) |
| 69 OVERRIDE { | 69 override { |
| 70 DCHECK(observer); | 70 DCHECK(observer); |
| 71 observers_.AddObserver(observer); | 71 observers_.AddObserver(observer); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // BluetoothDeviceClient override. | 74 // BluetoothDeviceClient override. |
| 75 virtual void RemoveObserver(BluetoothDeviceClient::Observer* observer) | 75 virtual void RemoveObserver(BluetoothDeviceClient::Observer* observer) |
| 76 OVERRIDE { | 76 override { |
| 77 DCHECK(observer); | 77 DCHECK(observer); |
| 78 observers_.RemoveObserver(observer); | 78 observers_.RemoveObserver(observer); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // dbus::ObjectManager::Interface override. | 81 // dbus::ObjectManager::Interface override. |
| 82 virtual dbus::PropertySet* CreateProperties( | 82 virtual dbus::PropertySet* CreateProperties( |
| 83 dbus::ObjectProxy* object_proxy, | 83 dbus::ObjectProxy* object_proxy, |
| 84 const dbus::ObjectPath& object_path, | 84 const dbus::ObjectPath& object_path, |
| 85 const std::string& interface_name) OVERRIDE { | 85 const std::string& interface_name) override { |
| 86 Properties* properties = new Properties( | 86 Properties* properties = new Properties( |
| 87 object_proxy, | 87 object_proxy, |
| 88 interface_name, | 88 interface_name, |
| 89 base::Bind(&BluetoothDeviceClientImpl::OnPropertyChanged, | 89 base::Bind(&BluetoothDeviceClientImpl::OnPropertyChanged, |
| 90 weak_ptr_factory_.GetWeakPtr(), | 90 weak_ptr_factory_.GetWeakPtr(), |
| 91 object_path)); | 91 object_path)); |
| 92 return static_cast<dbus::PropertySet*>(properties); | 92 return static_cast<dbus::PropertySet*>(properties); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // BluetoothDeviceClient override. | 95 // BluetoothDeviceClient override. |
| 96 virtual std::vector<dbus::ObjectPath> GetDevicesForAdapter( | 96 virtual std::vector<dbus::ObjectPath> GetDevicesForAdapter( |
| 97 const dbus::ObjectPath& adapter_path) OVERRIDE { | 97 const dbus::ObjectPath& adapter_path) override { |
| 98 std::vector<dbus::ObjectPath> object_paths, device_paths; | 98 std::vector<dbus::ObjectPath> object_paths, device_paths; |
| 99 device_paths = object_manager_->GetObjectsWithInterface( | 99 device_paths = object_manager_->GetObjectsWithInterface( |
| 100 bluetooth_device::kBluetoothDeviceInterface); | 100 bluetooth_device::kBluetoothDeviceInterface); |
| 101 for (std::vector<dbus::ObjectPath>::iterator iter = device_paths.begin(); | 101 for (std::vector<dbus::ObjectPath>::iterator iter = device_paths.begin(); |
| 102 iter != device_paths.end(); ++iter) { | 102 iter != device_paths.end(); ++iter) { |
| 103 Properties* properties = GetProperties(*iter); | 103 Properties* properties = GetProperties(*iter); |
| 104 if (properties->adapter.value() == adapter_path) | 104 if (properties->adapter.value() == adapter_path) |
| 105 object_paths.push_back(*iter); | 105 object_paths.push_back(*iter); |
| 106 } | 106 } |
| 107 return object_paths; | 107 return object_paths; |
| 108 } | 108 } |
| 109 | 109 |
| 110 // BluetoothDeviceClient override. | 110 // BluetoothDeviceClient override. |
| 111 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) | 111 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) |
| 112 OVERRIDE { | 112 override { |
| 113 return static_cast<Properties*>( | 113 return static_cast<Properties*>( |
| 114 object_manager_->GetProperties( | 114 object_manager_->GetProperties( |
| 115 object_path, | 115 object_path, |
| 116 bluetooth_device::kBluetoothDeviceInterface)); | 116 bluetooth_device::kBluetoothDeviceInterface)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // BluetoothDeviceClient override. | 119 // BluetoothDeviceClient override. |
| 120 virtual void Connect(const dbus::ObjectPath& object_path, | 120 virtual void Connect(const dbus::ObjectPath& object_path, |
| 121 const base::Closure& callback, | 121 const base::Closure& callback, |
| 122 const ErrorCallback& error_callback) OVERRIDE { | 122 const ErrorCallback& error_callback) override { |
| 123 dbus::MethodCall method_call( | 123 dbus::MethodCall method_call( |
| 124 bluetooth_device::kBluetoothDeviceInterface, | 124 bluetooth_device::kBluetoothDeviceInterface, |
| 125 bluetooth_device::kConnect); | 125 bluetooth_device::kConnect); |
| 126 | 126 |
| 127 dbus::ObjectProxy* object_proxy = | 127 dbus::ObjectProxy* object_proxy = |
| 128 object_manager_->GetObjectProxy(object_path); | 128 object_manager_->GetObjectProxy(object_path); |
| 129 if (!object_proxy) { | 129 if (!object_proxy) { |
| 130 error_callback.Run(kUnknownDeviceError, ""); | 130 error_callback.Run(kUnknownDeviceError, ""); |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Connect may take an arbitrary length of time, so use no timeout. | 134 // Connect may take an arbitrary length of time, so use no timeout. |
| 135 object_proxy->CallMethodWithErrorCallback( | 135 object_proxy->CallMethodWithErrorCallback( |
| 136 &method_call, | 136 &method_call, |
| 137 dbus::ObjectProxy::TIMEOUT_INFINITE, | 137 dbus::ObjectProxy::TIMEOUT_INFINITE, |
| 138 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, | 138 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, |
| 139 weak_ptr_factory_.GetWeakPtr(), callback), | 139 weak_ptr_factory_.GetWeakPtr(), callback), |
| 140 base::Bind(&BluetoothDeviceClientImpl::OnError, | 140 base::Bind(&BluetoothDeviceClientImpl::OnError, |
| 141 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 141 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // BluetoothDeviceClient override. | 144 // BluetoothDeviceClient override. |
| 145 virtual void Disconnect(const dbus::ObjectPath& object_path, | 145 virtual void Disconnect(const dbus::ObjectPath& object_path, |
| 146 const base::Closure& callback, | 146 const base::Closure& callback, |
| 147 const ErrorCallback& error_callback) OVERRIDE { | 147 const ErrorCallback& error_callback) override { |
| 148 dbus::MethodCall method_call( | 148 dbus::MethodCall method_call( |
| 149 bluetooth_device::kBluetoothDeviceInterface, | 149 bluetooth_device::kBluetoothDeviceInterface, |
| 150 bluetooth_device::kDisconnect); | 150 bluetooth_device::kDisconnect); |
| 151 | 151 |
| 152 dbus::ObjectProxy* object_proxy = | 152 dbus::ObjectProxy* object_proxy = |
| 153 object_manager_->GetObjectProxy(object_path); | 153 object_manager_->GetObjectProxy(object_path); |
| 154 if (!object_proxy) { | 154 if (!object_proxy) { |
| 155 error_callback.Run(kUnknownDeviceError, ""); | 155 error_callback.Run(kUnknownDeviceError, ""); |
| 156 return; | 156 return; |
| 157 } | 157 } |
| 158 | 158 |
| 159 object_proxy->CallMethodWithErrorCallback( | 159 object_proxy->CallMethodWithErrorCallback( |
| 160 &method_call, | 160 &method_call, |
| 161 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 161 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 162 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, | 162 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, |
| 163 weak_ptr_factory_.GetWeakPtr(), callback), | 163 weak_ptr_factory_.GetWeakPtr(), callback), |
| 164 base::Bind(&BluetoothDeviceClientImpl::OnError, | 164 base::Bind(&BluetoothDeviceClientImpl::OnError, |
| 165 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 165 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 166 } | 166 } |
| 167 | 167 |
| 168 // BluetoothDeviceClient override. | 168 // BluetoothDeviceClient override. |
| 169 virtual void ConnectProfile(const dbus::ObjectPath& object_path, | 169 virtual void ConnectProfile(const dbus::ObjectPath& object_path, |
| 170 const std::string& uuid, | 170 const std::string& uuid, |
| 171 const base::Closure& callback, | 171 const base::Closure& callback, |
| 172 const ErrorCallback& error_callback) OVERRIDE { | 172 const ErrorCallback& error_callback) override { |
| 173 dbus::MethodCall method_call( | 173 dbus::MethodCall method_call( |
| 174 bluetooth_device::kBluetoothDeviceInterface, | 174 bluetooth_device::kBluetoothDeviceInterface, |
| 175 bluetooth_device::kConnectProfile); | 175 bluetooth_device::kConnectProfile); |
| 176 | 176 |
| 177 dbus::MessageWriter writer(&method_call); | 177 dbus::MessageWriter writer(&method_call); |
| 178 writer.AppendString(uuid); | 178 writer.AppendString(uuid); |
| 179 | 179 |
| 180 dbus::ObjectProxy* object_proxy = | 180 dbus::ObjectProxy* object_proxy = |
| 181 object_manager_->GetObjectProxy(object_path); | 181 object_manager_->GetObjectProxy(object_path); |
| 182 if (!object_proxy) { | 182 if (!object_proxy) { |
| 183 error_callback.Run(kUnknownDeviceError, ""); | 183 error_callback.Run(kUnknownDeviceError, ""); |
| 184 return; | 184 return; |
| 185 } | 185 } |
| 186 | 186 |
| 187 // Connect may take an arbitrary length of time, so use no timeout. | 187 // Connect may take an arbitrary length of time, so use no timeout. |
| 188 object_proxy->CallMethodWithErrorCallback( | 188 object_proxy->CallMethodWithErrorCallback( |
| 189 &method_call, | 189 &method_call, |
| 190 dbus::ObjectProxy::TIMEOUT_INFINITE, | 190 dbus::ObjectProxy::TIMEOUT_INFINITE, |
| 191 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, | 191 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, |
| 192 weak_ptr_factory_.GetWeakPtr(), callback), | 192 weak_ptr_factory_.GetWeakPtr(), callback), |
| 193 base::Bind(&BluetoothDeviceClientImpl::OnError, | 193 base::Bind(&BluetoothDeviceClientImpl::OnError, |
| 194 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 194 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 195 } | 195 } |
| 196 | 196 |
| 197 // BluetoothDeviceClient override. | 197 // BluetoothDeviceClient override. |
| 198 virtual void DisconnectProfile(const dbus::ObjectPath& object_path, | 198 virtual void DisconnectProfile(const dbus::ObjectPath& object_path, |
| 199 const std::string& uuid, | 199 const std::string& uuid, |
| 200 const base::Closure& callback, | 200 const base::Closure& callback, |
| 201 const ErrorCallback& error_callback) | 201 const ErrorCallback& error_callback) |
| 202 OVERRIDE { | 202 override { |
| 203 dbus::MethodCall method_call( | 203 dbus::MethodCall method_call( |
| 204 bluetooth_device::kBluetoothDeviceInterface, | 204 bluetooth_device::kBluetoothDeviceInterface, |
| 205 bluetooth_device::kDisconnectProfile); | 205 bluetooth_device::kDisconnectProfile); |
| 206 | 206 |
| 207 dbus::MessageWriter writer(&method_call); | 207 dbus::MessageWriter writer(&method_call); |
| 208 writer.AppendString(uuid); | 208 writer.AppendString(uuid); |
| 209 | 209 |
| 210 dbus::ObjectProxy* object_proxy = | 210 dbus::ObjectProxy* object_proxy = |
| 211 object_manager_->GetObjectProxy(object_path); | 211 object_manager_->GetObjectProxy(object_path); |
| 212 if (!object_proxy) { | 212 if (!object_proxy) { |
| 213 error_callback.Run(kUnknownDeviceError, ""); | 213 error_callback.Run(kUnknownDeviceError, ""); |
| 214 return; | 214 return; |
| 215 } | 215 } |
| 216 | 216 |
| 217 object_proxy->CallMethodWithErrorCallback( | 217 object_proxy->CallMethodWithErrorCallback( |
| 218 &method_call, | 218 &method_call, |
| 219 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 219 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 220 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, | 220 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, |
| 221 weak_ptr_factory_.GetWeakPtr(), callback), | 221 weak_ptr_factory_.GetWeakPtr(), callback), |
| 222 base::Bind(&BluetoothDeviceClientImpl::OnError, | 222 base::Bind(&BluetoothDeviceClientImpl::OnError, |
| 223 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 223 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 224 } | 224 } |
| 225 | 225 |
| 226 // BluetoothDeviceClient override. | 226 // BluetoothDeviceClient override. |
| 227 virtual void Pair(const dbus::ObjectPath& object_path, | 227 virtual void Pair(const dbus::ObjectPath& object_path, |
| 228 const base::Closure& callback, | 228 const base::Closure& callback, |
| 229 const ErrorCallback& error_callback) OVERRIDE { | 229 const ErrorCallback& error_callback) override { |
| 230 dbus::MethodCall method_call( | 230 dbus::MethodCall method_call( |
| 231 bluetooth_device::kBluetoothDeviceInterface, | 231 bluetooth_device::kBluetoothDeviceInterface, |
| 232 bluetooth_device::kPair); | 232 bluetooth_device::kPair); |
| 233 | 233 |
| 234 dbus::ObjectProxy* object_proxy = | 234 dbus::ObjectProxy* object_proxy = |
| 235 object_manager_->GetObjectProxy(object_path); | 235 object_manager_->GetObjectProxy(object_path); |
| 236 if (!object_proxy) { | 236 if (!object_proxy) { |
| 237 error_callback.Run(kUnknownDeviceError, ""); | 237 error_callback.Run(kUnknownDeviceError, ""); |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 | 240 |
| 241 // Pairing may take an arbitrary length of time, so use no timeout. | 241 // Pairing may take an arbitrary length of time, so use no timeout. |
| 242 object_proxy->CallMethodWithErrorCallback( | 242 object_proxy->CallMethodWithErrorCallback( |
| 243 &method_call, | 243 &method_call, |
| 244 dbus::ObjectProxy::TIMEOUT_INFINITE, | 244 dbus::ObjectProxy::TIMEOUT_INFINITE, |
| 245 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, | 245 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, |
| 246 weak_ptr_factory_.GetWeakPtr(), callback), | 246 weak_ptr_factory_.GetWeakPtr(), callback), |
| 247 base::Bind(&BluetoothDeviceClientImpl::OnError, | 247 base::Bind(&BluetoothDeviceClientImpl::OnError, |
| 248 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 248 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 249 } | 249 } |
| 250 | 250 |
| 251 // BluetoothDeviceClient override. | 251 // BluetoothDeviceClient override. |
| 252 virtual void CancelPairing(const dbus::ObjectPath& object_path, | 252 virtual void CancelPairing(const dbus::ObjectPath& object_path, |
| 253 const base::Closure& callback, | 253 const base::Closure& callback, |
| 254 const ErrorCallback& error_callback) | 254 const ErrorCallback& error_callback) |
| 255 OVERRIDE { | 255 override { |
| 256 dbus::MethodCall method_call( | 256 dbus::MethodCall method_call( |
| 257 bluetooth_device::kBluetoothDeviceInterface, | 257 bluetooth_device::kBluetoothDeviceInterface, |
| 258 bluetooth_device::kCancelPairing); | 258 bluetooth_device::kCancelPairing); |
| 259 | 259 |
| 260 dbus::ObjectProxy* object_proxy = | 260 dbus::ObjectProxy* object_proxy = |
| 261 object_manager_->GetObjectProxy(object_path); | 261 object_manager_->GetObjectProxy(object_path); |
| 262 if (!object_proxy) { | 262 if (!object_proxy) { |
| 263 error_callback.Run(kUnknownDeviceError, ""); | 263 error_callback.Run(kUnknownDeviceError, ""); |
| 264 return; | 264 return; |
| 265 } | 265 } |
| 266 object_proxy->CallMethodWithErrorCallback( | 266 object_proxy->CallMethodWithErrorCallback( |
| 267 &method_call, | 267 &method_call, |
| 268 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 268 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 269 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, | 269 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, |
| 270 weak_ptr_factory_.GetWeakPtr(), callback), | 270 weak_ptr_factory_.GetWeakPtr(), callback), |
| 271 base::Bind(&BluetoothDeviceClientImpl::OnError, | 271 base::Bind(&BluetoothDeviceClientImpl::OnError, |
| 272 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 272 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 // BluetoothDeviceClient override. | 275 // BluetoothDeviceClient override. |
| 276 virtual void StartConnectionMonitor( | 276 virtual void StartConnectionMonitor( |
| 277 const dbus::ObjectPath& object_path, | 277 const dbus::ObjectPath& object_path, |
| 278 const base::Closure& callback, | 278 const base::Closure& callback, |
| 279 const ErrorCallback& error_callback) OVERRIDE { | 279 const ErrorCallback& error_callback) override { |
| 280 dbus::MethodCall method_call(bluetooth_device::kBluetoothDeviceInterface, | 280 dbus::MethodCall method_call(bluetooth_device::kBluetoothDeviceInterface, |
| 281 bluetooth_device::kStartConnectionMonitor); | 281 bluetooth_device::kStartConnectionMonitor); |
| 282 | 282 |
| 283 dbus::ObjectProxy* object_proxy = | 283 dbus::ObjectProxy* object_proxy = |
| 284 object_manager_->GetObjectProxy(object_path); | 284 object_manager_->GetObjectProxy(object_path); |
| 285 if (!object_proxy) { | 285 if (!object_proxy) { |
| 286 error_callback.Run(kUnknownDeviceError, ""); | 286 error_callback.Run(kUnknownDeviceError, ""); |
| 287 return; | 287 return; |
| 288 } | 288 } |
| 289 object_proxy->CallMethodWithErrorCallback( | 289 object_proxy->CallMethodWithErrorCallback( |
| 290 &method_call, | 290 &method_call, |
| 291 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 291 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 292 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, | 292 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, |
| 293 weak_ptr_factory_.GetWeakPtr(), | 293 weak_ptr_factory_.GetWeakPtr(), |
| 294 callback), | 294 callback), |
| 295 base::Bind(&BluetoothDeviceClientImpl::OnError, | 295 base::Bind(&BluetoothDeviceClientImpl::OnError, |
| 296 weak_ptr_factory_.GetWeakPtr(), | 296 weak_ptr_factory_.GetWeakPtr(), |
| 297 error_callback)); | 297 error_callback)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 // BluetoothDeviceClient override. | 300 // BluetoothDeviceClient override. |
| 301 virtual void StopConnectionMonitor( | 301 virtual void StopConnectionMonitor( |
| 302 const dbus::ObjectPath& object_path, | 302 const dbus::ObjectPath& object_path, |
| 303 const base::Closure& callback, | 303 const base::Closure& callback, |
| 304 const ErrorCallback& error_callback) OVERRIDE { | 304 const ErrorCallback& error_callback) override { |
| 305 dbus::MethodCall method_call(bluetooth_device::kBluetoothDeviceInterface, | 305 dbus::MethodCall method_call(bluetooth_device::kBluetoothDeviceInterface, |
| 306 bluetooth_device::kStopConnectionMonitor); | 306 bluetooth_device::kStopConnectionMonitor); |
| 307 | 307 |
| 308 dbus::ObjectProxy* object_proxy = | 308 dbus::ObjectProxy* object_proxy = |
| 309 object_manager_->GetObjectProxy(object_path); | 309 object_manager_->GetObjectProxy(object_path); |
| 310 if (!object_proxy) { | 310 if (!object_proxy) { |
| 311 error_callback.Run(kUnknownDeviceError, ""); | 311 error_callback.Run(kUnknownDeviceError, ""); |
| 312 return; | 312 return; |
| 313 } | 313 } |
| 314 object_proxy->CallMethodWithErrorCallback( | 314 object_proxy->CallMethodWithErrorCallback( |
| 315 &method_call, | 315 &method_call, |
| 316 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 316 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 317 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, | 317 base::Bind(&BluetoothDeviceClientImpl::OnSuccess, |
| 318 weak_ptr_factory_.GetWeakPtr(), | 318 weak_ptr_factory_.GetWeakPtr(), |
| 319 callback), | 319 callback), |
| 320 base::Bind(&BluetoothDeviceClientImpl::OnError, | 320 base::Bind(&BluetoothDeviceClientImpl::OnError, |
| 321 weak_ptr_factory_.GetWeakPtr(), | 321 weak_ptr_factory_.GetWeakPtr(), |
| 322 error_callback)); | 322 error_callback)); |
| 323 } | 323 } |
| 324 | 324 |
| 325 protected: | 325 protected: |
| 326 virtual void Init(dbus::Bus* bus) OVERRIDE { | 326 virtual void Init(dbus::Bus* bus) override { |
| 327 object_manager_ = bus->GetObjectManager( | 327 object_manager_ = bus->GetObjectManager( |
| 328 bluetooth_object_manager::kBluetoothObjectManagerServiceName, | 328 bluetooth_object_manager::kBluetoothObjectManagerServiceName, |
| 329 dbus::ObjectPath( | 329 dbus::ObjectPath( |
| 330 bluetooth_object_manager::kBluetoothObjectManagerServicePath)); | 330 bluetooth_object_manager::kBluetoothObjectManagerServicePath)); |
| 331 object_manager_->RegisterInterface( | 331 object_manager_->RegisterInterface( |
| 332 bluetooth_device::kBluetoothDeviceInterface, this); | 332 bluetooth_device::kBluetoothDeviceInterface, this); |
| 333 } | 333 } |
| 334 | 334 |
| 335 private: | 335 private: |
| 336 // Called by dbus::ObjectManager when an object with the device interface | 336 // Called by dbus::ObjectManager when an object with the device interface |
| 337 // is created. Informs observers. | 337 // is created. Informs observers. |
| 338 virtual void ObjectAdded(const dbus::ObjectPath& object_path, | 338 virtual void ObjectAdded(const dbus::ObjectPath& object_path, |
| 339 const std::string& interface_name) OVERRIDE { | 339 const std::string& interface_name) override { |
| 340 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, | 340 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
| 341 DeviceAdded(object_path)); | 341 DeviceAdded(object_path)); |
| 342 } | 342 } |
| 343 | 343 |
| 344 // Called by dbus::ObjectManager when an object with the device interface | 344 // Called by dbus::ObjectManager when an object with the device interface |
| 345 // is removed. Informs observers. | 345 // is removed. Informs observers. |
| 346 virtual void ObjectRemoved(const dbus::ObjectPath& object_path, | 346 virtual void ObjectRemoved(const dbus::ObjectPath& object_path, |
| 347 const std::string& interface_name) OVERRIDE { | 347 const std::string& interface_name) override { |
| 348 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, | 348 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
| 349 DeviceRemoved(object_path)); | 349 DeviceRemoved(object_path)); |
| 350 } | 350 } |
| 351 | 351 |
| 352 // Called by BluetoothPropertySet when a property value is changed, | 352 // Called by BluetoothPropertySet when a property value is changed, |
| 353 // either by result of a signal or response to a GetAll() or Get() | 353 // either by result of a signal or response to a GetAll() or Get() |
| 354 // call. Informs observers. | 354 // call. Informs observers. |
| 355 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 355 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
| 356 const std::string& property_name) { | 356 const std::string& property_name) { |
| 357 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, | 357 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 400 } |
| 401 | 401 |
| 402 BluetoothDeviceClient::~BluetoothDeviceClient() { | 402 BluetoothDeviceClient::~BluetoothDeviceClient() { |
| 403 } | 403 } |
| 404 | 404 |
| 405 BluetoothDeviceClient* BluetoothDeviceClient::Create() { | 405 BluetoothDeviceClient* BluetoothDeviceClient::Create() { |
| 406 return new BluetoothDeviceClientImpl(); | 406 return new BluetoothDeviceClientImpl(); |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace chromeos | 409 } // namespace chromeos |
| OLD | NEW |