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

Side by Side Diff: dbus/test_service.cc

Issue 8637002: chrome: dbus: support asynchronous method replies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix MethodCallCallback in bus.h comments to have void return type Created 9 years, 1 month 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
« dbus/exported_object.h ('K') | « dbus/test_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::SendResponseCallback send_response_cb) {
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 send_response_cb.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 send_response_cb.Run(response);
176 } 179 }
177 180
178 Response* TestService::SlowEcho(MethodCall* method_call) { 181 void TestService::SlowEcho(MethodCall* method_call,
182 dbus::ExportedObject::SendResponseCallback send_response_cb) {
179 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); 183 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms());
180 return Echo(method_call); 184 Echo(method_call, send_response_cb);
181 } 185 }
182 186
183 Response* TestService::BrokenMethod(MethodCall* method_call) { 187 void TestService::BrokenMethod(MethodCall* method_call,
184 return NULL; 188 dbus::ExportedObject::SendResponseCallback send_response_cb) {
189 send_response_cb.Run(NULL);
185 } 190 }
186 191
187 } // namespace dbus 192 } // namespace dbus
OLDNEW
« dbus/exported_object.h ('K') | « dbus/test_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698