This directory contains client libraries for communication with Chrome OS system service daemons over D-Bus.
For more information, see Chrome OS D-Bus Usage in Chrome.
The DBusThreadManager class was originally created to both own the D-Bus base::Thread, the system dbus::Bus instance, and all of the D-Bus clients.
With the significantly increased number of clients and upcoming Mash effort splitting Chrome and Ash into separate processes, this model no longer makes sense.
New clients should not be added to DBusThreadManager but instead should follow the pattern described below. DBusThreadManager will eventually be deprecated.
An example of a relatively simple client using existing patterns can be found in src/chromeos/dbus/kerberos.
Create a subdirectory under
src/chromeos/dbus for new clients or use an existing directory. Do not add new clients to this directory.
D-Bus clients should only be accessed by a single process, e.g. Chrome or Ash (preferably Ash), not both. Use a mojo interface to communicate between Chrome and Ash where necessary.
D-Bus clients are explicitly initialized and shut down. They provide a static getter for the single global instance. In Chrome, initialization occurs in dbus_helper.cc. In Ash it occurs in ash_service.cc.
For new clients, if test methods are required, create a
TestInterface in the base class with a virtual
GetTestInterface() method and implement it only in the fake (return null in the real implementation). See src/chromeos/dbus/kerberos for an example.
(Many existing clients provide additional test functionality in the fake implementation, however this complicates tests and the fake implementation).
Shill clients will eventually only be available to Chrome. As such, the DBusThreadManager::GetShill*Client() methods have been left intact for now. However, the clients are no longer owned by DBusThreadManager so that they can be initialized independently.
New code should prefer Shill*Client::Get() over the DBusThreadManager accessors.