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_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_ |
6 #define CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // Changes the profile for the network |service_path| to |profile_path|. | 114 // Changes the profile for the network |service_path| to |profile_path|. |
115 // See notes on |source| and callbacks in class description above. | 115 // See notes on |source| and callbacks in class description above. |
116 void SetNetworkProfile(const std::string& service_path, | 116 void SetNetworkProfile(const std::string& service_path, |
117 const std::string& profile_path, | 117 const std::string& profile_path, |
118 NetworkConfigurationObserver::Source source, | 118 NetworkConfigurationObserver::Source source, |
119 const base::Closure& callback, | 119 const base::Closure& callback, |
120 const network_handler::ErrorCallback& error_callback); | 120 const network_handler::ErrorCallback& error_callback); |
121 | 121 |
122 // Construct and initialize an instance for testing. | 122 // Construct and initialize an instance for testing. |
123 static NetworkConfigurationHandler* InitializeForTest( | 123 static NetworkConfigurationHandler* InitializeForTest( |
124 NetworkStateHandler* network_state_handler); | 124 NetworkStateHandler* network_state_handler, |
| 125 NetworkDeviceHandler* network_device_handler); |
125 | 126 |
126 protected: | 127 protected: |
127 friend class ClientCertResolverTest; | 128 friend class ClientCertResolverTest; |
128 friend class NetworkHandler; | 129 friend class NetworkHandler; |
129 friend class NetworkConfigurationHandlerTest; | 130 friend class NetworkConfigurationHandlerTest; |
130 friend class NetworkConfigurationHandlerStubTest; | 131 friend class NetworkConfigurationHandlerStubTest; |
131 class ProfileEntryDeleter; | 132 class ProfileEntryDeleter; |
132 | 133 |
133 NetworkConfigurationHandler(); | 134 NetworkConfigurationHandler(); |
134 void Init(NetworkStateHandler* network_state_handler); | 135 void Init(NetworkStateHandler* network_state_handler, |
| 136 NetworkDeviceHandler* network_device_handler); |
135 | 137 |
136 void RunCreateNetworkCallback( | 138 void RunCreateNetworkCallback( |
137 const std::string& profile_path, | 139 const std::string& profile_path, |
138 NetworkConfigurationObserver::Source source, | 140 NetworkConfigurationObserver::Source source, |
139 scoped_ptr<base::DictionaryValue> configure_properties, | 141 scoped_ptr<base::DictionaryValue> configure_properties, |
140 const network_handler::StringResultCallback& callback, | 142 const network_handler::StringResultCallback& callback, |
141 const dbus::ObjectPath& service_path); | 143 const dbus::ObjectPath& service_path); |
142 | 144 |
143 // Called from ProfileEntryDeleter instances when they complete causing | 145 // Called from ProfileEntryDeleter instances when they complete causing |
144 // this class to delete the instance. | 146 // this class to delete the instance. |
145 void ProfileEntryDeleterCompleted(const std::string& service_path, | 147 void ProfileEntryDeleterCompleted(const std::string& service_path, |
146 const std::string& guid, | 148 const std::string& guid, |
147 NetworkConfigurationObserver::Source source, | 149 NetworkConfigurationObserver::Source source, |
148 bool success); | 150 bool success); |
149 bool PendingProfileEntryDeleterForTest(const std::string& service_path) { | 151 bool PendingProfileEntryDeleterForTest(const std::string& service_path) { |
150 return profile_entry_deleters_.count(service_path); | 152 return profile_entry_deleters_.count(service_path); |
151 } | 153 } |
152 | 154 |
153 // Callback after moving a network configuration. | 155 // Callback after moving a network configuration. |
154 void SetNetworkProfileCompleted(const std::string& service_path, | 156 void SetNetworkProfileCompleted(const std::string& service_path, |
155 const std::string& profile_path, | 157 const std::string& profile_path, |
156 NetworkConfigurationObserver::Source source, | 158 NetworkConfigurationObserver::Source source, |
157 const base::Closure& callback); | 159 const base::Closure& callback); |
158 | 160 |
| 161 // Helper method to send the SetProperties request to Shill. Called either |
| 162 // directly from SetProperties, or after ClearProperties completes. |
| 163 void SendSetPropertiesToShill( |
| 164 const std::string& service_path, |
| 165 scoped_ptr<base::DictionaryValue> changed_properties, |
| 166 scoped_ptr<base::DictionaryValue> properties_to_set, |
| 167 NetworkConfigurationObserver::Source source, |
| 168 const base::Closure& callback, |
| 169 const network_handler::ErrorCallback& error_callback); |
| 170 |
159 // Invoke the callback and inform NetworkStateHandler to request an update | 171 // Invoke the callback and inform NetworkStateHandler to request an update |
160 // for the service after setting properties. | 172 // for the service after setting properties. |
161 void SetPropertiesSuccessCallback( | 173 void SetPropertiesSuccessCallback( |
162 const std::string& service_path, | 174 const std::string& service_path, |
163 scoped_ptr<base::DictionaryValue> set_properties, | 175 scoped_ptr<base::DictionaryValue> changed_properties, |
164 NetworkConfigurationObserver::Source source, | 176 NetworkConfigurationObserver::Source source, |
165 const base::Closure& callback); | 177 const base::Closure& callback); |
166 void SetPropertiesErrorCallback( | 178 void SetPropertiesErrorCallback( |
167 const std::string& service_path, | 179 const std::string& service_path, |
168 const network_handler::ErrorCallback& error_callback, | 180 const network_handler::ErrorCallback& error_callback, |
169 const std::string& dbus_error_name, | 181 const std::string& dbus_error_name, |
170 const std::string& dbus_error_message); | 182 const std::string& dbus_error_message); |
171 | 183 |
172 // Invoke the callback and inform NetworkStateHandler to request an update | 184 // Callbacks supporting ClearProperties. First the current properties are |
173 // for the service after clearing properties. | 185 // requested so that only set properties are cleared. On success this informs |
| 186 // NetworkStateHandler to request an update for the service. |
| 187 void ClearPropertiesGetCallback( |
| 188 const std::string& service_path, |
| 189 const std::vector<std::string>& names, |
| 190 const base::Closure& callback, |
| 191 const network_handler::ErrorCallback& error_callback, |
| 192 DBusMethodCallStatus call_status, |
| 193 const base::DictionaryValue& properties); |
174 void ClearPropertiesSuccessCallback( | 194 void ClearPropertiesSuccessCallback( |
175 const std::string& service_path, | 195 const std::string& service_path, |
176 const std::vector<std::string>& names, | 196 const std::vector<std::string>& names, |
177 const base::Closure& callback, | 197 const base::Closure& callback, |
178 const base::ListValue& result); | 198 const base::ListValue& result); |
179 void ClearPropertiesErrorCallback( | 199 void ClearPropertiesErrorCallback( |
180 const std::string& service_path, | 200 const std::string& service_path, |
181 const network_handler::ErrorCallback& error_callback, | 201 const network_handler::ErrorCallback& error_callback, |
182 const std::string& dbus_error_name, | 202 const std::string& dbus_error_name, |
183 const std::string& dbus_error_message); | 203 const std::string& dbus_error_message); |
184 | 204 |
185 // Unowned associated NetworkStateHandler* (global or test instance). | 205 // Signals the device handler to request an IP config refresh. |
| 206 void RequestRefreshIPConfigs(const std::string& service_path); |
| 207 |
| 208 // Unowned associated Network*Handlers (global or test instance). |
186 NetworkStateHandler* network_state_handler_; | 209 NetworkStateHandler* network_state_handler_; |
| 210 NetworkDeviceHandler* network_device_handler_; |
187 | 211 |
188 // Map of in-progress deleter instances. Owned by this class. | 212 // Map of in-progress deleter instances. Owned by this class. |
189 std::map<std::string, ProfileEntryDeleter*> profile_entry_deleters_; | 213 std::map<std::string, ProfileEntryDeleter*> profile_entry_deleters_; |
190 | 214 |
191 ObserverList<NetworkConfigurationObserver> observers_; | 215 ObserverList<NetworkConfigurationObserver> observers_; |
192 | 216 |
193 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationHandler); | 217 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationHandler); |
194 }; | 218 }; |
195 | 219 |
196 } // namespace chromeos | 220 } // namespace chromeos |
197 | 221 |
198 #endif // CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_ | 222 #endif // CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_ |
OLD | NEW |