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

Side by Side Diff: dbus/test_service.h

Issue 12255043: DBus: Use TaskRunners instead of MessageLoopProxies. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 7 years, 10 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "dbus/exported_object.h" 12 #include "dbus/exported_object.h"
13 13
14 namespace base { 14 namespace base {
15 class MessageLoopProxy; 15 class SequencedTaskRunner;
16 } 16 }
17 17
18 namespace dbus { 18 namespace dbus {
19 19
20 class Bus; 20 class Bus;
21 class MethodCall; 21 class MethodCall;
22 class Response; 22 class Response;
23 23
24 // The test service is used for end-to-end tests. The service runs in a 24 // The test service is used for end-to-end tests. The service runs in a
25 // separate thread, so it does not interfere the test code that runs in 25 // separate thread, so it does not interfere the test code that runs in
26 // the main thread. 26 // the main thread.
27 // 27 //
28 // The test service exports an object with methods such as Echo() and 28 // The test service exports an object with methods such as Echo() and
29 // SlowEcho(). The object has ability to send "Test" signal. 29 // SlowEcho(). The object has ability to send "Test" signal.
30 class TestService : public base::Thread { 30 class TestService : public base::Thread {
31 public: 31 public:
32 // Options for the test service. 32 // Options for the test service.
33 struct Options { 33 struct Options {
34 Options(); 34 Options();
35 ~Options(); 35 ~Options();
36 36
37 // NULL by default (i.e. don't use the D-Bus thread). 37 // NULL by default (i.e. don't use the D-Bus thread).
38 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy; 38 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner;
39 }; 39 };
40 40
41 // The number of methods we'll export. 41 // The number of methods we'll export.
42 static const int kNumMethodsToExport; 42 static const int kNumMethodsToExport;
43 43
44 TestService(const Options& options); 44 explicit TestService(const Options& options);
45 virtual ~TestService(); 45 virtual ~TestService();
46 46
47 // Starts the service in a separate thread. 47 // Starts the service in a separate thread.
48 // Returns true if the thread is started successfully. 48 // Returns true if the thread is started successfully.
49 bool StartService(); 49 bool StartService();
50 50
51 // Waits until the service is started (i.e. all methods are exported). 51 // Waits until the service is started (i.e. all methods are exported).
52 // Returns true on success. 52 // Returns true on success.
53 bool WaitUntilServiceIsStarted() WARN_UNUSED_RESULT; 53 bool WaitUntilServiceIsStarted() WARN_UNUSED_RESULT;
54 54
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 // Sends a property changed signal for the name property. 137 // Sends a property changed signal for the name property.
138 void SendPropertyChangedSignal(const std::string& name); 138 void SendPropertyChangedSignal(const std::string& name);
139 139
140 // Helper function for SendPropertyChangedSignal(). 140 // Helper function for SendPropertyChangedSignal().
141 void SendPropertyChangedSignalInternal(const std::string& name); 141 void SendPropertyChangedSignalInternal(const std::string& name);
142 142
143 // Helper function for RequestOwnership(). 143 // Helper function for RequestOwnership().
144 void RequestOwnershipInternal(base::Callback<void(bool)> callback); 144 void RequestOwnershipInternal(base::Callback<void(bool)> callback);
145 145
146 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_; 146 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner_;
147 base::WaitableEvent on_all_methods_exported_; 147 base::WaitableEvent on_all_methods_exported_;
148 // The number of methods actually exported. 148 // The number of methods actually exported.
149 int num_exported_methods_; 149 int num_exported_methods_;
150 150
151 // True iff this instance has successfully acquired the name ownership. 151 // True iff this instance has successfully acquired the name ownership.
152 bool has_ownership_; 152 bool has_ownership_;
153 153
154 scoped_refptr<Bus> bus_; 154 scoped_refptr<Bus> bus_;
155 ExportedObject* exported_object_; 155 ExportedObject* exported_object_;
156 }; 156 };
157 157
158 } // namespace dbus 158 } // namespace dbus
159 159
160 #endif // DBUS_TEST_SERVICE_H_ 160 #endif // DBUS_TEST_SERVICE_H_
OLDNEW
« dbus/mock_bus.cc ('K') | « dbus/test_server.cc ('k') | dbus/test_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698