Chromium Code Reviews| Index: chromeos/dbus/shill_client_helper.cc |
| diff --git a/chromeos/dbus/shill_client_helper.cc b/chromeos/dbus/shill_client_helper.cc |
| index c83bfe0b9d3530f1c9f859eeba37beb225e625d7..d9a491287d37a641473a9f635827d026f3d60510 100644 |
| --- a/chromeos/dbus/shill_client_helper.cc |
| +++ b/chromeos/dbus/shill_client_helper.cc |
| @@ -35,6 +35,13 @@ ShillClientHelper::~ShillClientHelper() { |
| void ShillClientHelper::AddPropertyChangedObserver( |
| ShillPropertyChangedObserver* observer) { |
| + // Excecutes all the pending MonitorPropertyChanged calls. |
| + for (std::vector<std::string>::iterator it = monitored_interfaces_.begin(); |
| + it != monitored_interfaces_.end(); ++it) { |
| + MonitorPropertyChangedInternal(*it); |
| + } |
| + monitored_interfaces_.clear(); |
| + |
| observer_list_.AddObserver(observer); |
| } |
| @@ -45,6 +52,16 @@ void ShillClientHelper::RemovePropertyChangedObserver( |
| void ShillClientHelper::MonitorPropertyChanged( |
| const std::string& interface_name) { |
| + if (observer_list_.size() > 0) |
|
hashimoto
2013/02/13 04:01:31
nit: if-statement without curly braces are not all
deymo
2013/02/13 05:41:07
Done.
|
| + // Effectively monitor the PropertyChanged now. |
| + MonitorPropertyChangedInternal(interface_name); |
| + else |
| + // Delay the ConnectToSignal until an observer is added. |
| + monitored_interfaces_.push_back(interface_name); |
| +} |
| + |
| +void ShillClientHelper::MonitorPropertyChangedInternal( |
| + const std::string& interface_name) { |
| // We are not using dbus::PropertySet to monitor PropertyChanged signal |
| // because the interface is not "org.freedesktop.DBus.Properties". |
| proxy_->ConnectToSignal(interface_name, |