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

Unified Diff: chromeos/dbus/fake_sms_client.cc

Issue 91373004: Move DBusClient stub implementations into separate files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years 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 | « chromeos/dbus/fake_sms_client.h ('k') | chromeos/dbus/introspectable_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/fake_sms_client.cc
diff --git a/chromeos/dbus/fake_sms_client.cc b/chromeos/dbus/fake_sms_client.cc
new file mode 100644
index 0000000000000000000000000000000000000000..eb3c8ab081a33d01396fc81122a4355729864d23
--- /dev/null
+++ b/chromeos/dbus/fake_sms_client.cc
@@ -0,0 +1,55 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback.h"
+#include "base/command_line.h"
+#include "base/location.h"
+#include "base/message_loop/message_loop.h"
+#include "base/values.h"
+#include "chromeos/chromeos_switches.h"
+#include "chromeos/dbus/fake_sms_client.h"
+#include "dbus/object_path.h"
+
+namespace chromeos {
+
+FakeSMSClient::FakeSMSClient() : weak_ptr_factory_(this) {}
+
+FakeSMSClient::~FakeSMSClient() {}
+
+void FakeSMSClient::Init(dbus::Bus* bus) {}
+
+void FakeSMSClient::GetAll(const std::string& service_name,
+ const dbus::ObjectPath& object_path,
+ const GetAllCallback& callback) {
+ 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", "FakeSMSClient: 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(&FakeSMSClient::OnGetAll,
+ weak_ptr_factory_.GetWeakPtr(),
+ base::Owned(sms),
+ callback));
+}
+
+void FakeSMSClient::OnGetAll(base::DictionaryValue* sms,
+ const GetAllCallback& callback) {
+ callback.Run(*sms);
+}
+
+} // namespace chromeos
« no previous file with comments | « chromeos/dbus/fake_sms_client.h ('k') | chromeos/dbus/introspectable_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698