diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-04 15:48:37 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-04 15:48:37 +0000 |
commit | 1db0b3573f76703384f4d3dc6a81930f04e81a63 (patch) | |
tree | 23e7666560dbda3237648642ab1a0bb28a7e7c92 /dbus/bus.h | |
parent | b80965554a11ef9d71df551c993e67a9ebe56cf9 (diff) | |
download | chromium_src-1db0b3573f76703384f4d3dc6a81930f04e81a63.zip chromium_src-1db0b3573f76703384f4d3dc6a81930f04e81a63.tar.gz chromium_src-1db0b3573f76703384f4d3dc6a81930f04e81a63.tar.bz2 |
Add a method to check if a D-Bus service has an owner. Use it for mtpd.
BUG=181064
Review URL: https://chromiumcodereview.appspot.com/14568005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/bus.h')
-rw-r--r-- | dbus/bus.h | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -161,6 +161,13 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> { 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 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> { // - 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 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> { // 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 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> { 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. |