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

Side by Side Diff: dbus/test_service.h

Issue 7491029: Implement Bus and ObjectProxy classes for our D-Bus library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another clang challenge Created 9 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/scoped_dbus_error.h ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DBUS_TEST_SERVICE_H_
6 #define DBUS_TEST_SERVICE_H_
7 #pragma once
8
9 #include "base/memory/ref_counted.h"
10 #include "base/threading/thread.h"
11 #include "base/synchronization/condition_variable.h"
12 #include "base/synchronization/lock.h"
13
14 namespace dbus {
15
16 class Bus;
17 class ExportedObject;
18 class MethodCall;
19 class Response;
20
21 // 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
23 // the main thread. Methods such as Echo() and SlowEcho() are exported.
24 class TestService : public base::Thread {
25 public:
26 // SlowEcho() sleeps for this period of time before returns.
27 static const int kSlowEchoSleepMs;
28
29 TestService();
30 virtual ~TestService();
31
32 // Starts the service in a separate thread.
33 void StartService();
34
35 // Waits until the service is started (i.e. methods are exported).
36 void WaitUntilServiceIsStarted();
37
38 private:
39 // Called when the service is started (i.e. the task is run from the
40 // message loop).
41 void OnServiceStarted();
42
43 // base::Thread override.
44 virtual void Run(MessageLoop* message_loop);
45
46 // base::Thread override.
47 virtual void CleanUp();
48
49 //
50 // Exported methods.
51 //
52
53 // Echos the text message received from the method call.
54 Response* Echo(MethodCall* method_call);
55
56 // Echos the text message received from the method call, but sleeps for
57 // kSlowEchoSleepMs before returning the response.
58 Response* SlowEcho(MethodCall* method_call);
59
60 // Returns NULL, instead of a valid Response.
61 Response* BrokenMethod(MethodCall* method_call);
62
63 bool service_started_;
64 base::Lock service_started_lock_;
65 base::ConditionVariable on_service_started_;
66
67 scoped_refptr<Bus> bus_;
68 ExportedObject* exported_object_;
69 };
70
71 } // namespace dbus
72
73 #endif // DBUS_TEST_SERVICE_H_
OLDNEW
« no previous file with comments | « dbus/scoped_dbus_error.h ('k') | dbus/test_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698