OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__ |
7 | 7 |
8 // This class interfaces with DBus. The interface allows it to be mocked. | 8 // This class interfaces with DBus. The interface allows it to be mocked. |
9 | 9 |
| 10 #include <base/logging.h> |
10 #include <dbus/dbus-glib.h> | 11 #include <dbus/dbus-glib.h> |
11 | 12 |
12 namespace chromeos_update_engine { | 13 namespace chromeos_update_engine { |
13 | 14 |
14 class DbusGlibInterface { | 15 class DbusGlibInterface { |
15 public: | 16 public: |
16 // wraps dbus_g_proxy_new_for_name_owner | 17 // wraps dbus_g_proxy_new_for_name_owner |
17 virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection, | 18 virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection, |
18 const char* name, | 19 const char* name, |
19 const char* path, | 20 const char* path, |
20 const char* interface, | 21 const char* interface, |
21 GError** error) = 0; | 22 GError** error) = 0; |
22 | 23 |
23 // wraps g_object_unref | 24 // wraps g_object_unref |
24 virtual void ProxyUnref(DBusGProxy* proxy) = 0; | 25 virtual void ProxyUnref(DBusGProxy* proxy) = 0; |
25 | 26 |
26 // wraps dbus_g_bus_get | 27 // wraps dbus_g_bus_get |
27 virtual DBusGConnection* BusGet(DBusBusType type, GError** error) = 0; | 28 virtual DBusGConnection* BusGet(DBusBusType type, GError** error) = 0; |
28 | 29 |
29 // wraps dbus_g_proxy_call | 30 // wraps dbus_g_proxy_call |
30 virtual gboolean ProxyCall(DBusGProxy* proxy, | 31 virtual gboolean ProxyCall(DBusGProxy* proxy, |
31 const char* method, | 32 const char* method, |
32 GError** error, | 33 GError** error, |
33 GType first_arg_type, | 34 GType first_arg_type, |
34 GType var_arg1, | 35 GType var_arg1, |
35 GHashTable** var_arg2, | 36 GHashTable** var_arg2, |
36 GType var_arg3) = 0; | 37 GType var_arg3) = 0; |
| 38 |
| 39 virtual gboolean ProxyCall(DBusGProxy* proxy, |
| 40 const char* method, |
| 41 GError** error, |
| 42 GType var_arg1, const char* var_arg2, |
| 43 GType var_arg3, |
| 44 GType var_arg4, gchar** var_arg5, |
| 45 GType var_arg6, GArray** var_arg7, |
| 46 GType var_arg8) = 0; |
37 }; | 47 }; |
38 | 48 |
39 class ConcreteDbusGlib : public DbusGlibInterface { | 49 class ConcreteDbusGlib : public DbusGlibInterface { |
40 virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection, | 50 virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection, |
41 const char* name, | 51 const char* name, |
42 const char* path, | 52 const char* path, |
43 const char* interface, | 53 const char* interface, |
44 GError** error) { | 54 GError** error) { |
45 return dbus_g_proxy_new_for_name_owner(connection, | 55 return dbus_g_proxy_new_for_name_owner(connection, |
46 name, | 56 name, |
(...skipping 13 matching lines...) Expand all Loading... |
60 virtual gboolean ProxyCall(DBusGProxy* proxy, | 70 virtual gboolean ProxyCall(DBusGProxy* proxy, |
61 const char* method, | 71 const char* method, |
62 GError** error, | 72 GError** error, |
63 GType first_arg_type, | 73 GType first_arg_type, |
64 GType var_arg1, | 74 GType var_arg1, |
65 GHashTable** var_arg2, | 75 GHashTable** var_arg2, |
66 GType var_arg3) { | 76 GType var_arg3) { |
67 return dbus_g_proxy_call( | 77 return dbus_g_proxy_call( |
68 proxy, method, error, first_arg_type, var_arg1, var_arg2, var_arg3); | 78 proxy, method, error, first_arg_type, var_arg1, var_arg2, var_arg3); |
69 } | 79 } |
| 80 |
| 81 virtual gboolean ProxyCall(DBusGProxy* proxy, |
| 82 const char* method, |
| 83 GError** error, |
| 84 GType var_arg1, const char* var_arg2, |
| 85 GType var_arg3, |
| 86 GType var_arg4, gchar** var_arg5, |
| 87 GType var_arg6, GArray** var_arg7, |
| 88 GType var_arg8) { |
| 89 return dbus_g_proxy_call( |
| 90 proxy, method, error, var_arg1, var_arg2, var_arg3, |
| 91 var_arg4, var_arg5, var_arg6, var_arg7, var_arg8); |
| 92 } |
70 }; | 93 }; |
71 | 94 |
72 } // namespace chromeos_update_engine | 95 } // namespace chromeos_update_engine |
73 | 96 |
74 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__ | 97 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__ |
OLD | NEW |