diff options
author | gspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-28 20:34:18 +0000 |
---|---|---|
committer | gspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-28 20:34:18 +0000 |
commit | d690ba464ab9b62373eb6b88435054d79f93a02e (patch) | |
tree | e010ce3b5d8cca5d6e7e03446d5742a7c4439929 /chromeos/dbus/shill_service_client.cc | |
parent | 2a74ed6cca3901234dad1294487a6ccd7b0710c9 (diff) | |
download | chromium_src-d690ba464ab9b62373eb6b88435054d79f93a02e.zip chromium_src-d690ba464ab9b62373eb6b88435054d79f93a02e.tar.gz chromium_src-d690ba464ab9b62373eb6b88435054d79f93a02e.tar.bz2 |
This converts the Shill clients to allow propagation of shill errors
back from the function calls. The existing implentation completely ignores most shill errors, and the javascript implementation will want to be able to receive them to aid in diagnosis.
BUG=chromium:147620,chromium:146616
TEST=Ran unit tests, ran on device.
Review URL: https://chromiumcodereview.appspot.com/10949030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/shill_service_client.cc')
-rw-r--r-- | chromeos/dbus/shill_service_client.cc | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/chromeos/dbus/shill_service_client.cc b/chromeos/dbus/shill_service_client.cc index 6a1c617..46fe0f4 100644 --- a/chromeos/dbus/shill_service_client.cc +++ b/chromeos/dbus/shill_service_client.cc @@ -75,23 +75,29 @@ class ShillServiceClientImpl : public ShillServiceClient { 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); } 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); } virtual void Connect(const dbus::ObjectPath& service_path, @@ -104,28 +110,37 @@ class ShillServiceClientImpl : public ShillServiceClient { } 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); } 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); } 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); } virtual bool CallActivateCellularModemAndBlock( @@ -192,14 +207,16 @@ class ShillServiceClientStubImpl : public ShillServiceClient { 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 { + MessageLoop::current()->PostTask(FROM_HERE, callback); } 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 { + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void Connect(const dbus::ObjectPath& service_path, @@ -209,20 +226,23 @@ class ShillServiceClientStubImpl : public ShillServiceClient { } virtual void Disconnect(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback) OVERRIDE { - PostSuccessVoidCallback(callback); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void Remove(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback) OVERRIDE { - PostSuccessVoidCallback(callback); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } 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 { + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual bool CallActivateCellularModemAndBlock( @@ -237,13 +257,6 @@ 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)); - } - // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<ShillServiceClientStubImpl> weak_ptr_factory_; |