summaryrefslogtreecommitdiffstats
path: root/dbus/object_proxy.h
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-20 03:18:27 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-20 03:18:27 +0000
commit91fe7ea8bd64b8137dac7d2de2f9110a9b28f100 (patch)
tree7b8dadb6cb5dfbaeec2b24ef14c9cd5b1ea38166 /dbus/object_proxy.h
parentca88302d0fbac047f1363258ded9b39d7f9b7ab7 (diff)
downloadchromium_src-91fe7ea8bd64b8137dac7d2de2f9110a9b28f100.zip
chromium_src-91fe7ea8bd64b8137dac7d2de2f9110a9b28f100.tar.gz
chromium_src-91fe7ea8bd64b8137dac7d2de2f9110a9b28f100.tar.bz2
Add dbus::ObjectProxy::CallMethodWithErrorCallback
Add CallMethodWithErrorCallback Add EndToEndAsyncTest.BrokenBus Fix leak in StartAsyncMethodCall BUG=chromium-os:27899 TEST=dbus_unittests --gtest_filter="EndToEndAsyncTest.*" Review URL: https://chromiumcodereview.appspot.com/10121005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133140 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/object_proxy.h')
-rw-r--r--dbus/object_proxy.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/dbus/object_proxy.h b/dbus/object_proxy.h
index eb09b8c0..620622f 100644
--- a/dbus/object_proxy.h
+++ b/dbus/object_proxy.h
@@ -21,6 +21,7 @@
namespace dbus {
class Bus;
+class ErrorResponse;
class MethodCall;
class Response;
class Signal;
@@ -59,6 +60,10 @@ class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> {
TIMEOUT_INFINITE = 0x7fffffff,
};
+ // Called when an error response is returned or no response is returned.
+ // Used for CallMethodWithErrorCallback().
+ typedef base::Callback<void(ErrorResponse*)> ErrorCallback;
+
// Called when the response is returned. Used for CallMethod().
typedef base::Callback<void(Response*)> ResponseCallback;
@@ -99,6 +104,26 @@ class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> {
int timeout_ms,
ResponseCallback callback);
+ // Requests to call the method of the remote object.
+ //
+ // |callback| and |error_callback| will be called in the origin thread, once
+ // the method call is complete. As it's called in the origin thread,
+ // |callback| can safely reference objects in the origin thread (i.e.
+ // UI thread in most cases). If the caller is not interested in the response
+ // from the method (i.e. calling a method that does not return a value),
+ // EmptyResponseCallback() can be passed to the |callback| parameter.
+ //
+ // If the method call is successful, a pointer to Response object will
+ // be passed to the callback. If unsuccessful, the error callback will be
+ // called and a pointer to ErrorResponse object will be passed to the error
+ // callback if available, otherwise NULL will be passed.
+ //
+ // Must be called in the origin thread.
+ virtual void CallMethodWithErrorCallback(MethodCall* method_call,
+ int timeout_ms,
+ ResponseCallback callback,
+ ErrorCallback error_callback);
+
// Requests to connect to the signal from the remote object, replacing
// any previous |signal_callback| connected to that signal.
//
@@ -138,11 +163,13 @@ class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> {
struct OnPendingCallIsCompleteData {
OnPendingCallIsCompleteData(ObjectProxy* in_object_proxy,
ResponseCallback in_response_callback,
+ ErrorCallback error_callback,
base::TimeTicks start_time);
~OnPendingCallIsCompleteData();
ObjectProxy* object_proxy;
ResponseCallback response_callback;
+ ErrorCallback error_callback;
base::TimeTicks start_time;
};
@@ -151,15 +178,18 @@ class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> {
void StartAsyncMethodCall(int timeout_ms,
DBusMessage* request_message,
ResponseCallback response_callback,
+ ErrorCallback error_callback,
base::TimeTicks start_time);
// Called when the pending call is complete.
void OnPendingCallIsComplete(DBusPendingCall* pending_call,
ResponseCallback response_callback,
+ ErrorCallback error_callback,
base::TimeTicks start_time);
// Runs the response callback with the given response object.
void RunResponseCallback(ResponseCallback response_callback,
+ ErrorCallback error_callback,
base::TimeTicks start_time,
DBusMessage* response_message);
@@ -199,6 +229,10 @@ class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> {
void LogMethodCallFailure(const base::StringPiece& error_name,
const base::StringPiece& error_message) const;
+ // Used as ErrorCallback by CallMethod().
+ void OnCallMethodError(ResponseCallback response_callback,
+ ErrorResponse* error_response);
+
scoped_refptr<Bus> bus_;
std::string service_name_;
ObjectPath object_path_;