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