Index: dbus/bus.h |
=================================================================== |
--- dbus/bus.h (revision 197465) |
+++ dbus/bus.h (working copy) |
@@ -161,6 +161,13 @@ |
SHARED, |
}; |
+ // Specifies whether the GetServiceOwnerAndBlock call should report or |
+ // suppress errors. |
+ enum GetServiceOwnerOption { |
+ REPORT_ERRORS, |
+ SUPPRESS_ERRORS, |
+ }; |
+ |
// Options used to create a Bus object. |
struct CHROME_DBUS_EXPORT Options { |
Options(); |
@@ -211,6 +218,12 @@ |
// - the requested service name. |
// - whether ownership has been obtained or not. |
typedef base::Callback<void (const std::string&, bool)> OnOwnershipCallback; |
+ |
+ // Called when GetServiceOwner() completes. |
+ // |service_owner| is the return value from GetServiceOwnerAndBlock(). |
+ typedef base::Callback<void (const std::string& service_owner)> |
+ GetServiceOwnerCallback; |
+ |
// TODO(satorux): Remove the service name parameter as the caller of |
// RequestOwnership() knows the service name. |
@@ -530,6 +543,19 @@ |
// AssertOnOriginThread(). |
virtual void AssertOnDBusThread(); |
+ // Gets the owner for |service_name| via org.freedesktop.DBus.GetNameOwner. |
+ // Returns the owner name, if any, or an empty string on failure. |
+ // |options| specifies where to printing error messages or not. |
+ // |
+ // BLOCKING CALL. |
+ virtual std::string GetServiceOwnerAndBlock(const std::string& service_name, |
+ GetServiceOwnerOption options); |
+ |
+ // A non-blocking version of GetServiceOwnerAndBlock(). |
+ // Must be called in the origin thread. |
+ virtual void GetServiceOwner(const std::string& service_name, |
+ const GetServiceOwnerCallback& callback); |
+ |
// Returns true if the bus is connected to D-Bus. |
bool is_connected() { return connection_ != NULL; } |
@@ -555,6 +581,10 @@ |
void RequestOwnershipInternal(const std::string& service_name, |
OnOwnershipCallback on_ownership_callback); |
+ // Helper function used for GetServiceOwner(). |
+ void GetServiceOwnerInternal(const std::string& service_name, |
+ const GetServiceOwnerCallback& callback); |
+ |
// Processes the all incoming data to the connection, if any. |
// |
// BLOCKING CALL. |