| 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 | 13 |
| 14 namespace base { |
| 15 class MessageLoopProxy; |
| 16 } |
| 17 |
| 14 namespace dbus { | 18 namespace dbus { |
| 15 | 19 |
| 16 class Bus; | 20 class Bus; |
| 17 class ExportedObject; | 21 class ExportedObject; |
| 18 class MethodCall; | 22 class MethodCall; |
| 19 class Response; | 23 class Response; |
| 20 | 24 |
| 21 // 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 |
| 22 // 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 |
| 23 // the main thread. | 27 // the main thread. |
| 24 // | 28 // |
| 25 // 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 |
| 26 // SlowEcho(). The object has ability to send "Test" signal. | 30 // SlowEcho(). The object has ability to send "Test" signal. |
| 27 class TestService : public base::Thread { | 31 class TestService : public base::Thread { |
| 28 public: | 32 public: |
| 29 // Options for the test service. | 33 // Options for the test service. |
| 30 struct Options { | 34 struct Options { |
| 31 Options(); | 35 Options(); |
| 32 ~Options(); | 36 ~Options(); |
| 33 | 37 |
| 34 // NULL by default (i.e. don't use the D-Bus thread). | 38 // NULL by default (i.e. don't use the D-Bus thread). |
| 35 base::Thread* dbus_thread; | 39 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy; |
| 36 }; | 40 }; |
| 37 | 41 |
| 38 // The number of methods we'll export. | 42 // The number of methods we'll export. |
| 39 static const int kNumMethodsToExport; | 43 static const int kNumMethodsToExport; |
| 40 | 44 |
| 41 TestService(const Options& options); | 45 TestService(const Options& options); |
| 42 virtual ~TestService(); | 46 virtual ~TestService(); |
| 43 | 47 |
| 44 // Starts the service in a separate thread. | 48 // Starts the service in a separate thread. |
| 45 // Returns true if the thread is started successfully. | 49 // Returns true if the thread is started successfully. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Echos the text message received from the method call. | 84 // Echos the text message received from the method call. |
| 81 Response* Echo(MethodCall* method_call); | 85 Response* Echo(MethodCall* method_call); |
| 82 | 86 |
| 83 // Echos the text message received from the method call, but sleeps for | 87 // Echos the text message received from the method call, but sleeps for |
| 84 // TestTimeouts::tiny_timeout_ms() before returning the response. | 88 // TestTimeouts::tiny_timeout_ms() before returning the response. |
| 85 Response* SlowEcho(MethodCall* method_call); | 89 Response* SlowEcho(MethodCall* method_call); |
| 86 | 90 |
| 87 // Returns NULL, instead of a valid Response. | 91 // Returns NULL, instead of a valid Response. |
| 88 Response* BrokenMethod(MethodCall* method_call); | 92 Response* BrokenMethod(MethodCall* method_call); |
| 89 | 93 |
| 90 base::Thread* dbus_thread_; | 94 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_; |
| 91 base::WaitableEvent on_all_methods_exported_; | 95 base::WaitableEvent on_all_methods_exported_; |
| 92 // The number of methods actually exported. | 96 // The number of methods actually exported. |
| 93 int num_exported_methods_; | 97 int num_exported_methods_; |
| 94 | 98 |
| 95 scoped_refptr<Bus> bus_; | 99 scoped_refptr<Bus> bus_; |
| 96 ExportedObject* exported_object_; | 100 ExportedObject* exported_object_; |
| 97 }; | 101 }; |
| 98 | 102 |
| 99 } // namespace dbus | 103 } // namespace dbus |
| 100 | 104 |
| 101 #endif // DBUS_TEST_SERVICE_H_ | 105 #endif // DBUS_TEST_SERVICE_H_ |
| OLD | NEW |