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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <dbus/dbus.h> | 9 #include <dbus/dbus.h> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 class Bus; | 23 class Bus; |
24 class MethodCall; | 24 class MethodCall; |
25 class Response; | 25 class Response; |
26 class Signal; | 26 class Signal; |
27 | 27 |
28 // ObjectProxy is used to communicate with remote objects, mainly for | 28 // ObjectProxy is used to communicate with remote objects, mainly for |
29 // calling methods of these objects. | 29 // calling methods of these objects. |
30 // | 30 // |
31 // ObjectProxy is a ref counted object, to ensure that |this| of the | 31 // ObjectProxy is a ref counted object, to ensure that |this| of the |
32 // object is is alive when callbacks referencing |this| are called. | 32 // object is is alive when callbacks referencing |this| are called; the |
| 33 // bus always holds at least one of those references so object proxies |
| 34 // always last as long as the bus that created them. |
33 class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> { | 35 class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> { |
34 public: | 36 public: |
35 // Client code should use Bus::GetObjectProxy() or | 37 // Client code should use Bus::GetObjectProxy() or |
36 // Bus::GetObjectProxyWithOptions() instead of this constructor. | 38 // Bus::GetObjectProxyWithOptions() instead of this constructor. |
37 ObjectProxy(Bus* bus, | 39 ObjectProxy(Bus* bus, |
38 const std::string& service_name, | 40 const std::string& service_name, |
39 const ObjectPath& object_path, | 41 const ObjectPath& object_path, |
40 int options); | 42 int options); |
41 | 43 |
42 // Options to be OR-ed together when calling Bus::GetObjectProxyWithOptions(). | 44 // Options to be OR-ed together when calling Bus::GetObjectProxyWithOptions(). |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // | 91 // |
90 // If the method call is successful, a pointer to Response object will | 92 // If the method call is successful, a pointer to Response object will |
91 // be passed to the callback. If unsuccessful, NULL will be passed to | 93 // be passed to the callback. If unsuccessful, NULL will be passed to |
92 // the callback. | 94 // the callback. |
93 // | 95 // |
94 // Must be called in the origin thread. | 96 // Must be called in the origin thread. |
95 virtual void CallMethod(MethodCall* method_call, | 97 virtual void CallMethod(MethodCall* method_call, |
96 int timeout_ms, | 98 int timeout_ms, |
97 ResponseCallback callback); | 99 ResponseCallback callback); |
98 | 100 |
99 // Requests to connect to the signal from the remote object. | 101 // Requests to connect to the signal from the remote object, replacing |
| 102 // any previous |signal_callback| connected to that signal. |
100 // | 103 // |
101 // |signal_callback| will be called in the origin thread, when the | 104 // |signal_callback| will be called in the origin thread, when the |
102 // signal is received from the remote object. As it's called in the | 105 // signal is received from the remote object. As it's called in the |
103 // origin thread, |signal_callback| can safely reference objects in the | 106 // origin thread, |signal_callback| can safely reference objects in the |
104 // origin thread (i.e. UI thread in most cases). | 107 // origin thread (i.e. UI thread in most cases). |
105 // | 108 // |
106 // |on_connected_callback| is called when the object proxy is connected | 109 // |on_connected_callback| is called when the object proxy is connected |
107 // to the signal, or failed to be connected, in the origin thread. | 110 // to the signal, or failed to be connected, in the origin thread. |
108 // | 111 // |
109 // Must be called in the origin thread. | 112 // Must be called in the origin thread. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 std::set<std::string> match_rules_; | 213 std::set<std::string> match_rules_; |
211 | 214 |
212 const bool ignore_service_unknown_errors_; | 215 const bool ignore_service_unknown_errors_; |
213 | 216 |
214 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); | 217 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); |
215 }; | 218 }; |
216 | 219 |
217 } // namespace dbus | 220 } // namespace dbus |
218 | 221 |
219 #endif // DBUS_OBJECT_PROXY_H_ | 222 #endif // DBUS_OBJECT_PROXY_H_ |
OLD | NEW |