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

Side by Side Diff: dbus/test_service.h

Issue 8728020: chrome: dbus: support asynchronous method replies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment 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
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 #ifndef DBUS_TEST_SERVICE_H_ 5 #ifndef DBUS_TEST_SERVICE_H_
6 #define DBUS_TEST_SERVICE_H_ 6 #define DBUS_TEST_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "dbus/exported_object.h"
13 14
14 namespace base { 15 namespace base {
15 class MessageLoopProxy; 16 class MessageLoopProxy;
16 } 17 }
17 18
18 namespace dbus { 19 namespace dbus {
19 20
20 class Bus; 21 class Bus;
21 class ExportedObject;
22 class MethodCall; 22 class MethodCall;
23 class Response; 23 class Response;
24 24
25 // The test service is used for end-to-end tests. The service runs in a 25 // The test service is used for end-to-end tests. The service runs in a
26 // separate thread, so it does not interfere the test code that runs in 26 // separate thread, so it does not interfere the test code that runs in
27 // the main thread. 27 // the main thread.
28 // 28 //
29 // The test service exports an object with methods such as Echo() and 29 // The test service exports an object with methods such as Echo() and
30 // SlowEcho(). The object has ability to send "Test" signal. 30 // SlowEcho(). The object has ability to send "Test" signal.
31 class TestService : public base::Thread { 31 class TestService : public base::Thread {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 bool success); 82 bool success);
83 83
84 // base::Thread override. 84 // base::Thread override.
85 virtual void Run(MessageLoop* message_loop); 85 virtual void Run(MessageLoop* message_loop);
86 86
87 // 87 //
88 // Exported methods. 88 // Exported methods.
89 // 89 //
90 90
91 // Echos the text message received from the method call. 91 // Echos the text message received from the method call.
92 Response* Echo(MethodCall* method_call); 92 void Echo(MethodCall* method_call,
93 dbus::ExportedObject::ResponseSender response_sender);
93 94
94 // Echos the text message received from the method call, but sleeps for 95 // Echos the text message received from the method call, but sleeps for
95 // TestTimeouts::tiny_timeout_ms() before returning the response. 96 // TestTimeouts::tiny_timeout_ms() before returning the response.
96 Response* SlowEcho(MethodCall* method_call); 97 void SlowEcho(MethodCall* method_call,
98 dbus::ExportedObject::ResponseSender response_sender);
99
100 // Echos the text message received from the method call, but sends its
101 // response asynchronously after this callback has returned.
102 void AsyncEcho(MethodCall* method_call,
103 dbus::ExportedObject::ResponseSender response_sender);
97 104
98 // Returns NULL, instead of a valid Response. 105 // Returns NULL, instead of a valid Response.
99 Response* BrokenMethod(MethodCall* method_call); 106 void BrokenMethod(MethodCall* method_call,
107 dbus::ExportedObject::ResponseSender response_sender);
100 108
101 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_; 109 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_;
102 base::WaitableEvent on_all_methods_exported_; 110 base::WaitableEvent on_all_methods_exported_;
103 // The number of methods actually exported. 111 // The number of methods actually exported.
104 int num_exported_methods_; 112 int num_exported_methods_;
105 113
106 scoped_refptr<Bus> bus_; 114 scoped_refptr<Bus> bus_;
107 ExportedObject* exported_object_; 115 ExportedObject* exported_object_;
108 }; 116 };
109 117
110 } // namespace dbus 118 } // namespace dbus
111 119
112 #endif // DBUS_TEST_SERVICE_H_ 120 #endif // DBUS_TEST_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698