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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/fake_sms_client.h ('k') | chromeos/dbus/introspectable_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/callback.h"
10 #include "base/command_line.h"
11 #include "base/location.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/values.h"
14 #include "chromeos/chromeos_switches.h"
15 #include "chromeos/dbus/fake_sms_client.h"
16 #include "dbus/object_path.h"
17
18 namespace chromeos {
19
20 FakeSMSClient::FakeSMSClient() : weak_ptr_factory_(this) {}
21
22 FakeSMSClient::~FakeSMSClient() {}
23
24 void FakeSMSClient::Init(dbus::Bus* bus) {}
25
26 void FakeSMSClient::GetAll(const std::string& service_name,
27 const dbus::ObjectPath& object_path,
28 const GetAllCallback& callback) {
29 if (!CommandLine::ForCurrentProcess()->HasSwitch(
30 chromeos::switches::kSmsTestMessages))
31 return;
32
33 // Ownership passed to callback
34 base::DictionaryValue* sms = new base::DictionaryValue();
35 sms->SetString("Number", "000-000-0000");
36 sms->SetString("Text", "FakeSMSClient: Test Message: " + object_path.value());
37 sms->SetString("Timestamp", "Fri Jun 8 13:26:04 EDT 2012");
38
39 // Run callback asynchronously.
40 if (callback.is_null())
41 return;
42 base::MessageLoop::current()->PostTask(
43 FROM_HERE,
44 base::Bind(&FakeSMSClient::OnGetAll,
45 weak_ptr_factory_.GetWeakPtr(),
46 base::Owned(sms),
47 callback));
48 }
49
50 void FakeSMSClient::OnGetAll(base::DictionaryValue* sms,
51 const GetAllCallback& callback) {
52 callback.Run(*sms);
53 }
54
55 } // namespace chromeos
OLDNEW
« 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