OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DBUS_OBJECT_PROXY_H_ | 5 #ifndef DBUS_OBJECT_PROXY_H_ |
6 #define DBUS_OBJECT_PROXY_H_ | 6 #define DBUS_OBJECT_PROXY_H_ |
7 | 7 |
8 #include <dbus/dbus.h> | 8 #include <dbus/dbus.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 // The constants correspond to DBUS_TIMEOUT_USE_DEFAULT and | 57 // The constants correspond to DBUS_TIMEOUT_USE_DEFAULT and |
58 // DBUS_TIMEOUT_INFINITE. Here we use literal numbers instead of these | 58 // DBUS_TIMEOUT_INFINITE. Here we use literal numbers instead of these |
59 // macros as these aren't defined with D-Bus earlier than 1.4.12. | 59 // macros as these aren't defined with D-Bus earlier than 1.4.12. |
60 enum { | 60 enum { |
61 TIMEOUT_USE_DEFAULT = -1, | 61 TIMEOUT_USE_DEFAULT = -1, |
62 TIMEOUT_INFINITE = 0x7fffffff, | 62 TIMEOUT_INFINITE = 0x7fffffff, |
63 }; | 63 }; |
64 | 64 |
65 // Called when an error response is returned or no response is returned. | 65 // Called when an error response is returned or no response is returned. |
66 // Used for CallMethodWithErrorCallback(). | 66 // Used for CallMethodWithErrorCallback(). |
67 typedef base::Callback<void(ErrorResponse*)> ErrorCallback; | 67 typedef base::Callback<void(ErrorResponse* error_response)> ErrorCallback; |
68 | 68 |
69 // Called when the response is returned. Used for CallMethod(). | 69 // Called when the response is returned. Used for CallMethod(). |
70 typedef base::Callback<void(Response*)> ResponseCallback; | 70 typedef base::Callback<void(Response* response)> ResponseCallback; |
71 | 71 |
72 // Called when a signal is received. Signal* is the incoming signal. | 72 // Called when a signal is received. Signal* is the incoming signal. |
73 typedef base::Callback<void (Signal*)> SignalCallback; | 73 typedef base::Callback<void (Signal* signal)> SignalCallback; |
74 | 74 |
75 // Called when the object proxy is connected to the signal. | 75 // Called when the object proxy is connected to the signal. |
76 // Parameters: | 76 // Parameters: |
77 // - the interface name. | 77 // - the interface name. |
78 // - the signal name. | 78 // - the signal name. |
79 // - whether it was successful or not. | 79 // - whether it was successful or not. |
80 typedef base::Callback<void (const std::string&, const std::string&, bool)> | 80 typedef base::Callback<void (const std::string&, const std::string&, bool)> |
81 OnConnectedCallback; | 81 OnConnectedCallback; |
82 | 82 |
83 // Calls the method of the remote object and blocks until the response | 83 // Calls the method of the remote object and blocks until the response |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 // the origin thread when D-Bus system sends "NameOwnerChanged" for the name | 146 // the origin thread when D-Bus system sends "NameOwnerChanged" for the name |
147 // represented by |service_name_|. | 147 // represented by |service_name_|. |
148 virtual void SetNameOwnerChangedCallback(SignalCallback callback); | 148 virtual void SetNameOwnerChangedCallback(SignalCallback callback); |
149 | 149 |
150 // Detaches from the remote object. The Bus object will take care of | 150 // Detaches from the remote object. The Bus object will take care of |
151 // detaching so you don't have to do this manually. | 151 // detaching so you don't have to do this manually. |
152 // | 152 // |
153 // BLOCKING CALL. | 153 // BLOCKING CALL. |
154 virtual void Detach(); | 154 virtual void Detach(); |
155 | 155 |
156 // Convenient form of CallMethodAndBlock() to call | |
157 // org.freedesktop.DBus.GetNameOwner for the given |service_name|. | |
158 // Returns true if |service_name| has an owner. | |
159 // | |
160 // BLOCKING CALL. | |
161 static bool ServiceHasOwner(dbus::Bus* bus, const std::string& service_name); | |
satorux1
2013/04/30 01:53:10
Looks rather awkward to have this in ObjectProxy a
| |
162 | |
156 // Returns an empty callback that does nothing. Can be used for | 163 // Returns an empty callback that does nothing. Can be used for |
157 // CallMethod(). | 164 // CallMethod(). |
158 static ResponseCallback EmptyResponseCallback(); | 165 static ResponseCallback EmptyResponseCallback(); |
159 | 166 |
160 protected: | 167 protected: |
161 // This is protected, so we can define sub classes. | 168 // This is protected, so we can define sub classes. |
162 virtual ~ObjectProxy(); | 169 virtual ~ObjectProxy(); |
163 | 170 |
164 private: | 171 private: |
165 friend class base::RefCountedThreadSafe<ObjectProxy>; | 172 friend class base::RefCountedThreadSafe<ObjectProxy>; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 | 289 |
283 // Known name owner of the well-known bus name represnted by |service_name_|. | 290 // Known name owner of the well-known bus name represnted by |service_name_|. |
284 std::string service_name_owner_; | 291 std::string service_name_owner_; |
285 | 292 |
286 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); | 293 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); |
287 }; | 294 }; |
288 | 295 |
289 } // namespace dbus | 296 } // namespace dbus |
290 | 297 |
291 #endif // DBUS_OBJECT_PROXY_H_ | 298 #endif // DBUS_OBJECT_PROXY_H_ |
OLD | NEW |