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

Unified Diff: chromeos/dbus/shill_service_client.cc

Issue 10949030: This converts the Shill clients to allow propagation of shill errors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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
Index: chromeos/dbus/shill_service_client.cc
diff --git a/chromeos/dbus/shill_service_client.cc b/chromeos/dbus/shill_service_client.cc
index 91f269032233fc3a2c02af198b552c60bf71f2c1..3c9195b6999f9e16f4600c4cb2c9740ed9fa73af 100644
--- a/chromeos/dbus/shill_service_client.cc
+++ b/chromeos/dbus/shill_service_client.cc
@@ -47,20 +47,20 @@ class ShillServiceClientImpl : public ShillServiceClient {
helpers_deleter_(&helpers_) {
}
- // ShillServiceClient override.
- virtual void SetPropertyChangedHandler(
+ /////////////////////////////////////
+ // ShillServiceClient overrides.
+ virtual void AddPropertyChangedObserver(
const dbus::ObjectPath& service_path,
- const PropertyChangedHandler& handler) OVERRIDE {
- GetHelper(service_path)->SetPropertyChangedHandler(handler);
+ PropertyChangedObserver* observer) OVERRIDE {
+ GetHelper(service_path)->AddPropertyChangedObserver(observer);
}
- // ShillServiceClient override.
- virtual void ResetPropertyChangedHandler(
- const dbus::ObjectPath& service_path) OVERRIDE {
- GetHelper(service_path)->ResetPropertyChangedHandler();
+ virtual void RemovePropertyChangedObserver(
+ const dbus::ObjectPath& service_path,
+ PropertyChangedObserver* observer) OVERRIDE {
+ GetHelper(service_path)->RemovePropertyChangedObserver(observer);
}
- // ShillServiceClient override.
virtual void GetProperties(const dbus::ObjectPath& service_path,
const DictionaryValueCallback& callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
@@ -71,31 +71,34 @@ class ShillServiceClientImpl : public ShillServiceClient {
base::Bind(&OnGetPropertiesError, service_path, callback));
}
- // ShillServiceClient override.
virtual void SetProperty(const dbus::ObjectPath& service_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kSetPropertyFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(name);
ShillClientHelper::AppendValueDataAsVariant(&writer, value);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
- // ShillServiceClient override.
virtual void ClearProperty(const dbus::ObjectPath& service_path,
const std::string& name,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kClearPropertyFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(name);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
- // ShillServiceClient override.
virtual void Connect(const dbus::ObjectPath& service_path,
const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE {
@@ -105,35 +108,40 @@ class ShillServiceClientImpl : public ShillServiceClient {
&method_call, callback, error_callback);
}
- // ShillServiceClient override.
virtual void Disconnect(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kDisconnectFunction);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
- // ShillServiceClient override.
virtual void Remove(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kRemoveServiceFunction);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
- // ShillServiceClient override.
virtual void ActivateCellularModem(
const dbus::ObjectPath& service_path,
const std::string& carrier,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kActivateCellularModemFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(carrier);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
- // ShillServiceClient override.
virtual bool CallActivateCellularModemAndBlock(
const dbus::ObjectPath& service_path,
const std::string& carrier) OVERRIDE {
@@ -176,16 +184,16 @@ class ShillServiceClientStubImpl : public ShillServiceClient {
virtual ~ShillServiceClientStubImpl() {}
- // ShillServiceClient override.
- virtual void SetPropertyChangedHandler(
+ ///////////////////////////////////
+ // ShillServiceClient overrides.
+ virtual void AddPropertyChangedObserver(
const dbus::ObjectPath& service_path,
- const PropertyChangedHandler& handler) OVERRIDE {}
+ PropertyChangedObserver* observer) OVERRIDE {}
- // ShillServiceClient override.
- virtual void ResetPropertyChangedHandler(
- const dbus::ObjectPath& service_path) OVERRIDE {}
+ virtual void RemovePropertyChangedObserver(
+ const dbus::ObjectPath& service_path,
+ PropertyChangedObserver* observer) OVERRIDE {}
- // ShillServiceClient override.
virtual void GetProperties(const dbus::ObjectPath& service_path,
const DictionaryValueCallback& callback) OVERRIDE {
MessageLoop::current()->PostTask(
@@ -195,49 +203,47 @@ class ShillServiceClientStubImpl : public ShillServiceClient {
callback));
}
- // ShillServiceClient override.
virtual void SetProperty(const dbus::ObjectPath& service_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ PostClosure(callback);
}
- // ShillServiceClient override.
virtual void ClearProperty(const dbus::ObjectPath& service_path,
const std::string& name,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ PostClosure(callback);
}
- // ShillServiceClient override.
virtual void Connect(const dbus::ObjectPath& service_path,
const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE {
MessageLoop::current()->PostTask(FROM_HERE, callback);
}
- // ShillServiceClient override.
virtual void Disconnect(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ PostClosure(callback);
}
- // ShillServiceClient override.
virtual void Remove(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ PostClosure(callback);
}
- // ShillServiceClient override.
virtual void ActivateCellularModem(
const dbus::ObjectPath& service_path,
const std::string& carrier,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ PostClosure(callback);
}
- // ShillServiceClient override.
virtual bool CallActivateCellularModemAndBlock(
const dbus::ObjectPath& service_path,
const std::string& carrier) OVERRIDE {
@@ -250,11 +256,9 @@ class ShillServiceClientStubImpl : public ShillServiceClient {
callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary);
}
- // Posts a task to run a void callback with success status code.
- void PostSuccessVoidCallback(const VoidDBusMethodCallback& callback) {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS));
+ // Posts a task to run a closure.
+ void PostClosure(const base::Closure& callback) {
hashimoto 2012/09/21 11:52:01 Since this method became very simple, we no longer
Greg Spencer (Chromium) 2012/09/21 22:03:47 Removed.
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
// Note: This should remain the last member so it'll be destroyed and

Powered by Google App Engine
This is Rietveld 408576698