summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/sms_client.cc
diff options
context:
space:
mode:
authorpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 12:23:04 +0000
committerpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 12:23:04 +0000
commitc5fd536cbf85dea5a3bc200a515bdf6cf75b2576 (patch)
tree1f233003e6f5d34428c73b318a89454b7c7ee23b /chromeos/dbus/sms_client.cc
parent072414940357abff52558f794af018adfeb6f0d7 (diff)
downloadchromium_src-c5fd536cbf85dea5a3bc200a515bdf6cf75b2576.zip
chromium_src-c5fd536cbf85dea5a3bc200a515bdf6cf75b2576.tar.gz
chromium_src-c5fd536cbf85dea5a3bc200a515bdf6cf75b2576.tar.bz2
Split construction and initialization of DBus clients.
Before, each Client had a Create function which constructed an instance of the client and initialized it (with a dbus::Bus*). To make the Clients separately replaceable in the DBusThreadManager, it's necessary to separate the construction of the Clients from their initialization. This CL, splits each Create function into Create (which only calls the constructor of either the real Impl or the Stub) and Init(dbus::Bus*). This is a pure refactoring. BUG=275286 Review URL: https://chromiumcodereview.appspot.com/23119006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219775 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/sms_client.cc')
-rw-r--r--chromeos/dbus/sms_client.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/chromeos/dbus/sms_client.cc b/chromeos/dbus/sms_client.cc
index ee6fb04..cd867a5 100644
--- a/chromeos/dbus/sms_client.cc
+++ b/chromeos/dbus/sms_client.cc
@@ -31,7 +31,8 @@ namespace {
// DBusThreadManager instance.
class SMSClientImpl : public SMSClient {
public:
- explicit SMSClientImpl(dbus::Bus* bus) : bus_(bus), weak_ptr_factory_(this) {}
+ SMSClientImpl() : bus_(NULL), weak_ptr_factory_(this) {}
+
virtual ~SMSClientImpl() {}
// Calls GetAll method. |callback| is called after the method call succeeds.
@@ -49,6 +50,11 @@ class SMSClientImpl : public SMSClient {
callback));
}
+ protected:
+ virtual void Init(dbus::Bus* bus) OVERRIDE {
+ bus_ = bus;
+ }
+
private:
// Handles responses of GetAll method calls.
void OnGetAll(const GetAllCallback& callback, dbus::Response* response) {
@@ -84,6 +90,8 @@ class SMSClientStubImpl : public SMSClient {
SMSClientStubImpl() : weak_ptr_factory_(this) {}
virtual ~SMSClientStubImpl() {}
+ virtual void Init(dbus::Bus* bus) OVERRIDE {}
+
virtual void GetAll(const std::string& service_name,
const dbus::ObjectPath& object_path,
const GetAllCallback& callback) OVERRIDE {
@@ -131,10 +139,9 @@ SMSClient::~SMSClient() {}
// static
-SMSClient* SMSClient::Create(DBusClientImplementationType type,
- dbus::Bus* bus) {
+SMSClient* SMSClient::Create(DBusClientImplementationType type) {
if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) {
- return new SMSClientImpl(bus);
+ return new SMSClientImpl();
}
DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
return new SMSClientStubImpl();