OLD | NEW |
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" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 // Sends "Test" signal with the given message from the root object ("/"). | 68 // Sends "Test" signal with the given message from the root object ("/"). |
69 // This function emulates dbus-send's behavior. | 69 // This function emulates dbus-send's behavior. |
70 void SendTestSignalFromRoot(const std::string& message); | 70 void SendTestSignalFromRoot(const std::string& message); |
71 | 71 |
72 // Request the ownership of a well-known name "TestService". | 72 // Request the ownership of a well-known name "TestService". |
73 // |callback| will be called with the result when an ownership request is | 73 // |callback| will be called with the result when an ownership request is |
74 // completed. | 74 // completed. |
75 void RequestOwnership(base::Callback<void(bool)> callback); | 75 void RequestOwnership(base::Callback<void(bool)> callback); |
76 | 76 |
| 77 // Release the ownership of the well-known name "TestService". |
| 78 // |callback| will be called when the ownership has been released. |
| 79 void ReleaseOwnership(base::Closure callback); |
| 80 |
77 // Returns whether this instance has the name ownership or not. | 81 // Returns whether this instance has the name ownership or not. |
78 bool has_ownership() const { return has_ownership_; } | 82 bool has_ownership() const { return has_ownership_; } |
79 | 83 |
80 private: | 84 private: |
81 // Helper function for SendTestSignal(). | 85 // Helper function for SendTestSignal(). |
82 void SendTestSignalInternal(const std::string& message); | 86 void SendTestSignalInternal(const std::string& message); |
83 | 87 |
84 // Helper function for SendTestSignalFromRoot. | 88 // Helper function for SendTestSignalFromRoot. |
85 void SendTestSignalFromRootInternal(const std::string& message); | 89 void SendTestSignalFromRootInternal(const std::string& message); |
86 | 90 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 163 |
160 // Sends a property changed signal for the name property. | 164 // Sends a property changed signal for the name property. |
161 void SendPropertyChangedSignal(const std::string& name); | 165 void SendPropertyChangedSignal(const std::string& name); |
162 | 166 |
163 // Helper function for SendPropertyChangedSignal(). | 167 // Helper function for SendPropertyChangedSignal(). |
164 void SendPropertyChangedSignalInternal(const std::string& name); | 168 void SendPropertyChangedSignalInternal(const std::string& name); |
165 | 169 |
166 // Helper function for RequestOwnership(). | 170 // Helper function for RequestOwnership(). |
167 void RequestOwnershipInternal(base::Callback<void(bool)> callback); | 171 void RequestOwnershipInternal(base::Callback<void(bool)> callback); |
168 | 172 |
| 173 // Helper function for ReleaseOwnership(). |
| 174 void ReleaseOwnershipInternal(base::Closure callback); |
| 175 |
| 176 // Sends the response on completion of the performed action. |
| 177 void PerformActionResponse( |
| 178 MethodCall* method_call, |
| 179 dbus::ExportedObject::ResponseSender response_sender); |
| 180 |
| 181 // Re-requests ownership of the well-known name after releasing it. |
| 182 void OwnershipReleased( |
| 183 MethodCall* method_call, |
| 184 dbus::ExportedObject::ResponseSender response_sender); |
| 185 |
| 186 // Sends the action response after regaining the well-known name. |
| 187 void OwnershipRegained( |
| 188 MethodCall* method_call, |
| 189 dbus::ExportedObject::ResponseSender response_sender, |
| 190 bool success); |
| 191 |
169 // Options to use when requesting service ownership. | 192 // Options to use when requesting service ownership. |
170 Bus::ServiceOwnershipOptions request_ownership_options_; | 193 Bus::ServiceOwnershipOptions request_ownership_options_; |
171 | 194 |
172 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner_; | 195 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner_; |
173 base::WaitableEvent on_name_obtained_; | 196 base::WaitableEvent on_name_obtained_; |
174 // The number of methods actually exported. | 197 // The number of methods actually exported. |
175 int num_exported_methods_; | 198 int num_exported_methods_; |
176 | 199 |
177 // True iff this instance has successfully acquired the name ownership. | 200 // True iff this instance has successfully acquired the name ownership. |
178 bool has_ownership_; | 201 bool has_ownership_; |
179 | 202 |
180 scoped_refptr<Bus> bus_; | 203 scoped_refptr<Bus> bus_; |
181 ExportedObject* exported_object_; | 204 ExportedObject* exported_object_; |
182 ExportedObject* exported_object_manager_; | 205 ExportedObject* exported_object_manager_; |
183 }; | 206 }; |
184 | 207 |
185 } // namespace dbus | 208 } // namespace dbus |
186 | 209 |
187 #endif // DBUS_TEST_SERVICE_H_ | 210 #endif // DBUS_TEST_SERVICE_H_ |
OLD | NEW |