| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "device/bluetooth/dbus/bluetooth_media_transport_client.h" | 5 #include "device/bluetooth/dbus/bluetooth_media_transport_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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 Properties* properties = new Properties( | 85 Properties* properties = new Properties( |
| 86 object_proxy, interface_name, | 86 object_proxy, interface_name, |
| 87 base::Bind(&BluetoothMediaTransportClientImpl::OnPropertyChanged, | 87 base::Bind(&BluetoothMediaTransportClientImpl::OnPropertyChanged, |
| 88 weak_ptr_factory_.GetWeakPtr(), object_path)); | 88 weak_ptr_factory_.GetWeakPtr(), object_path)); |
| 89 return properties; | 89 return properties; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void ObjectAdded(const dbus::ObjectPath& object_path, | 92 void ObjectAdded(const dbus::ObjectPath& object_path, |
| 93 const std::string& interface_name) override { | 93 const std::string& interface_name) override { |
| 94 VLOG(1) << "Remote Media Transport added: " << object_path.value(); | 94 VLOG(1) << "Remote Media Transport added: " << object_path.value(); |
| 95 FOR_EACH_OBSERVER(BluetoothMediaTransportClient::Observer, observers_, | 95 for (auto& observer : observers_) |
| 96 MediaTransportAdded(object_path)); | 96 observer.MediaTransportAdded(object_path); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void ObjectRemoved(const dbus::ObjectPath& object_path, | 99 void ObjectRemoved(const dbus::ObjectPath& object_path, |
| 100 const std::string& interface_name) override { | 100 const std::string& interface_name) override { |
| 101 VLOG(1) << "Remote Media Transport removed: " << object_path.value(); | 101 VLOG(1) << "Remote Media Transport removed: " << object_path.value(); |
| 102 FOR_EACH_OBSERVER(BluetoothMediaTransportClient::Observer, observers_, | 102 for (auto& observer : observers_) |
| 103 MediaTransportRemoved(object_path)); | 103 observer.MediaTransportRemoved(object_path); |
| 104 } | 104 } |
| 105 | 105 |
| 106 // BluetoothMediaTransportClient overrides. | 106 // BluetoothMediaTransportClient overrides. |
| 107 | 107 |
| 108 void AddObserver(BluetoothMediaTransportClient::Observer* observer) override { | 108 void AddObserver(BluetoothMediaTransportClient::Observer* observer) override { |
| 109 DCHECK(observer); | 109 DCHECK(observer); |
| 110 observers_.AddObserver(observer); | 110 observers_.AddObserver(observer); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void RemoveObserver( | 113 void RemoveObserver( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 object_manager_->RegisterInterface(kBluetoothMediaTransportInterface, this); | 199 object_manager_->RegisterInterface(kBluetoothMediaTransportInterface, this); |
| 200 } | 200 } |
| 201 | 201 |
| 202 private: | 202 private: |
| 203 // Called by dbus::PropertySet when a property value is changed. | 203 // Called by dbus::PropertySet when a property value is changed. |
| 204 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 204 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
| 205 const std::string& property_name) { | 205 const std::string& property_name) { |
| 206 VLOG(1) << "Name of the changed property: " << property_name; | 206 VLOG(1) << "Name of the changed property: " << property_name; |
| 207 | 207 |
| 208 // Dispatches the change to the corresponding property-changed handler. | 208 // Dispatches the change to the corresponding property-changed handler. |
| 209 FOR_EACH_OBSERVER( | 209 for (auto& observer : observers_) |
| 210 BluetoothMediaTransportClient::Observer, observers_, | 210 observer.MediaTransportPropertyChanged(object_path, property_name); |
| 211 MediaTransportPropertyChanged(object_path, property_name)); | |
| 212 } | 211 } |
| 213 | 212 |
| 214 // Called when a response for successful method call is received. | 213 // Called when a response for successful method call is received. |
| 215 void OnSuccess(const base::Closure& callback, dbus::Response* response) { | 214 void OnSuccess(const base::Closure& callback, dbus::Response* response) { |
| 216 DCHECK(response); | 215 DCHECK(response); |
| 217 callback.Run(); | 216 callback.Run(); |
| 218 } | 217 } |
| 219 | 218 |
| 220 // Called when a response for |Acquire|/|TryAcquire| method call is received. | 219 // Called when a response for |Acquire|/|TryAcquire| method call is received. |
| 221 void OnAcquireSuccess(const AcquireCallback& callback, | 220 void OnAcquireSuccess(const AcquireCallback& callback, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 276 |
| 278 BluetoothMediaTransportClient::BluetoothMediaTransportClient() {} | 277 BluetoothMediaTransportClient::BluetoothMediaTransportClient() {} |
| 279 | 278 |
| 280 BluetoothMediaTransportClient::~BluetoothMediaTransportClient() {} | 279 BluetoothMediaTransportClient::~BluetoothMediaTransportClient() {} |
| 281 | 280 |
| 282 BluetoothMediaTransportClient* BluetoothMediaTransportClient::Create() { | 281 BluetoothMediaTransportClient* BluetoothMediaTransportClient::Create() { |
| 283 return new BluetoothMediaTransportClientImpl(); | 282 return new BluetoothMediaTransportClientImpl(); |
| 284 } | 283 } |
| 285 | 284 |
| 286 } // namespace bluez | 285 } // namespace bluez |
| OLD | NEW |