Update V8 to version 4.7.3.
[chromium-blink-merge.git] / chromeos / dbus / fake_sms_client.cc
blob211e5c4544e0337de0705153e474c89f34147c5c
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.
5 #include <string>
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/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h"
14 #include "base/values.h"
15 #include "chromeos/chromeos_switches.h"
16 #include "chromeos/dbus/fake_sms_client.h"
17 #include "dbus/object_path.h"
19 namespace chromeos {
21 FakeSMSClient::FakeSMSClient() : weak_ptr_factory_(this) {}
23 FakeSMSClient::~FakeSMSClient() {}
25 void FakeSMSClient::Init(dbus::Bus* bus) {}
27 void FakeSMSClient::GetAll(const std::string& service_name,
28 const dbus::ObjectPath& object_path,
29 const GetAllCallback& callback) {
30 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
31 chromeos::switches::kSmsTestMessages))
32 return;
34 // Ownership passed to callback
35 base::DictionaryValue* sms = new base::DictionaryValue();
36 sms->SetString("Number", "000-000-0000");
37 sms->SetString("Text", "FakeSMSClient: Test Message: " + object_path.value());
38 sms->SetString("Timestamp", "Fri Jun 8 13:26:04 EDT 2012");
40 // Run callback asynchronously.
41 if (callback.is_null())
42 return;
43 base::ThreadTaskRunnerHandle::Get()->PostTask(
44 FROM_HERE,
45 base::Bind(&FakeSMSClient::OnGetAll, weak_ptr_factory_.GetWeakPtr(),
46 base::Owned(sms), callback));
49 void FakeSMSClient::OnGetAll(base::DictionaryValue* sms,
50 const GetAllCallback& callback) {
51 callback.Run(*sms);
54 } // namespace chromeos