diff options
author | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 09:56:07 +0000 |
---|---|---|
committer | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 09:56:07 +0000 |
commit | 5d2cfdfe2bf4a5010fb00f8f03bf277d14f5641c (patch) | |
tree | fe66c4376e96a3f3e3392505c9a2b37b54571cdf /chromeos/dbus/sms_client.cc | |
parent | 13a350cc9d7ec3d4225f9d4966e0d3e58a3d77b6 (diff) | |
download | chromium_src-5d2cfdfe2bf4a5010fb00f8f03bf277d14f5641c.zip chromium_src-5d2cfdfe2bf4a5010fb00f8f03bf277d14f5641c.tar.gz chromium_src-5d2cfdfe2bf4a5010fb00f8f03bf277d14f5641c.tar.bz2 |
Move DBusClient stub implementations into separate files.
This allows to create these stubs directly without routing through the static Create() function in the client's interface.
BUG=275286
R=satorux@chromium.org
Review URL: https://codereview.chromium.org/91373004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238329 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/sms_client.cc')
-rw-r--r-- | chromeos/dbus/sms_client.cc | 52 |
1 files changed, 3 insertions, 49 deletions
diff --git a/chromeos/dbus/sms_client.cc b/chromeos/dbus/sms_client.cc index cd867a5..2e7b971 100644 --- a/chromeos/dbus/sms_client.cc +++ b/chromeos/dbus/sms_client.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/command_line.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" @@ -85,49 +86,6 @@ class SMSClientImpl : public SMSClient { DISALLOW_COPY_AND_ASSIGN(SMSClientImpl); }; -class SMSClientStubImpl : public SMSClient { - public: - 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 { - if (!CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kSmsTestMessages)) - return; - - // Ownership passed to callback - base::DictionaryValue *sms = new base::DictionaryValue(); - sms->SetString("Number", "000-000-0000"); - sms->SetString("Text", - "SMSClientStubImpl: Test Message: " + object_path.value()); - sms->SetString("Timestamp", "Fri Jun 8 13:26:04 EDT 2012"); - - // Run callback asynchronously. - if (callback.is_null()) - return; - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&SMSClientStubImpl::OnGetAll, - weak_ptr_factory_.GetWeakPtr(), - base::Owned(sms), - callback)); - } - - private: - void OnGetAll(base::DictionaryValue *sms, - const GetAllCallback& callback) { - callback.Run(*sms); - } - - base::WeakPtrFactory<SMSClientStubImpl> weak_ptr_factory_; - - DISALLOW_COPY_AND_ASSIGN(SMSClientStubImpl); -}; - } // namespace //////////////////////////////////////////////////////////////////////////////// @@ -139,12 +97,8 @@ SMSClient::~SMSClient() {} // static -SMSClient* SMSClient::Create(DBusClientImplementationType type) { - if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { - return new SMSClientImpl(); - } - DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); - return new SMSClientStubImpl(); +SMSClient* SMSClient::Create() { + return new SMSClientImpl(); } } // namespace chromeos |