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

Side by Side Diff: chrome/browser/chromeos/dbus/introspect_util.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/dbus/introspect_util.h"
6
7 #include "third_party/libxml/chromium/libxml_utils.h"
8
9 namespace {
10
11 // String constants used for parsing D-Bus Introspection XML data.
12 const char kInterfaceNode[] = "interface";
13 const char kInterfaceNameAttribute[] = "name";
14
15 }
16
17 namespace chromeos {
18
19 std::vector<std::string> GetInterfacesFromIntrospectResult(
20 const std::string& xml_data) {
21 std::vector<std::string> interfaces;
22
23 XmlReader reader;
24 if (!reader.Load(xml_data))
25 return interfaces;
26
27 do {
28 // Skip to the next open tag, exit when done.
29 while (!reader.SkipToElement()) {
30 if (!reader.Read()) {
31 return interfaces;
32 }
33 }
34
35 // Only look at interface nodes.
36 if (reader.NodeName() != kInterfaceNode)
37 continue;
38
39 // Skip if missing the interface name.
40 std::string interface_name;
41 if (!reader.NodeAttribute(kInterfaceNameAttribute, &interface_name))
42 continue;
43
44 interfaces.push_back(interface_name);
45 } while (reader.Read());
46
47 return interfaces;
48 }
49
50 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/dbus/introspect_util.h ('k') | chrome/browser/chromeos/dbus/introspect_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698