| 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" |
| 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 SequencedTaskRunner; | 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 MessageWriter; |
| 22 class Response; | 23 class Response; |
| 23 | 24 |
| 24 // 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 |
| 25 // 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 |
| 26 // the main thread. | 27 // the main thread. |
| 27 // | 28 // |
| 28 // 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 |
| 29 // SlowEcho(). The object has ability to send "Test" signal. | 30 // SlowEcho(). The object has ability to send "Test" signal. |
| 30 class TestService : public base::Thread { | 31 class TestService : public base::Thread { |
| 31 public: | 32 public: |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 dbus::ExportedObject::ResponseSender response_sender); | 128 dbus::ExportedObject::ResponseSender response_sender); |
| 128 | 129 |
| 129 // Returns a new value of 20 for the Version property when called. | 130 // Returns a new value of 20 for the Version property when called. |
| 130 void GetProperty(MethodCall* method_call, | 131 void GetProperty(MethodCall* method_call, |
| 131 dbus::ExportedObject::ResponseSender response_sender); | 132 dbus::ExportedObject::ResponseSender response_sender); |
| 132 | 133 |
| 133 // Allows the name property to be changed, errors otherwise. | 134 // Allows the name property to be changed, errors otherwise. |
| 134 void SetProperty(MethodCall* method_call, | 135 void SetProperty(MethodCall* method_call, |
| 135 dbus::ExportedObject::ResponseSender response_sender); | 136 dbus::ExportedObject::ResponseSender response_sender); |
| 136 | 137 |
| 138 // Performs an action for testing. |
| 139 void PerformAction(MethodCall* method_call, |
| 140 dbus::ExportedObject::ResponseSender response_sender); |
| 141 |
| 142 // Object Manager: returns the set of objects and properties. |
| 143 void GetManagedObjects(MethodCall* method_call, |
| 144 dbus::ExportedObject::ResponseSender response_sender); |
| 145 |
| 146 // Add a properties dictionary to a message writer. |
| 147 void AddPropertiesToWriter(MessageWriter* writer); |
| 148 |
| 149 // Add a new object to the manager. |
| 150 void AddObject(const dbus::ObjectPath& object_path); |
| 151 void AddObjectInternal(const dbus::ObjectPath& object_path); |
| 152 |
| 153 // Remove an object from the manager. |
| 154 void RemoveObject(const dbus::ObjectPath& object_path); |
| 155 void RemoveObjectInternal(const dbus::ObjectPath& object_path); |
| 156 |
| 137 // Sends a property changed signal for the name property. | 157 // Sends a property changed signal for the name property. |
| 138 void SendPropertyChangedSignal(const std::string& name); | 158 void SendPropertyChangedSignal(const std::string& name); |
| 139 | 159 |
| 140 // Helper function for SendPropertyChangedSignal(). | 160 // Helper function for SendPropertyChangedSignal(). |
| 141 void SendPropertyChangedSignalInternal(const std::string& name); | 161 void SendPropertyChangedSignalInternal(const std::string& name); |
| 142 | 162 |
| 143 // Helper function for RequestOwnership(). | 163 // Helper function for RequestOwnership(). |
| 144 void RequestOwnershipInternal(base::Callback<void(bool)> callback); | 164 void RequestOwnershipInternal(base::Callback<void(bool)> callback); |
| 145 | 165 |
| 146 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner_; | 166 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner_; |
| 147 base::WaitableEvent on_all_methods_exported_; | 167 base::WaitableEvent on_all_methods_exported_; |
| 148 // The number of methods actually exported. | 168 // The number of methods actually exported. |
| 149 int num_exported_methods_; | 169 int num_exported_methods_; |
| 150 | 170 |
| 151 // True iff this instance has successfully acquired the name ownership. | 171 // True iff this instance has successfully acquired the name ownership. |
| 152 bool has_ownership_; | 172 bool has_ownership_; |
| 153 | 173 |
| 154 scoped_refptr<Bus> bus_; | 174 scoped_refptr<Bus> bus_; |
| 155 ExportedObject* exported_object_; | 175 ExportedObject* exported_object_; |
| 176 ExportedObject* exported_object_manager_; |
| 156 }; | 177 }; |
| 157 | 178 |
| 158 } // namespace dbus | 179 } // namespace dbus |
| 159 | 180 |
| 160 #endif // DBUS_TEST_SERVICE_H_ | 181 #endif // DBUS_TEST_SERVICE_H_ |
| OLD | NEW |