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

Unified Diff: dbus/bus.h

Issue 14568005: Add a method to check if a D-Bus service has an owner. Use it for mtpd. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros compile Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dbus/bus.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | dbus/bus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698