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.
5 #ifndef CHROMEOS_DBUS_INTROSPECTABLE_CLIENT_H_
6 #define CHROMEOS_DBUS_INTROSPECTABLE_CLIENT_H_
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/dbus_client.h"
14 #include "chromeos/dbus/dbus_client_implementation_type.h"
15 #include "dbus/object_path.h"
19 // IntrospectableClient is used to retrieve the D-Bus introspection data
20 // from a remote object.
21 class CHROMEOS_EXPORT IntrospectableClient : public DBusClient {
23 virtual ~IntrospectableClient();
25 // The IntrospectCallback is used for the Introspect() method. It receives
26 // four arguments, the first two are the |service_name| and |object_path|
27 // of the remote object being introspected, the third is the |xml_data| of
28 // the object as described in
29 // http://dbus.freedesktop.org/doc/dbus-specification.html, the fourth
30 // |success| indicates whether the request succeeded.
31 typedef base::Callback<void(const std::string&, const dbus::ObjectPath&,
32 const std::string&, bool)> IntrospectCallback;
34 // Retrieves introspection data from the remote object on service name
35 // |service_name| with object path |object_path|, calling |callback| with
36 // the XML-formatted data received.
37 virtual void Introspect(const std::string& service_name,
38 const dbus::ObjectPath& object_path,
39 const IntrospectCallback& callback) = 0;
41 // Parses XML-formatted introspection data returned by
42 // org.freedesktop.DBus.Introspectable.Introspect and returns the list of
43 // interface names declared within.
44 static std::vector<std::string> GetInterfacesFromIntrospectResult(
45 const std::string& xml_data);
47 // Creates the instance
48 static IntrospectableClient* Create(DBusClientImplementationType type);
51 IntrospectableClient();
54 DISALLOW_COPY_AND_ASSIGN(IntrospectableClient);
57 } // namespace chromeos
59 #endif // CHROMEOS_DBUS_INTROSPECTABLE_CLIENT_H_