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 |
11 #include <map> | 11 #include <map> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/string_piece.h" | 17 #include "base/string_piece.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "dbus/object_path.h" |
19 | 20 |
20 namespace dbus { | 21 namespace dbus { |
21 | 22 |
22 class Bus; | 23 class Bus; |
23 class MethodCall; | 24 class MethodCall; |
24 class Response; | 25 class Response; |
25 class Signal; | 26 class Signal; |
26 | 27 |
27 // ObjectProxy is used to communicate with remote objects, mainly for | 28 // ObjectProxy is used to communicate with remote objects, mainly for |
28 // calling methods of these objects. | 29 // calling methods of these objects. |
29 // | 30 // |
30 // 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 |
31 // object is is alive when callbacks referencing |this| are called. | 32 // object is is alive when callbacks referencing |this| are called. |
32 class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> { | 33 class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> { |
33 public: | 34 public: |
34 // Client code should use Bus::GetObjectProxy() or | 35 // Client code should use Bus::GetObjectProxy() or |
35 // Bus::GetObjectProxyWithOptions() instead of this constructor. | 36 // Bus::GetObjectProxyWithOptions() instead of this constructor. |
36 ObjectProxy(Bus* bus, | 37 ObjectProxy(Bus* bus, |
37 const std::string& service_name, | 38 const std::string& service_name, |
38 const std::string& object_path, | 39 const ObjectPath& object_path, |
39 int options); | 40 int options); |
40 | 41 |
41 // Options to be OR-ed together when calling Bus::GetObjectProxyWithOptions(). | 42 // Options to be OR-ed together when calling Bus::GetObjectProxyWithOptions(). |
42 // Set the IGNORE_SERVICE_UNKNOWN_ERRORS option to silence logging of | 43 // Set the IGNORE_SERVICE_UNKNOWN_ERRORS option to silence logging of |
43 // org.freedesktop.DBus.Error.ServiceUnknown errors. | 44 // org.freedesktop.DBus.Error.ServiceUnknown errors. |
44 enum Options { | 45 enum Options { |
45 DEFAULT_OPTIONS = 0, | 46 DEFAULT_OPTIONS = 0, |
46 IGNORE_SERVICE_UNKNOWN_ERRORS = 1 << 0 | 47 IGNORE_SERVICE_UNKNOWN_ERRORS = 1 << 0 |
47 }; | 48 }; |
48 | 49 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, | 190 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, |
190 DBusMessage* raw_message, | 191 DBusMessage* raw_message, |
191 void* user_data); | 192 void* user_data); |
192 | 193 |
193 // Helper method for logging response errors appropriately. | 194 // Helper method for logging response errors appropriately. |
194 void LogMethodCallFailure(const base::StringPiece& error_name, | 195 void LogMethodCallFailure(const base::StringPiece& error_name, |
195 const base::StringPiece& error_message) const; | 196 const base::StringPiece& error_message) const; |
196 | 197 |
197 scoped_refptr<Bus> bus_; | 198 scoped_refptr<Bus> bus_; |
198 std::string service_name_; | 199 std::string service_name_; |
199 std::string object_path_; | 200 ObjectPath object_path_; |
200 | 201 |
201 // True if the message filter was added. | 202 // True if the message filter was added. |
202 bool filter_added_; | 203 bool filter_added_; |
203 | 204 |
204 // The method table where keys are absolute signal names (i.e. interface | 205 // The method table where keys are absolute signal names (i.e. interface |
205 // name + signal name), and values are the corresponding callbacks. | 206 // name + signal name), and values are the corresponding callbacks. |
206 typedef std::map<std::string, SignalCallback> MethodTable; | 207 typedef std::map<std::string, SignalCallback> MethodTable; |
207 MethodTable method_table_; | 208 MethodTable method_table_; |
208 | 209 |
209 std::set<std::string> match_rules_; | 210 std::set<std::string> match_rules_; |
210 | 211 |
211 const bool ignore_service_unknown_errors_; | 212 const bool ignore_service_unknown_errors_; |
212 | 213 |
213 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); | 214 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); |
214 }; | 215 }; |
215 | 216 |
216 } // namespace dbus | 217 } // namespace dbus |
217 | 218 |
218 #endif // DBUS_OBJECT_PROXY_H_ | 219 #endif // DBUS_OBJECT_PROXY_H_ |
OLD | NEW |