Index: chromeos/dbus/shill_client_helper.cc |
diff --git a/chromeos/dbus/shill_client_helper.cc b/chromeos/dbus/shill_client_helper.cc |
index bd421bcfa453f26f02bd5b809d0dc0f2038d275a..6b68784a28ea43675e62989f5a2fb5fa91f68784 100644 |
--- a/chromeos/dbus/shill_client_helper.cc |
+++ b/chromeos/dbus/shill_client_helper.cc |
@@ -14,7 +14,7 @@ |
namespace chromeos { |
ShillClientHelper::ShillClientHelper(dbus::Bus* bus, |
- dbus::ObjectProxy* proxy) |
+ dbus::ObjectProxy* proxy) |
: blocking_method_caller_(bus, proxy), |
proxy_(proxy), |
weak_ptr_factory_(this) { |
@@ -23,13 +23,14 @@ ShillClientHelper::ShillClientHelper(dbus::Bus* bus, |
ShillClientHelper::~ShillClientHelper() { |
} |
-void ShillClientHelper::SetPropertyChangedHandler( |
- const PropertyChangedHandler& handler) { |
- property_changed_handler_ = handler; |
+void ShillClientHelper::AddPropertyChangedObserver( |
+ PropertyChangedObserver* obs) { |
hashimoto
2012/09/21 11:52:01
Rename this to |observer|
Greg Spencer (Chromium)
2012/09/21 22:03:47
Done.
|
+ observer_list_.AddObserver(obs); |
} |
-void ShillClientHelper::ResetPropertyChangedHandler() { |
- property_changed_handler_.Reset(); |
+void ShillClientHelper::RemovePropertyChangedObserver( |
+ PropertyChangedObserver* obs) { |
hashimoto
2012/09/21 11:52:01
ditto.
Greg Spencer (Chromium)
2012/09/21 22:03:47
Done.
|
+ observer_list_.RemoveObserver(obs); |
} |
void ShillClientHelper::MonitorPropertyChanged( |
@@ -62,6 +63,21 @@ void ShillClientHelper::CallObjectPathMethod( |
callback)); |
} |
+void ShillClientHelper::CallObjectPathMethodWithErrorCallback( |
+ dbus::MethodCall* method_call, |
+ const ObjectPathDBusMethodCallback& callback, |
+ const ErrorCallback& error_callback) { |
+ proxy_->CallMethodWithErrorCallback( |
+ method_call, |
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
+ base::Bind(&ShillClientHelper::OnObjectPathMethod, |
+ weak_ptr_factory_.GetWeakPtr(), |
+ callback), |
+ base::Bind(&ShillClientHelper::OnError, |
+ weak_ptr_factory_.GetWeakPtr(), |
+ error_callback)); |
+} |
+ |
void ShillClientHelper::CallDictionaryValueMethod( |
dbus::MethodCall* method_call, |
const DictionaryValueCallback& callback) { |
@@ -144,7 +160,7 @@ base::DictionaryValue* ShillClientHelper::CallDictionaryValueMethodAndBlock( |
// static |
void ShillClientHelper::AppendValueDataAsVariant(dbus::MessageWriter* writer, |
- const base::Value& value) { |
+ const base::Value& value) { |
// Support basic types and string-to-string dictionary. |
switch (value.GetType()) { |
case base::Value::TYPE_DICTIONARY: { |
@@ -185,14 +201,14 @@ void ShillClientHelper::AppendValueDataAsVariant(dbus::MessageWriter* writer, |
} |
void ShillClientHelper::OnSignalConnected(const std::string& interface, |
- const std::string& signal, |
- bool success) { |
+ const std::string& signal, |
+ bool success) { |
LOG_IF(ERROR, !success) << "Connect to " << interface << " " << signal |
<< " failed."; |
} |
void ShillClientHelper::OnPropertyChanged(dbus::Signal* signal) { |
- if (property_changed_handler_.is_null()) |
+ if (!observer_list_.might_have_observers()) |
hashimoto
2012/09/21 11:52:01
This early exit was necessary since calling Run()
Greg Spencer (Chromium)
2012/09/21 22:03:47
Sure, but why not early exit anyhow, to avoid havi
|
return; |
dbus::MessageReader reader(signal); |
@@ -202,11 +218,14 @@ void ShillClientHelper::OnPropertyChanged(dbus::Signal* signal) { |
scoped_ptr<base::Value> value(dbus::PopDataAsValue(&reader)); |
if (!value.get()) |
return; |
- property_changed_handler_.Run(name, *value); |
+ |
+ FOR_EACH_OBSERVER(PropertyChangedObserver, observer_list_, |
+ OnPropertyChanged(name, *value)); |
+ |
} |
void ShillClientHelper::OnVoidMethod(const VoidDBusMethodCallback& callback, |
- dbus::Response* response) { |
+ dbus::Response* response) { |
if (!response) { |
callback.Run(DBUS_METHOD_CALL_FAILURE); |
return; |
@@ -272,7 +291,7 @@ void ShillClientHelper::OnDictionaryValueMethodWithErrorCallback( |
} |
void ShillClientHelper::OnError(const ErrorCallback& error_callback, |
- dbus::ErrorResponse* response) { |
+ dbus::ErrorResponse* response) { |
std::string error_name; |
std::string error_message; |
if (response) { |