summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-30 10:44:34 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-30 10:44:34 +0000
commitb6ebf078d2ada6bb2e226d58686cc9e7469b55fa (patch)
tree8598e241fc4cce76ad9158102df5df7f79327cb8
parent41e8daba7c80736e434a23164cf62e8999efe0b2 (diff)
downloadchromium_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
-rw-r--r--chrome/browser/chromeos/bluetooth/bluetooth_device.cc3
-rw-r--r--chrome/browser/chromeos/dbus/introspect_util.cc50
-rw-r--r--chrome/browser/chromeos/dbus/introspect_util.h22
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chromeos/DEPS1
-rw-r--r--chromeos/chromeos.gyp2
-rw-r--r--chromeos/dbus/introspectable_client.cc38
-rw-r--r--chromeos/dbus/introspectable_client.h6
-rw-r--r--chromeos/dbus/introspectable_client_unittest.cc (renamed from chrome/browser/chromeos/dbus/introspect_util_unittest.cc)6
10 files changed, 51 insertions, 80 deletions
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
index 051127c..e696d0d 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h"
#include "chrome/browser/chromeos/bluetooth/bluetooth_service_record.h"
#include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h"
-#include "chrome/browser/chromeos/dbus/introspect_util.h"
#include "chromeos/dbus/bluetooth_adapter_client.h"
#include "chromeos/dbus/bluetooth_agent_service_provider.h"
#include "chromeos/dbus/bluetooth_device_client.h"
@@ -354,7 +353,7 @@ void BluetoothDevice::OnIntrospect(ErrorCallback error_callback,
// device. Send appropraite Connect calls for each of those interfaces
// to connect all of the application protocols for this device.
std::vector<std::string> interfaces =
- GetInterfacesFromIntrospectResult(xml_data);
+ IntrospectableClient::GetInterfacesFromIntrospectResult(xml_data);
for (std::vector<std::string>::iterator iter = interfaces.begin();
iter != interfaces.end(); ++iter) {
diff --git a/chrome/browser/chromeos/dbus/introspect_util.cc b/chrome/browser/chromeos/dbus/introspect_util.cc
deleted file mode 100644
index 997fd7b..0000000
--- a/chrome/browser/chromeos/dbus/introspect_util.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/chromeos/dbus/introspect_util.h"
-
-#include "third_party/libxml/chromium/libxml_utils.h"
-
-namespace {
-
-// String constants used for parsing D-Bus Introspection XML data.
-const char kInterfaceNode[] = "interface";
-const char kInterfaceNameAttribute[] = "name";
-
-}
-
-namespace chromeos {
-
-std::vector<std::string> 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;
-}
-
-}
diff --git a/chrome/browser/chromeos/dbus/introspect_util.h b/chrome/browser/chromeos/dbus/introspect_util.h
deleted file mode 100644
index 93577c0..0000000
--- a/chrome/browser/chromeos/dbus/introspect_util.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2012 The Chromium 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 CHROME_BROWSER_CHROMEOS_DBUS_INTROSPECT_UTIL_H_
-#define CHROME_BROWSER_CHROMEOS_DBUS_INTROSPECT_UTIL_H_
-#pragma once
-
-#include <string>
-#include <vector>
-
-namespace chromeos {
-
-// Parses XML-formatted introspection data returned by
-// org.freedesktop.DBus.Introspectable.Introspect and returns the list of
-// interface names declared within.
-std::vector<std::string> GetInterfacesFromIntrospectResult(
- const std::string& xml_data);
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_DBUS_INTROSPECT_UTIL_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 2cefa45..6d8c643 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -476,8 +476,6 @@
'browser/chromeos/customization_document.h',
'browser/chromeos/dbus/cros_dbus_service.cc',
'browser/chromeos/dbus/cros_dbus_service.h',
- 'browser/chromeos/dbus/introspect_util.cc',
- 'browser/chromeos/dbus/introspect_util.h',
'browser/chromeos/dbus/proxy_resolution_service_provider.cc',
'browser/chromeos/dbus/proxy_resolution_service_provider.h',
'browser/chromeos/disks/disk_mount_manager.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index c866587..8c8e2ee 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1058,7 +1058,6 @@
'browser/chromeos/cros_settings_unittest.cc',
'browser/chromeos/customization_document_unittest.cc',
'browser/chromeos/dbus/cros_dbus_service_unittest.cc',
- 'browser/chromeos/dbus/introspect_util_unittest.cc',
'browser/chromeos/dbus/proxy_resolution_service_provider_unittest.cc',
'browser/chromeos/device_settings_provider_unittest.cc',
'browser/chromeos/extensions/file_browser_notifications_unittest.cc',
diff --git a/chromeos/DEPS b/chromeos/DEPS
index ffae1fe..3958c13 100644
--- a/chromeos/DEPS
+++ b/chromeos/DEPS
@@ -2,4 +2,5 @@ include_rules = [
"+net",
"+third_party/cros",
"+third_party/cros_system_api",
+ "+third_party/libxml",
]
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp
index 172af0c..97c6604 100644
--- a/chromeos/chromeos.gyp
+++ b/chromeos/chromeos.gyp
@@ -15,6 +15,7 @@
'../build/linux/system.gyp:dbus',
'../dbus/dbus.gyp:dbus',
'../net/net.gyp:net',
+ '../third_party/libxml/libxml.gyp:libxml',
'power_state_control_proto',
'power_supply_properties_proto',
],
@@ -193,6 +194,7 @@
'dbus/ibus/ibus_object_unittest.cc',
'dbus/ibus/ibus_text_unittest.cc',
'dbus/ibus/ibus_input_context_client_unittest.cc',
+ 'dbus/introspectable_client_unittest.cc',
'network/network_sms_handler_unittest.cc',
],
'include_dirs': [
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) {
diff --git a/chromeos/dbus/introspectable_client.h b/chromeos/dbus/introspectable_client.h
index c21eb94..c70bb6e 100644
--- a/chromeos/dbus/introspectable_client.h
+++ b/chromeos/dbus/introspectable_client.h
@@ -42,6 +42,12 @@ class CHROMEOS_EXPORT IntrospectableClient {
const dbus::ObjectPath& object_path,
const IntrospectCallback& callback) = 0;
+ // Parses XML-formatted introspection data returned by
+ // org.freedesktop.DBus.Introspectable.Introspect and returns the list of
+ // interface names declared within.
+ static std::vector<std::string> GetInterfacesFromIntrospectResult(
+ const std::string& xml_data);
+
// Creates the instance
static IntrospectableClient* Create(DBusClientImplementationType type,
dbus::Bus* bus);
diff --git a/chrome/browser/chromeos/dbus/introspect_util_unittest.cc b/chromeos/dbus/introspectable_client_unittest.cc
index 5d68ada..5e98b1c 100644
--- a/chrome/browser/chromeos/dbus/introspect_util_unittest.cc
+++ b/chromeos/dbus/introspectable_client_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/chromeos/dbus/introspect_util.h"
+#include "chromeos/dbus/introspectable_client.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -55,9 +55,9 @@ const char kXmlData[] =
namespace chromeos {
-TEST(IntrospectUtilTest, GetInterfacesFromIntrospectResult) {
+TEST(IntrospectableClientTest, GetInterfacesFromIntrospectResult) {
std::vector<std::string> interfaces =
- GetInterfacesFromIntrospectResult(kXmlData);
+ IntrospectableClient::GetInterfacesFromIntrospectResult(kXmlData);
ASSERT_EQ(3U, interfaces.size());
EXPECT_EQ("org.freedesktop.DBus.Introspectable", interfaces[0]);