diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 10:44:34 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 10:44:34 +0000 |
commit | b6ebf078d2ada6bb2e226d58686cc9e7469b55fa (patch) | |
tree | 8598e241fc4cce76ad9158102df5df7f79327cb8 /chromeos/dbus/introspectable_client.cc | |
parent | 41e8daba7c80736e434a23164cf62e8999efe0b2 (diff) | |
download | chromium_src-b6ebf078d2ada6bb2e226d58686cc9e7469b55fa.zip chromium_src-b6ebf078d2ada6bb2e226d58686cc9e7469b55fa.tar.gz chromium_src-b6ebf078d2ada6bb2e226d58686cc9e7469b55fa.tar.bz2 |
Move chromeos::GetInterfacesFromIntrospectResult into IntrospectableClient
Since XmlReader was moved from chrome/ to third_party/libxml/, now chromeos/ can depend on it.
BUG=119583
TEST=chromeos_unittests
Review URL: https://chromiumcodereview.appspot.com/10440013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/introspectable_client.cc')
-rw-r--r-- | chromeos/dbus/introspectable_client.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/chromeos/dbus/introspectable_client.cc b/chromeos/dbus/introspectable_client.cc index d29563f..5f66684 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) { |