summaryrefslogtreecommitdiffstats
path: root/dbus/bus.h
diff options
context:
space:
mode:
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-10 01:12:52 +0000
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-10 01:12:52 +0000
commit15e7b16ff24684e2678fe1b4964125b42a4c4018 (patch)
tree5f53e19b8a27e5af437e342d5464b110f4980a48 /dbus/bus.h
parent093fcf536f77186f754119854ab729e68c31f784 (diff)
downloadchromium_src-15e7b16ff24684e2678fe1b4964125b42a4c4018.zip
chromium_src-15e7b16ff24684e2678fe1b4964125b42a4c4018.tar.gz
chromium_src-15e7b16ff24684e2678fe1b4964125b42a4c4018.tar.bz2
dbus: remove service name from ExportedObject
Well-known names in D-Bus are merely aliases to unique connection ids maintained by the bus, they have no purpose in qualifying object paths or interfaces and it's perfectly legimiate for a client to make requests to the unique connection id (e.g. in response to a signal, which does not reference the well-known name of the origin connection). Remove the service_name member from dbus::ExportedObject, from its constructor and from dbus::Bus::GetExportedObject and require code to call dbus::Bus::RequestOwnership if a well-known name is desired. This requires making that function callable from the origin thread with a callback for the return value. BUG=chromium-os:27101 TEST=dbus_unittests Change-Id: Ib91de8b68ad9c3b432e224a2c715f0c2ca1af463 Review URL: http://codereview.chromium.org/9668018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125970 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/bus.h')
-rw-r--r--dbus/bus.h39
1 files changed, 31 insertions, 8 deletions
diff --git a/dbus/bus.h b/dbus/bus.h
index e045386..0cafd9e 100644
--- a/dbus/bus.h
+++ b/dbus/bus.h
@@ -176,6 +176,12 @@ class Bus : public base::RefCountedThreadSafe<Bus> {
// Connect() is called.
explicit Bus(const Options& options);
+ // Called when an ownership request is complete.
+ // Parameters:
+ // - the requested service name.
+ // - whether ownership has been obtained or not.
+ typedef base::Callback<void (const std::string&, bool)> OnOwnershipCallback;
+
// Gets the object proxy for the given service name and the object path.
// The caller must not delete the returned object.
//
@@ -204,12 +210,11 @@ class Bus : public base::RefCountedThreadSafe<Bus> {
const ObjectPath& object_path,
int options);
- // Gets the exported object for the given service name and the object
- // path. The caller must not delete the returned object.
+ // Gets the exported object for the given object path.
+ // The caller must not delete the returned object.
//
// Returns an existing exported object if the bus object already owns
- // the exported object for the given service name and the object path.
- // Never returns NULL.
+ // the exported object for the given object path. Never returns NULL.
//
// The bus will own all exported objects created by the bus, to ensure
// that the exported objects are unregistered at the shutdown time of
@@ -219,8 +224,7 @@ class Bus : public base::RefCountedThreadSafe<Bus> {
// send signal from them.
//
// Must be called in the origin thread.
- virtual ExportedObject* GetExportedObject(const std::string& service_name,
- const ObjectPath& object_path);
+ virtual ExportedObject* GetExportedObject(const ObjectPath& object_path);
// Shuts down the bus and blocks until it's done. More specifically, this
// function does the following:
@@ -255,11 +259,21 @@ class Bus : public base::RefCountedThreadSafe<Bus> {
// BLOCKING CALL.
virtual bool Connect();
+ // Requests the ownership of the service name given by |service_name|.
+ // See also RequestOwnershipAndBlock().
+ //
+ // |on_ownership_callback| is called when the service name is obtained
+ // or failed to be obtained, in the origin thread.
+ //
+ // Must be called in the origin thread.
+ virtual void RequestOwnership(const std::string& service_name,
+ OnOwnershipCallback on_ownership_callback);
+
// Requests the ownership of the given service name.
// Returns true on success, or the the service name is already obtained.
//
// BLOCKING CALL.
- virtual bool RequestOwnership(const std::string& service_name);
+ virtual bool RequestOwnershipAndBlock(const std::string& service_name);
// Releases the ownership of the given service name.
// Returns true on success.
@@ -409,6 +423,15 @@ class Bus : public base::RefCountedThreadSafe<Bus> {
// Helper function used for ShutdownOnDBusThreadAndBlock().
void ShutdownOnDBusThreadAndBlockInternal();
+ // Helper function used for RequestOwnership().
+ void RequestOwnershipInternal(const std::string& service_name,
+ OnOwnershipCallback on_ownership_callback);
+
+ // Called when the ownership request is completed.
+ void OnOwnership(OnOwnershipCallback on_ownership_callback,
+ const std::string& service_name,
+ bool success);
+
// Processes the all incoming data to the connection, if any.
//
// BLOCKING CALL.
@@ -478,7 +501,7 @@ class Bus : public base::RefCountedThreadSafe<Bus> {
// ExportedObjectTable is used to hold the exported objects created by
// the bus object. Key is a concatenated string of service name +
// object path, like "org.chromium.TestService/org/chromium/TestObject".
- typedef std::map<std::string,
+ typedef std::map<const dbus::ObjectPath,
scoped_refptr<dbus::ExportedObject> > ExportedObjectTable;
ExportedObjectTable exported_object_table_;