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

Side by Side Diff: dbus/test_service.h

Issue 20555003: Allow Chromium's DBus service ownership to be stealable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nits Created 7 years, 4 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
« no previous file with comments | « dbus/signal_sender_verification_unittest.cc ('k') | dbus/test_service.cc » ('j') | 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) 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/bus.h"
12 #include "dbus/exported_object.h" 13 #include "dbus/exported_object.h"
13 14
14 namespace base { 15 namespace base {
15 class SequencedTaskRunner; 16 class SequencedTaskRunner;
16 } 17 }
17 18
18 namespace dbus { 19 namespace dbus {
19 20
20 class Bus;
21 class MethodCall; 21 class MethodCall;
22 class MessageWriter; 22 class MessageWriter;
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 {
32 public: 32 public:
33 // Options for the test service. 33 // Options for the test service.
34 struct Options { 34 struct Options {
35 Options(); 35 Options();
36 ~Options(); 36 ~Options();
37 37
38 // 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).
39 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner; 39 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner;
40
41 // Flags governing parameters of service ownership request.
42 Bus::ServiceOwnershipOptions request_ownership_options;
40 }; 43 };
41 44
42 // The number of methods we'll export. 45 // The number of methods we'll export.
43 static const int kNumMethodsToExport; 46 static const int kNumMethodsToExport;
44 47
45 explicit TestService(const Options& options); 48 explicit TestService(const Options& options);
46 virtual ~TestService(); 49 virtual ~TestService();
47 50
48 // Starts the service in a separate thread. 51 // Starts the service in a separate thread.
49 // Returns true if the thread is started successfully. 52 // Returns true if the thread is started successfully.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 159
157 // Sends a property changed signal for the name property. 160 // Sends a property changed signal for the name property.
158 void SendPropertyChangedSignal(const std::string& name); 161 void SendPropertyChangedSignal(const std::string& name);
159 162
160 // Helper function for SendPropertyChangedSignal(). 163 // Helper function for SendPropertyChangedSignal().
161 void SendPropertyChangedSignalInternal(const std::string& name); 164 void SendPropertyChangedSignalInternal(const std::string& name);
162 165
163 // Helper function for RequestOwnership(). 166 // Helper function for RequestOwnership().
164 void RequestOwnershipInternal(base::Callback<void(bool)> callback); 167 void RequestOwnershipInternal(base::Callback<void(bool)> callback);
165 168
169 // Options to use when requesting service ownership.
170 Bus::ServiceOwnershipOptions request_ownership_options_;
171
166 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner_; 172 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner_;
167 base::WaitableEvent on_all_methods_exported_; 173 base::WaitableEvent on_all_methods_exported_;
168 // The number of methods actually exported. 174 // The number of methods actually exported.
169 int num_exported_methods_; 175 int num_exported_methods_;
170 176
171 // True iff this instance has successfully acquired the name ownership. 177 // True iff this instance has successfully acquired the name ownership.
172 bool has_ownership_; 178 bool has_ownership_;
173 179
174 scoped_refptr<Bus> bus_; 180 scoped_refptr<Bus> bus_;
175 ExportedObject* exported_object_; 181 ExportedObject* exported_object_;
176 ExportedObject* exported_object_manager_; 182 ExportedObject* exported_object_manager_;
177 }; 183 };
178 184
179 } // namespace dbus 185 } // namespace dbus
180 186
181 #endif // DBUS_TEST_SERVICE_H_ 187 #endif // DBUS_TEST_SERVICE_H_
OLDNEW
« no previous file with comments | « dbus/signal_sender_verification_unittest.cc ('k') | dbus/test_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698