| 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 #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 Loading... |
| 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); |
| 97 | 99 |
| 98 // Returns NULL, instead of a valid Response. | 100 // Returns NULL, instead of a valid Response. |
| 99 Response* BrokenMethod(MethodCall* method_call); | 101 void BrokenMethod(MethodCall* method_call, |
| 102 dbus::ExportedObject::ResponseSender response_sender); |
| 100 | 103 |
| 101 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_; | 104 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_; |
| 102 base::WaitableEvent on_all_methods_exported_; | 105 base::WaitableEvent on_all_methods_exported_; |
| 103 // The number of methods actually exported. | 106 // The number of methods actually exported. |
| 104 int num_exported_methods_; | 107 int num_exported_methods_; |
| 105 | 108 |
| 106 scoped_refptr<Bus> bus_; | 109 scoped_refptr<Bus> bus_; |
| 107 ExportedObject* exported_object_; | 110 ExportedObject* exported_object_; |
| 108 }; | 111 }; |
| 109 | 112 |
| 110 } // namespace dbus | 113 } // namespace dbus |
| 111 | 114 |
| 112 #endif // DBUS_TEST_SERVICE_H_ | 115 #endif // DBUS_TEST_SERVICE_H_ |
| OLD | NEW |