Index: chromeos/dbus/shill_device_client.cc |
diff --git a/chromeos/dbus/shill_device_client.cc b/chromeos/dbus/shill_device_client.cc |
index 39ca916bebb16c1d2713e5300ae9ce930dadf04c..1f4e7a47dadc39e4245099ca1df943ead49be35c 100644 |
--- a/chromeos/dbus/shill_device_client.cc |
+++ b/chromeos/dbus/shill_device_client.cc |
@@ -232,11 +232,15 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, |
virtual void AddPropertyChangedObserver( |
const dbus::ObjectPath& device_path, |
- ShillPropertyChangedObserver* observer) OVERRIDE {} |
+ ShillPropertyChangedObserver* observer) OVERRIDE { |
+ observer_list_.AddObserver(observer); |
hashimoto
2012/11/05 04:03:03
You might need to change the type of observer_list
stevenjb
2012/11/05 22:42:35
Good catch, fixed.
|
+ } |
virtual void RemovePropertyChangedObserver( |
const dbus::ObjectPath& device_path, |
- ShillPropertyChangedObserver* observer) OVERRIDE {} |
+ ShillPropertyChangedObserver* observer) OVERRIDE { |
+ observer_list_.RemoveObserver(observer); |
+ } |
virtual void GetProperties(const dbus::ObjectPath& device_path, |
const DictionaryValueCallback& callback) OVERRIDE { |
@@ -277,6 +281,10 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, |
} |
device_properties->Set(name, value.DeepCopy()); |
MessageLoop::current()->PostTask(FROM_HERE, callback); |
+ MessageLoop::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&ShillDeviceClientStubImpl::NotifyObserversPropertyChanged, |
+ weak_ptr_factory_.GetWeakPtr(), device_path, name)); |
} |
virtual void ClearProperty(const dbus::ObjectPath& device_path, |
@@ -413,6 +421,25 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, |
base::Bind(callback, status)); |
} |
+ void NotifyObserversPropertyChanged(const dbus::ObjectPath& device_path, |
+ const std::string& property) { |
+ base::DictionaryValue* dict = NULL; |
+ std::string path = device_path.value(); |
+ if (!stub_devices_.GetDictionaryWithoutPathExpansion(path, &dict)) { |
+ LOG(ERROR) << "Notify for unknown service: " << path; |
+ return; |
+ } |
+ base::Value* value = NULL; |
+ if (!dict->GetWithoutPathExpansion(property, &value)) { |
+ LOG(ERROR) << "Notify for unknown property: " |
+ << path << " : " << property; |
+ return; |
+ } |
+ FOR_EACH_OBSERVER(ShillPropertyChangedObserver, |
+ observer_list_, |
+ OnPropertyChanged(property, *value)); |
+ } |
+ |
base::DictionaryValue* GetDeviceProperties(const std::string& device_path) { |
base::DictionaryValue* properties = NULL; |
if (!stub_devices_.GetDictionaryWithoutPathExpansion( |
@@ -425,6 +452,7 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, |
// Dictionary of <device_name, Dictionary>. |
base::DictionaryValue stub_devices_; |
+ ObserverList<ShillPropertyChangedObserver> observer_list_; |
// Note: This should remain the last member so it'll be destroyed and |
// invalidate its weak pointers before any other members are destroyed. |