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

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 memory management issue in ExportedObject::HandleMessage Created 9 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
« dbus/exported_object.cc ('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::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
OLDNEW
« dbus/exported_object.cc ('K') | « dbus/test_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698