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

Side by Side Diff: dbus/test_service.h

Issue 7830009: Add Bus::ShutdownOnDBusThreadAndBlock() and remove bus::Shutdown() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 3 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/mock_bus.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
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"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 virtual ~TestService(); 42 virtual ~TestService();
43 43
44 // Starts the service in a separate thread. 44 // Starts the service in a separate thread.
45 // Returns true if the thread is started successfully. 45 // Returns true if the thread is started successfully.
46 bool StartService(); 46 bool StartService();
47 47
48 // Waits until the service is started (i.e. all methods are exported). 48 // Waits until the service is started (i.e. all methods are exported).
49 // Returns true on success. 49 // Returns true on success.
50 bool WaitUntilServiceIsStarted() WARN_UNUSED_RESULT; 50 bool WaitUntilServiceIsStarted() WARN_UNUSED_RESULT;
51 51
52 // Shuts down the service. 52 // Shuts down the service and blocks until it's done.
53 void Shutdown(); 53 void ShutdownAndBlock();
54
55 // Waits until the service is shut down.
56 // Returns true on success.
57 bool WaitUntilServiceIsShutdown() WARN_UNUSED_RESULT;
58 54
59 // Returns true if the bus has the D-Bus thread. 55 // Returns true if the bus has the D-Bus thread.
60 bool HasDBusThread(); 56 bool HasDBusThread();
61 57
62 // Sends "Test" signal with the given message from the exported object. 58 // Sends "Test" signal with the given message from the exported object.
63 void SendTestSignal(const std::string& message); 59 void SendTestSignal(const std::string& message);
64 60
65 private: 61 private:
66 // Helper function for SendTestSignal(). 62 // Helper function for SendTestSignal().
67 void SendTestSignalInternal(const std::string& message); 63 void SendTestSignalInternal(const std::string& message);
68 64
69 // Helper function for Shutdown(). 65 // Helper function for ShutdownAndBlock().
70 void ShutdownInternal(); 66 void ShutdownAndBlockInternal();
71 67
72 // Called when a method is exported. 68 // Called when a method is exported.
73 void OnExported(const std::string& interface_name, 69 void OnExported(const std::string& interface_name,
74 const std::string& method_name, 70 const std::string& method_name,
75 bool success); 71 bool success);
76 72
77 // Called when the bus is shut down.
78 void OnShutdown();
79
80 // base::Thread override. 73 // base::Thread override.
81 virtual void Run(MessageLoop* message_loop); 74 virtual void Run(MessageLoop* message_loop);
82 75
83 // 76 //
84 // Exported methods. 77 // Exported methods.
85 // 78 //
86 79
87 // Echos the text message received from the method call. 80 // Echos the text message received from the method call.
88 Response* Echo(MethodCall* method_call); 81 Response* Echo(MethodCall* method_call);
89 82
90 // Echos the text message received from the method call, but sleeps for 83 // Echos the text message received from the method call, but sleeps for
91 // TestTimeouts::tiny_timeout_ms() before returning the response. 84 // TestTimeouts::tiny_timeout_ms() before returning the response.
92 Response* SlowEcho(MethodCall* method_call); 85 Response* SlowEcho(MethodCall* method_call);
93 86
94 // Returns NULL, instead of a valid Response. 87 // Returns NULL, instead of a valid Response.
95 Response* BrokenMethod(MethodCall* method_call); 88 Response* BrokenMethod(MethodCall* method_call);
96 89
97 base::Thread* dbus_thread_; 90 base::Thread* dbus_thread_;
98 base::WaitableEvent on_shutdown_;
99 base::WaitableEvent on_all_methods_exported_; 91 base::WaitableEvent on_all_methods_exported_;
100 // The number of methods actually exported. 92 // The number of methods actually exported.
101 int num_exported_methods_; 93 int num_exported_methods_;
102 94
103 scoped_refptr<Bus> bus_; 95 scoped_refptr<Bus> bus_;
104 ExportedObject* exported_object_; 96 ExportedObject* exported_object_;
105 }; 97 };
106 98
107 } // namespace dbus 99 } // namespace dbus
108 100
109 #endif // DBUS_TEST_SERVICE_H_ 101 #endif // DBUS_TEST_SERVICE_H_
OLDNEW
« no previous file with comments | « dbus/mock_bus.h ('k') | dbus/test_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698