| 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 "device/bluetooth/dbus/bluetooth_input_client.h" | 5 #include "device/bluetooth/dbus/bluetooth_input_client.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 bluetooth_object_manager::kBluetoothObjectManagerServicePath)); | 76 bluetooth_object_manager::kBluetoothObjectManagerServicePath)); |
| 77 object_manager_->RegisterInterface( | 77 object_manager_->RegisterInterface( |
| 78 bluetooth_input::kBluetoothInputInterface, this); | 78 bluetooth_input::kBluetoothInputInterface, this); |
| 79 } | 79 } |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 // Called by dbus::ObjectManager when an object with the input interface | 82 // Called by dbus::ObjectManager when an object with the input interface |
| 83 // is created. Informs observers. | 83 // is created. Informs observers. |
| 84 void ObjectAdded(const dbus::ObjectPath& object_path, | 84 void ObjectAdded(const dbus::ObjectPath& object_path, |
| 85 const std::string& interface_name) override { | 85 const std::string& interface_name) override { |
| 86 FOR_EACH_OBSERVER(BluetoothInputClient::Observer, observers_, | 86 for (auto& observer : observers_) |
| 87 InputAdded(object_path)); | 87 observer.InputAdded(object_path); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Called by dbus::ObjectManager when an object with the input interface | 90 // Called by dbus::ObjectManager when an object with the input interface |
| 91 // is removed. Informs observers. | 91 // is removed. Informs observers. |
| 92 void ObjectRemoved(const dbus::ObjectPath& object_path, | 92 void ObjectRemoved(const dbus::ObjectPath& object_path, |
| 93 const std::string& interface_name) override { | 93 const std::string& interface_name) override { |
| 94 FOR_EACH_OBSERVER(BluetoothInputClient::Observer, observers_, | 94 for (auto& observer : observers_) |
| 95 InputRemoved(object_path)); | 95 observer.InputRemoved(object_path); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Called by BluetoothPropertySet when a property value is changed, | 98 // Called by BluetoothPropertySet when a property value is changed, |
| 99 // either by result of a signal or response to a GetAll() or Get() | 99 // either by result of a signal or response to a GetAll() or Get() |
| 100 // call. Informs observers. | 100 // call. Informs observers. |
| 101 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 101 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
| 102 const std::string& property_name) { | 102 const std::string& property_name) { |
| 103 FOR_EACH_OBSERVER(BluetoothInputClient::Observer, observers_, | 103 for (auto& observer : observers_) |
| 104 InputPropertyChanged(object_path, property_name)); | 104 observer.InputPropertyChanged(object_path, property_name); |
| 105 } | 105 } |
| 106 | 106 |
| 107 dbus::ObjectManager* object_manager_; | 107 dbus::ObjectManager* object_manager_; |
| 108 | 108 |
| 109 // List of observers interested in event notifications from us. | 109 // List of observers interested in event notifications from us. |
| 110 base::ObserverList<BluetoothInputClient::Observer> observers_; | 110 base::ObserverList<BluetoothInputClient::Observer> observers_; |
| 111 | 111 |
| 112 // Weak pointer factory for generating 'this' pointers that might live longer | 112 // Weak pointer factory for generating 'this' pointers that might live longer |
| 113 // than we do. | 113 // than we do. |
| 114 // Note: This should remain the last member so it'll be destroyed and | 114 // Note: This should remain the last member so it'll be destroyed and |
| 115 // invalidate its weak pointers before any other members are destroyed. | 115 // invalidate its weak pointers before any other members are destroyed. |
| 116 base::WeakPtrFactory<BluetoothInputClientImpl> weak_ptr_factory_; | 116 base::WeakPtrFactory<BluetoothInputClientImpl> weak_ptr_factory_; |
| 117 | 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(BluetoothInputClientImpl); | 118 DISALLOW_COPY_AND_ASSIGN(BluetoothInputClientImpl); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 BluetoothInputClient::BluetoothInputClient() {} | 121 BluetoothInputClient::BluetoothInputClient() {} |
| 122 | 122 |
| 123 BluetoothInputClient::~BluetoothInputClient() {} | 123 BluetoothInputClient::~BluetoothInputClient() {} |
| 124 | 124 |
| 125 BluetoothInputClient* BluetoothInputClient::Create() { | 125 BluetoothInputClient* BluetoothInputClient::Create() { |
| 126 return new BluetoothInputClientImpl(); | 126 return new BluetoothInputClientImpl(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace bluez | 129 } // namespace bluez |
| OLD | NEW |