Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: chromeos/dbus/shill_device_client.cc

Issue 11192024: Add chromeos::NetworkStateManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase with dbus tests in trunk Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698