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

Unified Diff: chromeos/dbus/introspectable_client.cc

Issue 10440013: Move chromeos::GetInterfacesFromIntrospectResult into IntrospectableClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | « chromeos/dbus/introspectable_client.h ('k') | chromeos/dbus/introspectable_client_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/introspectable_client.cc
diff --git a/chromeos/dbus/introspectable_client.cc b/chromeos/dbus/introspectable_client.cc
index d29563f37acf6dbfa2311efa6b4b67c1498d4a78..5f666841a3623690ca65b937bd135a18db0473a5 100644
--- a/chromeos/dbus/introspectable_client.cc
+++ b/chromeos/dbus/introspectable_client.cc
@@ -13,6 +13,7 @@
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
+#include "third_party/libxml/chromium/libxml_utils.h"
namespace {
@@ -20,6 +21,10 @@ namespace {
const char kIntrospectableInterface[] = "org.freedesktop.DBus.Introspectable";
const char kIntrospect[] = "Introspect";
+// String constants used for parsing D-Bus Introspection XML data.
+const char kInterfaceNode[] = "interface";
+const char kInterfaceNameAttribute[] = "name";
+
} // namespace
namespace chromeos {
@@ -105,6 +110,39 @@ IntrospectableClient::~IntrospectableClient() {
}
// static
+std::vector<std::string>
+IntrospectableClient::GetInterfacesFromIntrospectResult(
+ const std::string& xml_data) {
+ std::vector<std::string> interfaces;
+
+ XmlReader reader;
+ if (!reader.Load(xml_data))
+ return interfaces;
+
+ do {
+ // Skip to the next open tag, exit when done.
+ while (!reader.SkipToElement()) {
+ if (!reader.Read()) {
+ return interfaces;
+ }
+ }
+
+ // Only look at interface nodes.
+ if (reader.NodeName() != kInterfaceNode)
+ continue;
+
+ // Skip if missing the interface name.
+ std::string interface_name;
+ if (!reader.NodeAttribute(kInterfaceNameAttribute, &interface_name))
+ continue;
+
+ interfaces.push_back(interface_name);
+ } while (reader.Read());
+
+ return interfaces;
+}
+
+// static
IntrospectableClient* IntrospectableClient::Create(
DBusClientImplementationType type,
dbus::Bus* bus) {
« no previous file with comments | « chromeos/dbus/introspectable_client.h ('k') | chromeos/dbus/introspectable_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698