adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef DBUS_OBJECT_PROXY_H_ |
| 6 | #define DBUS_OBJECT_PROXY_H_ |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 7 | |
thestig@chromium.org | 519c9ac | 2011-11-15 09:29:48 +0900 | [diff] [blame] | 8 | #include <dbus/dbus.h> |
| 9 | |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 10 | #include <map> |
satorux@chromium.org | 5b3e496 | 2011-11-24 07:08:38 +0900 | [diff] [blame] | 11 | #include <set> |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 12 | #include <string> |
keybuk@chromium.org | 2594a71 | 2013-04-24 09:12:35 +0900 | [diff] [blame] | 13 | #include <vector> |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 14 | |
| 15 | #include "base/callback.h" |
| 16 | #include "base/memory/ref_counted.h" |
tfarina@chromium.org | 0eed10b | 2013-04-18 06:42:40 +0900 | [diff] [blame] | 17 | #include "base/strings/string_piece.h" |
avi@chromium.org | 78a7e7b | 2013-06-29 00:20:02 +0900 | [diff] [blame] | 18 | #include "base/time/time.h" |
tfarina@chromium.org | 7928ea2 | 2012-11-05 10:56:14 +0900 | [diff] [blame] | 19 | #include "dbus/dbus_export.h" |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 20 | #include "dbus/object_path.h" |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 21 | |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 22 | namespace dbus { |
| 23 | |
| 24 | class Bus; |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 25 | class ErrorResponse; |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 26 | class MethodCall; |
| 27 | class Response; |
avakulenko | 1d8962b | 2014-09-17 10:44:09 +0900 | [diff] [blame^] | 28 | class ScopedDBusError; |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 29 | class Signal; |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 30 | |
| 31 | // ObjectProxy is used to communicate with remote objects, mainly for |
| 32 | // calling methods of these objects. |
| 33 | // |
| 34 | // ObjectProxy is a ref counted object, to ensure that |this| of the |
avakulenko | 1d8962b | 2014-09-17 10:44:09 +0900 | [diff] [blame^] | 35 | // object is alive when callbacks referencing |this| are called; the |
keybuk@chromium.org | de7b4a9 | 2012-03-22 08:39:17 +0900 | [diff] [blame] | 36 | // bus always holds at least one of those references so object proxies |
| 37 | // always last as long as the bus that created them. |
tfarina@chromium.org | 7928ea2 | 2012-11-05 10:56:14 +0900 | [diff] [blame] | 38 | class CHROME_DBUS_EXPORT ObjectProxy |
| 39 | : public base::RefCountedThreadSafe<ObjectProxy> { |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 40 | public: |
adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 41 | // Client code should use Bus::GetObjectProxy() or |
| 42 | // Bus::GetObjectProxyWithOptions() instead of this constructor. |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 43 | ObjectProxy(Bus* bus, |
| 44 | const std::string& service_name, |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 45 | const ObjectPath& object_path, |
adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 46 | int options); |
| 47 | |
| 48 | // Options to be OR-ed together when calling Bus::GetObjectProxyWithOptions(). |
| 49 | // Set the IGNORE_SERVICE_UNKNOWN_ERRORS option to silence logging of |
stevenjb@chromium.org | c415c48 | 2014-08-09 06:57:19 +0900 | [diff] [blame] | 50 | // org.freedesktop.DBus.Error.ServiceUnknown errors and |
| 51 | // org.freedesktop.DBus.Error.ObjectUnknown errors. |
adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 52 | enum Options { |
| 53 | DEFAULT_OPTIONS = 0, |
| 54 | IGNORE_SERVICE_UNKNOWN_ERRORS = 1 << 0 |
| 55 | }; |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 56 | |
| 57 | // Special timeout constants. |
| 58 | // |
| 59 | // The constants correspond to DBUS_TIMEOUT_USE_DEFAULT and |
| 60 | // DBUS_TIMEOUT_INFINITE. Here we use literal numbers instead of these |
| 61 | // macros as these aren't defined with D-Bus earlier than 1.4.12. |
| 62 | enum { |
| 63 | TIMEOUT_USE_DEFAULT = -1, |
| 64 | TIMEOUT_INFINITE = 0x7fffffff, |
| 65 | }; |
| 66 | |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 67 | // Called when an error response is returned or no response is returned. |
| 68 | // Used for CallMethodWithErrorCallback(). |
| 69 | typedef base::Callback<void(ErrorResponse*)> ErrorCallback; |
| 70 | |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 71 | // Called when the response is returned. Used for CallMethod(). |
| 72 | typedef base::Callback<void(Response*)> ResponseCallback; |
| 73 | |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 74 | // Called when a signal is received. Signal* is the incoming signal. |
| 75 | typedef base::Callback<void (Signal*)> SignalCallback; |
| 76 | |
hashimoto@chromium.org | 4f3851c | 2013-09-27 16:12:03 +0900 | [diff] [blame] | 77 | // Called when NameOwnerChanged signal is received. |
| 78 | typedef base::Callback<void( |
| 79 | const std::string& old_owner, |
| 80 | const std::string& new_owner)> NameOwnerChangedCallback; |
| 81 | |
hashimoto@chromium.org | ed26809 | 2013-10-02 16:53:09 +0900 | [diff] [blame] | 82 | // Called when the service becomes available. |
| 83 | typedef base::Callback<void( |
| 84 | bool service_is_available)> WaitForServiceToBeAvailableCallback; |
| 85 | |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 86 | // Called when the object proxy is connected to the signal. |
| 87 | // Parameters: |
| 88 | // - the interface name. |
| 89 | // - the signal name. |
| 90 | // - whether it was successful or not. |
| 91 | typedef base::Callback<void (const std::string&, const std::string&, bool)> |
| 92 | OnConnectedCallback; |
| 93 | |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 94 | // Calls the method of the remote object and blocks until the response |
avakulenko | 1d8962b | 2014-09-17 10:44:09 +0900 | [diff] [blame^] | 95 | // is returned. Returns NULL on error with the error details specified |
| 96 | // in the |error| object. |
| 97 | // |
| 98 | // BLOCKING CALL. |
| 99 | virtual scoped_ptr<Response> CallMethodAndBlockWithErrorDetails( |
| 100 | MethodCall* method_call, |
| 101 | int timeout_ms, |
| 102 | ScopedDBusError* error); |
| 103 | |
| 104 | // Calls the method of the remote object and blocks until the response |
satorux@chromium.org | ffa83a9 | 2011-08-24 12:32:06 +0900 | [diff] [blame] | 105 | // is returned. Returns NULL on error. |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 106 | // |
| 107 | // BLOCKING CALL. |
yuki@chromium.org | d4eedf8 | 2013-02-07 18:46:24 +0900 | [diff] [blame] | 108 | virtual scoped_ptr<Response> CallMethodAndBlock(MethodCall* method_call, |
| 109 | int timeout_ms); |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 110 | |
| 111 | // Requests to call the method of the remote object. |
| 112 | // |
| 113 | // |callback| will be called in the origin thread, once the method call |
| 114 | // is complete. As it's called in the origin thread, |callback| can |
| 115 | // safely reference objects in the origin thread (i.e. UI thread in most |
satorux@chromium.org | b175315 | 2011-11-11 17:36:22 +0900 | [diff] [blame] | 116 | // cases). If the caller is not interested in the response from the |
| 117 | // method (i.e. calling a method that does not return a value), |
| 118 | // EmptyResponseCallback() can be passed to the |callback| parameter. |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 119 | // |
| 120 | // If the method call is successful, a pointer to Response object will |
| 121 | // be passed to the callback. If unsuccessful, NULL will be passed to |
| 122 | // the callback. |
| 123 | // |
| 124 | // Must be called in the origin thread. |
| 125 | virtual void CallMethod(MethodCall* method_call, |
| 126 | int timeout_ms, |
| 127 | ResponseCallback callback); |
| 128 | |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 129 | // Requests to call the method of the remote object. |
| 130 | // |
| 131 | // |callback| and |error_callback| will be called in the origin thread, once |
| 132 | // the method call is complete. As it's called in the origin thread, |
| 133 | // |callback| can safely reference objects in the origin thread (i.e. |
| 134 | // UI thread in most cases). If the caller is not interested in the response |
| 135 | // from the method (i.e. calling a method that does not return a value), |
| 136 | // EmptyResponseCallback() can be passed to the |callback| parameter. |
| 137 | // |
| 138 | // If the method call is successful, a pointer to Response object will |
| 139 | // be passed to the callback. If unsuccessful, the error callback will be |
| 140 | // called and a pointer to ErrorResponse object will be passed to the error |
| 141 | // callback if available, otherwise NULL will be passed. |
| 142 | // |
| 143 | // Must be called in the origin thread. |
| 144 | virtual void CallMethodWithErrorCallback(MethodCall* method_call, |
| 145 | int timeout_ms, |
| 146 | ResponseCallback callback, |
| 147 | ErrorCallback error_callback); |
| 148 | |
keybuk@chromium.org | de7b4a9 | 2012-03-22 08:39:17 +0900 | [diff] [blame] | 149 | // Requests to connect to the signal from the remote object, replacing |
| 150 | // any previous |signal_callback| connected to that signal. |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 151 | // |
| 152 | // |signal_callback| will be called in the origin thread, when the |
| 153 | // signal is received from the remote object. As it's called in the |
| 154 | // origin thread, |signal_callback| can safely reference objects in the |
| 155 | // origin thread (i.e. UI thread in most cases). |
| 156 | // |
| 157 | // |on_connected_callback| is called when the object proxy is connected |
| 158 | // to the signal, or failed to be connected, in the origin thread. |
| 159 | // |
| 160 | // Must be called in the origin thread. |
| 161 | virtual void ConnectToSignal(const std::string& interface_name, |
| 162 | const std::string& signal_name, |
| 163 | SignalCallback signal_callback, |
| 164 | OnConnectedCallback on_connected_callback); |
| 165 | |
haruki@chromium.org | c8d231a | 2012-11-14 20:02:59 +0900 | [diff] [blame] | 166 | // Sets a callback for "NameOwnerChanged" signal. The callback is called on |
| 167 | // the origin thread when D-Bus system sends "NameOwnerChanged" for the name |
| 168 | // represented by |service_name_|. |
hashimoto@chromium.org | 4f3851c | 2013-09-27 16:12:03 +0900 | [diff] [blame] | 169 | virtual void SetNameOwnerChangedCallback(NameOwnerChangedCallback callback); |
haruki@chromium.org | c8d231a | 2012-11-14 20:02:59 +0900 | [diff] [blame] | 170 | |
hashimoto@chromium.org | ed26809 | 2013-10-02 16:53:09 +0900 | [diff] [blame] | 171 | // Runs the callback as soon as the service becomes available. |
| 172 | virtual void WaitForServiceToBeAvailable( |
| 173 | WaitForServiceToBeAvailableCallback callback); |
| 174 | |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 175 | // Detaches from the remote object. The Bus object will take care of |
| 176 | // detaching so you don't have to do this manually. |
| 177 | // |
| 178 | // BLOCKING CALL. |
| 179 | virtual void Detach(); |
| 180 | |
stevenjb@chromium.org | b53cfb3 | 2013-10-08 07:56:57 +0900 | [diff] [blame] | 181 | const ObjectPath& object_path() const { return object_path_; } |
| 182 | |
satorux@chromium.org | b175315 | 2011-11-11 17:36:22 +0900 | [diff] [blame] | 183 | // Returns an empty callback that does nothing. Can be used for |
| 184 | // CallMethod(). |
| 185 | static ResponseCallback EmptyResponseCallback(); |
| 186 | |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 187 | protected: |
| 188 | // This is protected, so we can define sub classes. |
| 189 | virtual ~ObjectProxy(); |
| 190 | |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 191 | private: |
| 192 | friend class base::RefCountedThreadSafe<ObjectProxy>; |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 193 | |
| 194 | // Struct of data we'll be passing from StartAsyncMethodCall() to |
| 195 | // OnPendingCallIsCompleteThunk(). |
| 196 | struct OnPendingCallIsCompleteData { |
| 197 | OnPendingCallIsCompleteData(ObjectProxy* in_object_proxy, |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 198 | ResponseCallback in_response_callback, |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 199 | ErrorCallback error_callback, |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 200 | base::TimeTicks start_time); |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 201 | ~OnPendingCallIsCompleteData(); |
| 202 | |
| 203 | ObjectProxy* object_proxy; |
| 204 | ResponseCallback response_callback; |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 205 | ErrorCallback error_callback; |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 206 | base::TimeTicks start_time; |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 207 | }; |
| 208 | |
| 209 | // Starts the async method call. This is a helper function to implement |
| 210 | // CallMethod(). |
| 211 | void StartAsyncMethodCall(int timeout_ms, |
satorux@chromium.org | 47d706b | 2011-10-04 22:47:21 +0900 | [diff] [blame] | 212 | DBusMessage* request_message, |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 213 | ResponseCallback response_callback, |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 214 | ErrorCallback error_callback, |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 215 | base::TimeTicks start_time); |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 216 | |
| 217 | // Called when the pending call is complete. |
| 218 | void OnPendingCallIsComplete(DBusPendingCall* pending_call, |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 219 | ResponseCallback response_callback, |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 220 | ErrorCallback error_callback, |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 221 | base::TimeTicks start_time); |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 222 | |
| 223 | // Runs the response callback with the given response object. |
| 224 | void RunResponseCallback(ResponseCallback response_callback, |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 225 | ErrorCallback error_callback, |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 226 | base::TimeTicks start_time, |
satorux@chromium.org | 47d706b | 2011-10-04 22:47:21 +0900 | [diff] [blame] | 227 | DBusMessage* response_message); |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 228 | |
| 229 | // Redirects the function call to OnPendingCallIsComplete(). |
| 230 | static void OnPendingCallIsCompleteThunk(DBusPendingCall* pending_call, |
| 231 | void* user_data); |
| 232 | |
hashimoto@chromium.org | ed26809 | 2013-10-02 16:53:09 +0900 | [diff] [blame] | 233 | // Connects to NameOwnerChanged signal. |
| 234 | bool ConnectToNameOwnerChangedSignal(); |
| 235 | |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 236 | // Helper function for ConnectToSignal(). |
hashimoto@chromium.org | ce5c615 | 2013-09-26 15:40:04 +0900 | [diff] [blame] | 237 | bool ConnectToSignalInternal(const std::string& interface_name, |
| 238 | const std::string& signal_name, |
| 239 | SignalCallback signal_callback); |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 240 | |
hashimoto@chromium.org | ed26809 | 2013-10-02 16:53:09 +0900 | [diff] [blame] | 241 | // Helper function for WaitForServiceToBeAvailable(). |
| 242 | void WaitForServiceToBeAvailableInternal(); |
| 243 | |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 244 | // Handles the incoming request messages and dispatches to the signal |
| 245 | // callbacks. |
| 246 | DBusHandlerResult HandleMessage(DBusConnection* connection, |
| 247 | DBusMessage* raw_message); |
| 248 | |
| 249 | // Runs the method. Helper function for HandleMessage(). |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 250 | void RunMethod(base::TimeTicks start_time, |
keybuk@chromium.org | 2594a71 | 2013-04-24 09:12:35 +0900 | [diff] [blame] | 251 | std::vector<SignalCallback> signal_callbacks, |
satorux@chromium.org | 5a92cf3 | 2011-09-07 05:53:30 +0900 | [diff] [blame] | 252 | Signal* signal); |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 253 | |
| 254 | // Redirects the function call to HandleMessage(). |
| 255 | static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, |
| 256 | DBusMessage* raw_message, |
| 257 | void* user_data); |
| 258 | |
adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 259 | // Helper method for logging response errors appropriately. |
satorux@chromium.org | 31bb21e | 2012-05-31 15:12:11 +0900 | [diff] [blame] | 260 | void LogMethodCallFailure(const base::StringPiece& interface_name, |
| 261 | const base::StringPiece& method_name, |
| 262 | const base::StringPiece& error_name, |
adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 263 | const base::StringPiece& error_message) const; |
| 264 | |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 265 | // Used as ErrorCallback by CallMethod(). |
satorux@chromium.org | 31bb21e | 2012-05-31 15:12:11 +0900 | [diff] [blame] | 266 | void OnCallMethodError(const std::string& interface_name, |
| 267 | const std::string& method_name, |
| 268 | ResponseCallback response_callback, |
hashimoto@chromium.org | 0d2477e | 2012-04-20 12:18:27 +0900 | [diff] [blame] | 269 | ErrorResponse* error_response); |
| 270 | |
haruki@chromium.org | c5623ec | 2012-10-29 15:27:33 +0900 | [diff] [blame] | 271 | // Adds the match rule to the bus and associate the callback with the signal. |
| 272 | bool AddMatchRuleWithCallback(const std::string& match_rule, |
| 273 | const std::string& absolute_signal_name, |
| 274 | SignalCallback signal_callback); |
| 275 | |
| 276 | // Adds the match rule to the bus so that HandleMessage can see the signal. |
| 277 | bool AddMatchRuleWithoutCallback(const std::string& match_rule, |
| 278 | const std::string& absolute_signal_name); |
| 279 | |
| 280 | // Calls D-Bus's GetNameOwner method synchronously to update |
| 281 | // |service_name_owner_| with the current owner of |service_name_|. |
| 282 | // |
| 283 | // BLOCKING CALL. |
| 284 | void UpdateNameOwnerAndBlock(); |
| 285 | |
| 286 | // Handles NameOwnerChanged signal from D-Bus's special message bus. |
haruki@chromium.org | c8d231a | 2012-11-14 20:02:59 +0900 | [diff] [blame] | 287 | DBusHandlerResult HandleNameOwnerChanged(scoped_ptr<dbus::Signal> signal); |
haruki@chromium.org | c5623ec | 2012-10-29 15:27:33 +0900 | [diff] [blame] | 288 | |
hashimoto@chromium.org | 4f3851c | 2013-09-27 16:12:03 +0900 | [diff] [blame] | 289 | // Runs |name_owner_changed_callback_|. |
| 290 | void RunNameOwnerChangedCallback(const std::string& old_owner, |
| 291 | const std::string& new_owner); |
| 292 | |
hashimoto@chromium.org | ed26809 | 2013-10-02 16:53:09 +0900 | [diff] [blame] | 293 | // Runs |wait_for_service_to_be_available_callbacks_|. |
| 294 | void RunWaitForServiceToBeAvailableCallbacks(bool service_is_available); |
| 295 | |
satorux@chromium.org | f06eb89 | 2011-10-13 09:45:26 +0900 | [diff] [blame] | 296 | scoped_refptr<Bus> bus_; |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 297 | std::string service_name_; |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 298 | ObjectPath object_path_; |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 299 | |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 300 | // True if the message filter was added. |
| 301 | bool filter_added_; |
| 302 | |
| 303 | // The method table where keys are absolute signal names (i.e. interface |
keybuk@chromium.org | 2594a71 | 2013-04-24 09:12:35 +0900 | [diff] [blame] | 304 | // name + signal name), and values are lists of the corresponding callbacks. |
| 305 | typedef std::map<std::string, std::vector<SignalCallback> > MethodTable; |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 306 | MethodTable method_table_; |
| 307 | |
haruki@chromium.org | c8d231a | 2012-11-14 20:02:59 +0900 | [diff] [blame] | 308 | // The callback called when NameOwnerChanged signal is received. |
hashimoto@chromium.org | 4f3851c | 2013-09-27 16:12:03 +0900 | [diff] [blame] | 309 | NameOwnerChangedCallback name_owner_changed_callback_; |
haruki@chromium.org | c8d231a | 2012-11-14 20:02:59 +0900 | [diff] [blame] | 310 | |
hashimoto@chromium.org | ed26809 | 2013-10-02 16:53:09 +0900 | [diff] [blame] | 311 | // Called when the service becomes available. |
| 312 | std::vector<WaitForServiceToBeAvailableCallback> |
| 313 | wait_for_service_to_be_available_callbacks_; |
| 314 | |
satorux@chromium.org | 5b3e496 | 2011-11-24 07:08:38 +0900 | [diff] [blame] | 315 | std::set<std::string> match_rules_; |
satorux@chromium.org | 7f0c451 | 2011-08-23 16:29:21 +0900 | [diff] [blame] | 316 | |
adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 317 | const bool ignore_service_unknown_errors_; |
| 318 | |
avakulenko | 1d8962b | 2014-09-17 10:44:09 +0900 | [diff] [blame^] | 319 | // Known name owner of the well-known bus name represented by |service_name_|. |
haruki@chromium.org | c5623ec | 2012-10-29 15:27:33 +0900 | [diff] [blame] | 320 | std::string service_name_owner_; |
| 321 | |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 322 | DISALLOW_COPY_AND_ASSIGN(ObjectProxy); |
| 323 | }; |
| 324 | |
| 325 | } // namespace dbus |
| 326 | |
| 327 | #endif // DBUS_OBJECT_PROXY_H_ |