Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: dbus_interface.h

Issue 4029002: AU: Don't use network on expensive connection types (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « SConstruct ('k') | flimflam_proxy.h » ('j') | flimflam_proxy.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus_interface.h
diff --git a/dbus_interface.h b/dbus_interface.h
new file mode 100644
index 0000000000000000000000000000000000000000..1b5c9536ce25a9580ada598745f2a34b8a6d2680
--- /dev/null
+++ b/dbus_interface.h
@@ -0,0 +1,74 @@
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__
+#define CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__
+
+// This class interfaces with DBus. The interface allows it to be mocked.
+
+#include <dbus/dbus-glib.h>
+
+namespace chromeos_update_engine {
+
+class DbusGlibInterface {
+ public:
+ // wraps dbus_g_proxy_new_for_name_owner
+ virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection,
+ const char* name,
+ const char* path,
+ const char* interface,
+ GError** error) = 0;
+
+ // wraps g_object_unref
+ virtual void ProxyUnref(DBusGProxy* proxy) = 0;
+
+ // wraps dbus_g_bus_get
+ virtual DBusGConnection* BusGet(DBusBusType type, GError** error) = 0;
+
+ // wraps dbus_g_proxy_call
+ virtual gboolean ProxyCall(DBusGProxy* proxy,
+ const char* method,
+ GError** error,
+ GType first_arg_type,
+ GType var_arg1,
+ GHashTable** var_arg2,
+ GType var_arg3) = 0;
+};
+
+class ConcreteDbusGlib : public DbusGlibInterface {
+ virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection,
+ const char* name,
+ const char* path,
+ const char* interface,
+ GError** error) {
+ return dbus_g_proxy_new_for_name_owner(connection,
+ name,
+ path,
+ interface,
+ error);
+ }
+
+ virtual void ProxyUnref(DBusGProxy* proxy) {
+ g_object_unref(proxy);
+ }
+
+ virtual DBusGConnection* BusGet(DBusBusType type, GError** error) {
+ return dbus_g_bus_get(type, error);
+ }
+
+ virtual gboolean ProxyCall(DBusGProxy* proxy,
+ const char* method,
+ GError** error,
+ GType first_arg_type,
+ GType var_arg1,
+ GHashTable** var_arg2,
+ GType var_arg3) {
+ return dbus_g_proxy_call(
+ proxy, method, error, first_arg_type, var_arg1, var_arg2, var_arg3);
+ }
+};
+
+} // namespace chromeos_update_engine
+
+#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__
« no previous file with comments | « SConstruct ('k') | flimflam_proxy.h » ('j') | flimflam_proxy.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698