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 CHROMEOS_DBUS_SHILL_CLIENT_HELPER_H_ | 5 #ifndef CHROMEOS_DBUS_SHILL_CLIENT_HELPER_H_ |
6 #define CHROMEOS_DBUS_SHILL_CLIENT_HELPER_H_ | 6 #define CHROMEOS_DBUS_SHILL_CLIENT_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 ShillClientHelper(dbus::Bus* bus, dbus::ObjectProxy* proxy); | 65 ShillClientHelper(dbus::Bus* bus, dbus::ObjectProxy* proxy); |
66 | 66 |
67 virtual ~ShillClientHelper(); | 67 virtual ~ShillClientHelper(); |
68 | 68 |
69 // Adds an |observer| of the PropertyChanged signal. | 69 // Adds an |observer| of the PropertyChanged signal. |
70 void AddPropertyChangedObserver(ShillPropertyChangedObserver* observer); | 70 void AddPropertyChangedObserver(ShillPropertyChangedObserver* observer); |
71 | 71 |
72 // Removes an |observer| of the PropertyChanged signal. | 72 // Removes an |observer| of the PropertyChanged signal. |
73 void RemovePropertyChangedObserver(ShillPropertyChangedObserver* observer); | 73 void RemovePropertyChangedObserver(ShillPropertyChangedObserver* observer); |
74 | 74 |
75 // Starts monitoring PropertyChanged signal. | 75 // Starts monitoring PropertyChanged signal. If there aren't observers for the |
| 76 // PropertyChanged signal, the actual monitoring will be delayed until the |
| 77 // first observer is added. |
76 void MonitorPropertyChanged(const std::string& interface_name); | 78 void MonitorPropertyChanged(const std::string& interface_name); |
77 | 79 |
78 // Calls a method without results. | 80 // Calls a method without results. |
79 void CallVoidMethod(dbus::MethodCall* method_call, | 81 void CallVoidMethod(dbus::MethodCall* method_call, |
80 const VoidDBusMethodCallback& callback); | 82 const VoidDBusMethodCallback& callback); |
81 | 83 |
82 // Calls a method with an object path result. | 84 // Calls a method with an object path result. |
83 void CallObjectPathMethod(dbus::MethodCall* method_call, | 85 void CallObjectPathMethod(dbus::MethodCall* method_call, |
84 const ObjectPathDBusMethodCallback& callback); | 86 const ObjectPathDBusMethodCallback& callback); |
85 | 87 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // This method returns NULL when method call fails. | 120 // This method returns NULL when method call fails. |
119 base::DictionaryValue* CallDictionaryValueMethodAndBlock( | 121 base::DictionaryValue* CallDictionaryValueMethodAndBlock( |
120 dbus::MethodCall* method_call); | 122 dbus::MethodCall* method_call); |
121 | 123 |
122 // Appends the value (basic types and string-to-string dictionary) to the | 124 // Appends the value (basic types and string-to-string dictionary) to the |
123 // writer as a variant. | 125 // writer as a variant. |
124 static void AppendValueDataAsVariant(dbus::MessageWriter* writer, | 126 static void AppendValueDataAsVariant(dbus::MessageWriter* writer, |
125 const base::Value& value); | 127 const base::Value& value); |
126 | 128 |
127 private: | 129 private: |
| 130 // Starts monitoring PropertyChanged signal. |
| 131 void MonitorPropertyChangedInternal(const std::string& interface_name); |
| 132 |
128 // Handles the result of signal connection setup. | 133 // Handles the result of signal connection setup. |
129 void OnSignalConnected(const std::string& interface, | 134 void OnSignalConnected(const std::string& interface, |
130 const std::string& signal, | 135 const std::string& signal, |
131 bool success); | 136 bool success); |
132 | 137 |
133 // Handles PropertyChanged signal. | 138 // Handles PropertyChanged signal. |
134 void OnPropertyChanged(dbus::Signal* signal); | 139 void OnPropertyChanged(dbus::Signal* signal); |
135 | 140 |
136 // Handles responses for methods without results. | 141 // Handles responses for methods without results. |
137 void OnVoidMethod(const VoidDBusMethodCallback& callback, | 142 void OnVoidMethod(const VoidDBusMethodCallback& callback, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // Handles errors for method calls. | 178 // Handles errors for method calls. |
174 void OnError(const ErrorCallback& error_callback, | 179 void OnError(const ErrorCallback& error_callback, |
175 dbus::ErrorResponse* response); | 180 dbus::ErrorResponse* response); |
176 | 181 |
177 // TODO(hashimoto): Remove this when we no longer need to make blocking calls. | 182 // TODO(hashimoto): Remove this when we no longer need to make blocking calls. |
178 BlockingMethodCaller blocking_method_caller_; | 183 BlockingMethodCaller blocking_method_caller_; |
179 dbus::ObjectProxy* proxy_; | 184 dbus::ObjectProxy* proxy_; |
180 PropertyChangedHandler property_changed_handler_; | 185 PropertyChangedHandler property_changed_handler_; |
181 ObserverList<ShillPropertyChangedObserver, true /* check_empty */> | 186 ObserverList<ShillPropertyChangedObserver, true /* check_empty */> |
182 observer_list_; | 187 observer_list_; |
| 188 std::vector<std::string> interfaces_to_be_monitored_; |
183 | 189 |
184 // Note: This should remain the last member so it'll be destroyed and | 190 // Note: This should remain the last member so it'll be destroyed and |
185 // invalidate its weak pointers before any other members are destroyed. | 191 // invalidate its weak pointers before any other members are destroyed. |
186 base::WeakPtrFactory<ShillClientHelper> weak_ptr_factory_; | 192 base::WeakPtrFactory<ShillClientHelper> weak_ptr_factory_; |
187 | 193 |
188 DISALLOW_COPY_AND_ASSIGN(ShillClientHelper); | 194 DISALLOW_COPY_AND_ASSIGN(ShillClientHelper); |
189 }; | 195 }; |
190 | 196 |
191 } // namespace chromeos | 197 } // namespace chromeos |
192 | 198 |
193 #endif // CHROMEOS_DBUS_SHILL_CLIENT_HELPER_H_ | 199 #endif // CHROMEOS_DBUS_SHILL_CLIENT_HELPER_H_ |
OLD | NEW |