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

Unified Diff: chromeos/dbus/shill_client_helper.cc

Issue 12220128: Shill: Delay the ConnectToSignal call until an observer is added. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: apply issues on try bots, patch rebased. Created 7 years, 10 months 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
« no previous file with comments | « chromeos/dbus/shill_client_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e7c6dc812ff14842feca67c1ffb0ef2beea5a541 100644
--- a/chromeos/dbus/shill_client_helper.cc
+++ b/chromeos/dbus/shill_client_helper.cc
@@ -35,6 +35,12 @@ ShillClientHelper::~ShillClientHelper() {
void ShillClientHelper::AddPropertyChangedObserver(
ShillPropertyChangedObserver* observer) {
+ // Excecute all the pending MonitorPropertyChanged calls.
+ for (size_t i = 0; i < interfaces_to_be_monitored_.size(); ++i) {
+ MonitorPropertyChangedInternal(interfaces_to_be_monitored_[i]);
+ }
+ interfaces_to_be_monitored_.clear();
+
observer_list_.AddObserver(observer);
}
@@ -45,6 +51,17 @@ void ShillClientHelper::RemovePropertyChangedObserver(
void ShillClientHelper::MonitorPropertyChanged(
const std::string& interface_name) {
+ if (observer_list_.size() > 0) {
+ // Effectively monitor the PropertyChanged now.
+ MonitorPropertyChangedInternal(interface_name);
+ } else {
+ // Delay the ConnectToSignal until an observer is added.
+ interfaces_to_be_monitored_.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,
« no previous file with comments | « chromeos/dbus/shill_client_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698