OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "dbus/test_service.h" | 5 #include "dbus/test_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "dbus/bus.h" | 10 #include "dbus/bus.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 ++num_methods; | 156 ++num_methods; |
157 | 157 |
158 // Just print an error message as we don't want to crash tests. | 158 // Just print an error message as we don't want to crash tests. |
159 // Tests will fail at a call to WaitUntilServiceIsStarted(). | 159 // Tests will fail at a call to WaitUntilServiceIsStarted(). |
160 if (num_methods != kNumMethodsToExport) { | 160 if (num_methods != kNumMethodsToExport) { |
161 LOG(ERROR) << "The number of methods does not match"; | 161 LOG(ERROR) << "The number of methods does not match"; |
162 } | 162 } |
163 message_loop->Run(); | 163 message_loop->Run(); |
164 } | 164 } |
165 | 165 |
166 Response* TestService::Echo(MethodCall* method_call) { | 166 void TestService::Echo(MethodCall* method_call, |
| 167 dbus::ExportedObject::ResponseSender response_sender) { |
167 MessageReader reader(method_call); | 168 MessageReader reader(method_call); |
168 std::string text_message; | 169 std::string text_message; |
169 if (!reader.PopString(&text_message)) | 170 if (!reader.PopString(&text_message)) { |
170 return NULL; | 171 response_sender.Run(NULL); |
| 172 return; |
| 173 } |
171 | 174 |
172 Response* response = Response::FromMethodCall(method_call); | 175 Response* response = Response::FromMethodCall(method_call); |
173 MessageWriter writer(response); | 176 MessageWriter writer(response); |
174 writer.AppendString(text_message); | 177 writer.AppendString(text_message); |
175 return response; | 178 response_sender.Run(response); |
176 } | 179 } |
177 | 180 |
178 Response* TestService::SlowEcho(MethodCall* method_call) { | 181 void TestService::SlowEcho( |
| 182 MethodCall* method_call, |
| 183 dbus::ExportedObject::ResponseSender response_sender) { |
179 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); | 184 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); |
180 return Echo(method_call); | 185 Echo(method_call, response_sender); |
181 } | 186 } |
182 | 187 |
183 Response* TestService::BrokenMethod(MethodCall* method_call) { | 188 void TestService::BrokenMethod( |
184 return NULL; | 189 MethodCall* method_call, |
| 190 dbus::ExportedObject::ResponseSender response_sender) { |
| 191 response_sender.Run(NULL); |
185 } | 192 } |
186 | 193 |
187 } // namespace dbus | 194 } // namespace dbus |
OLD | NEW |