OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/memory/ptr_util.h" |
9 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
11 #include "chromeos/dbus/fake_gsm_sms_client.h" | 14 #include "chromeos/dbus/fake_gsm_sms_client.h" |
12 | 15 |
13 namespace chromeos { | 16 namespace chromeos { |
14 | 17 |
15 FakeGsmSMSClient::FakeGsmSMSClient() | 18 FakeGsmSMSClient::FakeGsmSMSClient() |
16 : test_index_(-1), | 19 : test_index_(-1), |
17 sms_test_message_switch_present_(false), | 20 sms_test_message_switch_present_(false), |
18 weak_ptr_factory_(this) { | 21 weak_ptr_factory_(this) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 const int kSmsMessageDelaySeconds = 5; | 99 const int kSmsMessageDelaySeconds = 5; |
97 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 100 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
98 FROM_HERE, base::Bind(&FakeGsmSMSClient::PushTestMessageChain, | 101 FROM_HERE, base::Bind(&FakeGsmSMSClient::PushTestMessageChain, |
99 weak_ptr_factory_.GetWeakPtr()), | 102 weak_ptr_factory_.GetWeakPtr()), |
100 base::TimeDelta::FromSeconds(kSmsMessageDelaySeconds)); | 103 base::TimeDelta::FromSeconds(kSmsMessageDelaySeconds)); |
101 } | 104 } |
102 | 105 |
103 bool FakeGsmSMSClient::PushTestMessage() { | 106 bool FakeGsmSMSClient::PushTestMessage() { |
104 if (test_index_ >= static_cast<int>(test_messages_.size())) | 107 if (test_index_ >= static_cast<int>(test_messages_.size())) |
105 return false; | 108 return false; |
106 base::DictionaryValue* message = new base::DictionaryValue; | 109 auto message = base::MakeUnique<base::DictionaryValue>(); |
107 message->SetString("number", "000-000-0000"); | 110 message->SetString("number", "000-000-0000"); |
108 message->SetString("text", test_messages_[test_index_]); | 111 message->SetString("text", test_messages_[test_index_]); |
109 message->SetInteger("index", test_index_); | 112 message->SetInteger("index", test_index_); |
110 int msg_index = message_list_.GetSize(); | 113 int msg_index = message_list_.GetSize(); |
111 message_list_.Append(message); | 114 message_list_.Append(std::move(message)); |
112 if (!handler_.is_null()) | 115 if (!handler_.is_null()) |
113 handler_.Run(msg_index, true); | 116 handler_.Run(msg_index, true); |
114 ++test_index_; | 117 ++test_index_; |
115 return true; | 118 return true; |
116 } | 119 } |
117 | 120 |
118 } // namespace chromeos | 121 } // namespace chromeos |
OLD | NEW |