| 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_input_client.h" | 5 #include "chromeos/dbus/experimental_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/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 virtual void RemoveObserver( | 62 virtual void RemoveObserver( |
| 63 ExperimentalBluetoothInputClient::Observer* observer) OVERRIDE { | 63 ExperimentalBluetoothInputClient::Observer* observer) OVERRIDE { |
| 64 DCHECK(observer); | 64 DCHECK(observer); |
| 65 observers_.RemoveObserver(observer); | 65 observers_.RemoveObserver(observer); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // dbus::ObjectManager::Interface override. | 68 // dbus::ObjectManager::Interface override. |
| 69 virtual dbus::PropertySet* CreateProperties( | 69 virtual dbus::PropertySet* CreateProperties( |
| 70 dbus::ObjectProxy* object_proxy, | 70 dbus::ObjectProxy* object_proxy, |
| 71 const dbus::ObjectPath& object_path, | 71 const dbus::ObjectPath& object_path, |
| 72 const std::string& interface_name) { | 72 const std::string& interface_name) OVERRIDE { |
| 73 Properties* properties = new Properties( | 73 Properties* properties = new Properties( |
| 74 object_proxy, interface_name, | 74 object_proxy, |
| 75 interface_name, |
| 75 base::Bind(&ExperimentalBluetoothInputClientImpl::OnPropertyChanged, | 76 base::Bind(&ExperimentalBluetoothInputClientImpl::OnPropertyChanged, |
| 76 weak_ptr_factory_.GetWeakPtr(), | 77 weak_ptr_factory_.GetWeakPtr(), |
| 77 object_path)); | 78 object_path)); |
| 78 return static_cast<dbus::PropertySet*>(properties); | 79 return static_cast<dbus::PropertySet*>(properties); |
| 79 } | 80 } |
| 80 | 81 |
| 81 // ExperimentalBluetoothInputClient override. | 82 // ExperimentalBluetoothInputClient override. |
| 82 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) | 83 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) |
| 83 OVERRIDE { | 84 OVERRIDE { |
| 84 return static_cast<Properties*>( | 85 return static_cast<Properties*>( |
| 85 object_manager_->GetProperties( | 86 object_manager_->GetProperties( |
| 86 object_path, | 87 object_path, |
| 87 bluetooth_input::kExperimentalBluetoothInputInterface)); | 88 bluetooth_input::kExperimentalBluetoothInputInterface)); |
| 88 } | 89 } |
| 89 | 90 |
| 90 private: | 91 private: |
| 91 // Called by dbus::ObjectManager when an object with the input interface | 92 // Called by dbus::ObjectManager when an object with the input interface |
| 92 // is created. Informs observers. | 93 // is created. Informs observers. |
| 93 void ObjectAdded(const dbus::ObjectPath& object_path, | 94 virtual void ObjectAdded(const dbus::ObjectPath& object_path, |
| 94 const std::string& interface_name) OVERRIDE { | 95 const std::string& interface_name) OVERRIDE { |
| 95 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_, | 96 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_, |
| 96 InputAdded(object_path)); | 97 InputAdded(object_path)); |
| 97 } | 98 } |
| 98 | 99 |
| 99 // Called by dbus::ObjectManager when an object with the input interface | 100 // Called by dbus::ObjectManager when an object with the input interface |
| 100 // is removed. Informs observers. | 101 // is removed. Informs observers. |
| 101 void ObjectRemoved(const dbus::ObjectPath& object_path, | 102 virtual void ObjectRemoved(const dbus::ObjectPath& object_path, |
| 102 const std::string& interface_name) OVERRIDE { | 103 const std::string& interface_name) OVERRIDE { |
| 103 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_, | 104 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_, |
| 104 InputRemoved(object_path)); | 105 InputRemoved(object_path)); |
| 105 } | 106 } |
| 106 | 107 |
| 107 // Called by BluetoothPropertySet when a property value is changed, | 108 // Called by BluetoothPropertySet when a property value is changed, |
| 108 // either by result of a signal or response to a GetAll() or Get() | 109 // either by result of a signal or response to a GetAll() or Get() |
| 109 // call. Informs observers. | 110 // call. Informs observers. |
| 110 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 111 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
| 111 const std::string& property_name) { | 112 const std::string& property_name) { |
| 112 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_, | 113 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 137 ExperimentalBluetoothInputClient* ExperimentalBluetoothInputClient::Create( | 138 ExperimentalBluetoothInputClient* ExperimentalBluetoothInputClient::Create( |
| 138 DBusClientImplementationType type, | 139 DBusClientImplementationType type, |
| 139 dbus::Bus* bus) { | 140 dbus::Bus* bus) { |
| 140 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 141 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 141 return new ExperimentalBluetoothInputClientImpl(bus); | 142 return new ExperimentalBluetoothInputClientImpl(bus); |
| 142 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 143 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 143 return new FakeBluetoothInputClient(); | 144 return new FakeBluetoothInputClient(); |
| 144 } | 145 } |
| 145 | 146 |
| 146 } // namespace chromeos | 147 } // namespace chromeos |
| OLD | NEW |