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

Side by Side Diff: chromeos/dbus/shill_client_helper.h

Issue 12220128: Shill: Delay the ConnectToSignal call until an observer is added. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: apply issues on try bots, patch rebased. Created 7 years, 10 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
« no previous file with comments | « no previous file | chromeos/dbus/shill_client_helper.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) 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
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | chromeos/dbus/shill_client_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698