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_STATE_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
6 #define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // be stored or used beyond the scope of the calling function (i.e. they may | 175 // be stored or used beyond the scope of the calling function (i.e. they may |
176 // later become invalid, but only on the UI thread). SortNetworkList() will be | 176 // later become invalid, but only on the UI thread). SortNetworkList() will be |
177 // called if necessary to provide the states in a convenient order (see | 177 // called if necessary to provide the states in a convenient order (see |
178 // SortNetworkList for details). | 178 // SortNetworkList for details). |
179 void GetNetworkListByType(const NetworkTypePattern& type, | 179 void GetNetworkListByType(const NetworkTypePattern& type, |
180 bool configured_only, | 180 bool configured_only, |
181 bool visible_only, | 181 bool visible_only, |
182 int limit, | 182 int limit, |
183 NetworkStateList* list); | 183 NetworkStateList* list); |
184 | 184 |
185 // Sets |list| to contain the list of Tether networks. If |limit| > 0, that | |
186 // will determine the number of results; pass 0 for no limit. The returned | |
187 // list contains a copy of NetworkState pointers which should not be stored or | |
188 // used beyond the scope of the calling function (i.e. they may later become | |
189 // invalid, but only on the UI thread). | |
190 // NOTE: See AddTetherNetworkState for more information about Tether networks. | |
191 void GetTetherNetworkList(int limit, NetworkStateList* list); | |
192 | |
193 // Finds and returns the NetworkState associated with |service_path| or NULL | 185 // Finds and returns the NetworkState associated with |service_path| or NULL |
194 // if not found. If |configured_only| is true, only returns saved entries | 186 // if not found. If |configured_only| is true, only returns saved entries |
195 // (IsInProfile is true). | 187 // (IsInProfile is true). |
196 const NetworkState* GetNetworkStateFromServicePath( | 188 const NetworkState* GetNetworkStateFromServicePath( |
197 const std::string& service_path, | 189 const std::string& service_path, |
198 bool configured_only) const; | 190 bool configured_only) const; |
199 | 191 |
200 // Finds and returns the NetworkState associated with |guid| or NULL if not | 192 // Finds and returns the NetworkState associated with |guid| or NULL if not |
201 // found. This returns all entries (IsInProfile() may be true or false). | 193 // found. This returns all entries (IsInProfile() may be true or false). |
202 const NetworkState* GetNetworkStateFromGuid(const std::string& guid) const; | 194 const NetworkState* GetNetworkStateFromGuid(const std::string& guid) const; |
203 | 195 |
204 // Creates a Tether NetworkState that has no underlying shill type or | 196 // Creates a Tether NetworkState that has no underlying shill type or |
205 // service. When initially created, it does not actually represent a real | 197 // service. When initially created, it does not actually represent a real |
206 // network. The |guid| provided must be non-empty. If a network with |guid| | 198 // network. The |guid| provided must be non-empty. If a network with |guid| |
207 // already exists, this method will do nothing. Use the provided |guid| to | 199 // already exists, this method will do nothing. Use the provided |guid| to |
208 // refer to and fetch this NetworkState in the future. | 200 // refer to and fetch this NetworkState in the future. |
209 // NOTE: only GetNetworkStateFromGuid is supported to fetch "tether" | 201 // NOTE: only GetNetworkStateFromGuid is supported to fetch "tether" |
210 // NetworkStates. | 202 // NetworkStates. |
211 void AddTetherNetworkState(const std::string& guid, const std::string& name); | 203 void AddTetherNetworkState(const std::string& guid, |
| 204 const std::string& name, |
| 205 const std::string& carrier, |
| 206 int battery_percentage, |
| 207 int signal_strength); |
| 208 |
| 209 // Updates the tether properties (carrier, battery percentage, and signal |
| 210 // strength) for a network which has already been added via |
| 211 // AddTetherNetworkState. Returns whether the update was successful. |
| 212 bool UpdateTetherNetworkProperties(const std::string& guid, |
| 213 const std::string& carrier, |
| 214 int battery_percentage, |
| 215 int signal_strength); |
212 | 216 |
213 // Remove a Tether NetworkState, using the same |guid| passed to | 217 // Remove a Tether NetworkState, using the same |guid| passed to |
214 // AddTetherNetworkState. | 218 // AddTetherNetworkState. |
215 void RemoveTetherNetworkState(const std::string& guid); | 219 void RemoveTetherNetworkState(const std::string& guid); |
216 | 220 |
217 // Inform NetworkStateHandler that the provided Tether network with the | 221 // Inform NetworkStateHandler that the provided Tether network with the |
218 // provided guid |tether_guid| is associated with the Wi-Fi network with the | 222 // provided guid |tether_network_guid| is associated with the Wi-Fi network |
219 // provided guid |wifi_ssid|. This Wi-Fi network can now be hidden in the UI, | 223 // with the provided guid |wifi_network_guid|. This Wi-Fi network can now be |
220 // and the Tether network will act as its proxy. Returns false if the | 224 // hidden in the UI, and the Tether network will act as its proxy. Returns |
221 // association failed (e.g. one or both networks don't exist). | 225 // false if the association failed (e.g., one or both networks don't exist). |
222 bool AssociateTetherNetworkStateWithWifiNetwork( | 226 bool AssociateTetherNetworkStateWithWifiNetwork( |
223 const std::string& tether_network_guid, | 227 const std::string& tether_network_guid, |
224 const std::string& wifi_network_ssid); | 228 const std::string& wifi_network_guid); |
225 | 229 |
226 // Set the connection_state of the Tether NetworkState corresponding to the | 230 // Set the connection_state of the Tether NetworkState corresponding to the |
227 // provided |guid| to "Disconnected". This will be reflected in the UI. | 231 // provided |guid| to "Disconnected". This will be reflected in the UI. |
228 void SetTetherNetworkStateDisconnected(const std::string& guid); | 232 void SetTetherNetworkStateDisconnected(const std::string& guid); |
229 | 233 |
230 // Set the connection_state of the Tether NetworkState corresponding to the | 234 // Set the connection_state of the Tether NetworkState corresponding to the |
231 // provided |guid| to "Connecting". This will be reflected in the UI. | 235 // provided |guid| to "Connecting". This will be reflected in the UI. |
232 void SetTetherNetworkStateConnecting(const std::string& guid); | 236 void SetTetherNetworkStateConnecting(const std::string& guid); |
233 | 237 |
234 // Set the connection_state of the Tether NetworkState corresponding to the | 238 // Set the connection_state of the Tether NetworkState corresponding to the |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 void NotifyScanCompleted(const DeviceState* device); | 431 void NotifyScanCompleted(const DeviceState* device); |
428 | 432 |
429 // Returns one technology type for |type|. This technology will be the | 433 // Returns one technology type for |type|. This technology will be the |
430 // highest priority technology in the type pattern. | 434 // highest priority technology in the type pattern. |
431 std::string GetTechnologyForType(const NetworkTypePattern& type) const; | 435 std::string GetTechnologyForType(const NetworkTypePattern& type) const; |
432 | 436 |
433 // Returns all the technology types for |type|. | 437 // Returns all the technology types for |type|. |
434 std::vector<std::string> GetTechnologiesForType( | 438 std::vector<std::string> GetTechnologiesForType( |
435 const NetworkTypePattern& type) const; | 439 const NetworkTypePattern& type) const; |
436 | 440 |
| 441 // Sets |list| to contain the list of Tether networks. If |limit| > 0, that |
| 442 // will determine the number of results; pass 0 for no limit. The returned |
| 443 // list contains a copy of NetworkState pointers which should not be stored or |
| 444 // used beyond the scope of the calling function (i.e. they may later become |
| 445 // invalid, but only on the UI thread). |
| 446 // NOTE: See AddTetherNetworkState for more information about Tether networks. |
| 447 void GetTetherNetworkList(int limit, NetworkStateList* list); |
| 448 |
| 449 // Set the connection_state of a Tether NetworkState corresponding to the |
| 450 // provided |guid|. |
| 451 void SetTetherNetworkStateConnectionState( |
| 452 const std::string& guid, |
| 453 const std::string& connection_state); |
| 454 |
437 // Shill property handler instance, owned by this class. | 455 // Shill property handler instance, owned by this class. |
438 std::unique_ptr<internal::ShillPropertyHandler> shill_property_handler_; | 456 std::unique_ptr<internal::ShillPropertyHandler> shill_property_handler_; |
439 | 457 |
440 // Observer list | 458 // Observer list |
441 base::ObserverList<NetworkStateHandlerObserver, true> observers_; | 459 base::ObserverList<NetworkStateHandlerObserver, true> observers_; |
442 | 460 |
443 // List of managed network states | 461 // List of managed network states |
444 ManagedStateList network_list_; | 462 ManagedStateList network_list_; |
445 | 463 |
446 // List of managed Tether network states, which exist separately from | 464 // List of managed Tether network states, which exist separately from |
(...skipping 13 matching lines...) Expand all Loading... |
460 // List of interfaces on which portal check is enabled. | 478 // List of interfaces on which portal check is enabled. |
461 std::string check_portal_list_; | 479 std::string check_portal_list_; |
462 | 480 |
463 // Map of network specifiers to guids. Contains an entry for each | 481 // Map of network specifiers to guids. Contains an entry for each |
464 // NetworkState that is not saved in a profile. | 482 // NetworkState that is not saved in a profile. |
465 SpecifierGuidMap specifier_guid_map_; | 483 SpecifierGuidMap specifier_guid_map_; |
466 | 484 |
467 // Ensure that Shutdown() gets called exactly once. | 485 // Ensure that Shutdown() gets called exactly once. |
468 bool did_shutdown_ = false; | 486 bool did_shutdown_ = false; |
469 | 487 |
470 // Set the |connection_state| of a Tether NetworkState corresponding to the | |
471 // provided |guid|. | |
472 void SetTetherNetworkStateConnectionState( | |
473 const std::string& guid, | |
474 const std::string& connection_state); | |
475 | |
476 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); | 488 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); |
477 }; | 489 }; |
478 | 490 |
479 } // namespace chromeos | 491 } // namespace chromeos |
480 | 492 |
481 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ | 493 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
OLD | NEW |