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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // themselves and disable any networking. | 84 // themselves and disable any networking. |
85 void Shutdown(); | 85 void Shutdown(); |
86 | 86 |
87 // Add/remove observers. | 87 // Add/remove observers. |
88 void AddObserver(NetworkStateHandlerObserver* observer, | 88 void AddObserver(NetworkStateHandlerObserver* observer, |
89 const tracked_objects::Location& from_here); | 89 const tracked_objects::Location& from_here); |
90 void RemoveObserver(NetworkStateHandlerObserver* observer, | 90 void RemoveObserver(NetworkStateHandlerObserver* observer, |
91 const tracked_objects::Location& from_here); | 91 const tracked_objects::Location& from_here); |
92 | 92 |
93 // Returns the state for technology |type|. Only | 93 // Returns the state for technology |type|. Only |
94 // NetworkTypePattern::Primitive, ::Mobile and ::Ethernet are supported. | 94 // NetworkTypePattern::Primitive, ::Mobile, ::Ethernet, and ::Tether are |
| 95 // supported. |
95 TechnologyState GetTechnologyState(const NetworkTypePattern& type) const; | 96 TechnologyState GetTechnologyState(const NetworkTypePattern& type) const; |
96 bool IsTechnologyAvailable(const NetworkTypePattern& type) const { | 97 bool IsTechnologyAvailable(const NetworkTypePattern& type) const { |
97 return GetTechnologyState(type) != TECHNOLOGY_UNAVAILABLE; | 98 return GetTechnologyState(type) != TECHNOLOGY_UNAVAILABLE; |
98 } | 99 } |
99 bool IsTechnologyEnabled(const NetworkTypePattern& type) const { | 100 bool IsTechnologyEnabled(const NetworkTypePattern& type) const { |
100 return GetTechnologyState(type) == TECHNOLOGY_ENABLED; | 101 return GetTechnologyState(type) == TECHNOLOGY_ENABLED; |
101 } | 102 } |
102 bool IsTechnologyProhibited(const NetworkTypePattern& type) const { | 103 bool IsTechnologyProhibited(const NetworkTypePattern& type) const { |
103 return GetTechnologyState(type) == TECHNOLOGY_PROHIBITED; | 104 return GetTechnologyState(type) == TECHNOLOGY_PROHIBITED; |
104 } | 105 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // 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 |
175 // 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 |
176 // 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 |
177 // SortNetworkList for details). | 178 // SortNetworkList for details). |
178 void GetNetworkListByType(const NetworkTypePattern& type, | 179 void GetNetworkListByType(const NetworkTypePattern& type, |
179 bool configured_only, | 180 bool configured_only, |
180 bool visible_only, | 181 bool visible_only, |
181 int limit, | 182 int limit, |
182 NetworkStateList* list); | 183 NetworkStateList* list); |
183 | 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" |
| 191 // networks. |
| 192 void GetTetherNetworkList(int limit, NetworkStateList* list); |
| 193 |
184 // Finds and returns the NetworkState associated with |service_path| or NULL | 194 // Finds and returns the NetworkState associated with |service_path| or NULL |
185 // if not found. If |configured_only| is true, only returns saved entries | 195 // if not found. If |configured_only| is true, only returns saved entries |
186 // (IsInProfile is true). | 196 // (IsInProfile is true). |
187 const NetworkState* GetNetworkStateFromServicePath( | 197 const NetworkState* GetNetworkStateFromServicePath( |
188 const std::string& service_path, | 198 const std::string& service_path, |
189 bool configured_only) const; | 199 bool configured_only) const; |
190 | 200 |
191 // Finds and returns the NetworkState associated with |guid| or NULL if not | 201 // Finds and returns the NetworkState associated with |guid| or NULL if not |
192 // found. This returns all entries (IsInProfile() may be true or false). | 202 // found. This returns all entries (IsInProfile() may be true or false). |
193 const NetworkState* GetNetworkStateFromGuid(const std::string& guid) const; | 203 const NetworkState* GetNetworkStateFromGuid(const std::string& guid) const; |
194 | 204 |
195 // Creates a "tether" NetworkState that has no underlying shill type or | 205 // Creates a "tether" NetworkState that has no underlying shill type or |
196 // service. When initially created, it does not actually represent a real | 206 // service. When initially created, it does not actually represent a real |
197 // network. Generates and returns a guid to be used to refer to and fetch this | 207 // network. The |guid| provided must be non-empty. If a network with |guid| |
198 // NetworkState in the future. | 208 // already exists, this method will do nothing. Use the provided |guid| to |
| 209 // refer to and fetch this NetworkState in the future. |
199 // NOTE: only GetNetworkStateFromGuid is supported to fetch "tether" | 210 // NOTE: only GetNetworkStateFromGuid is supported to fetch "tether" |
200 // NetworkStates. | 211 // NetworkStates. |
201 const std::string CreateTetherNetworkState(const std::string& name); | 212 void AddTetherNetworkState(const std::string& guid, const std::string& name); |
202 | 213 |
203 // Remove a "tether" NetworkState, using the same guid that was returned by | 214 // Remove a "tether" NetworkState, using the same |guid| passed to |
204 // CreateTetherNetworkState. | 215 // AddTetherNetworkState. |
205 void RemoveTetherNetworkState(const std::string& guid); | 216 void RemoveTetherNetworkState(const std::string& guid); |
206 | 217 |
207 // Sets |list| to contain the list of devices. The returned list contains | 218 // Sets |list| to contain the list of devices. The returned list contains |
208 // a copy of DeviceState pointers which should not be stored or used beyond | 219 // a copy of DeviceState pointers which should not be stored or used beyond |
209 // the scope of the calling function (i.e. they may later become invalid, but | 220 // the scope of the calling function (i.e. they may later become invalid, but |
210 // only on the UI thread). | 221 // only on the UI thread). |
211 void GetDeviceList(DeviceStateList* list) const; | 222 void GetDeviceList(DeviceStateList* list) const; |
212 | 223 |
213 // Like GetDeviceList() but only returns networks with matching |type|. | 224 // Like GetDeviceList() but only returns networks with matching |type|. |
214 void GetDeviceListByType(const NetworkTypePattern& type, | 225 void GetDeviceListByType(const NetworkTypePattern& type, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 | 444 |
434 // Ensure that Shutdown() gets called exactly once. | 445 // Ensure that Shutdown() gets called exactly once. |
435 bool did_shutdown_ = false; | 446 bool did_shutdown_ = false; |
436 | 447 |
437 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); | 448 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); |
438 }; | 449 }; |
439 | 450 |
440 } // namespace chromeos | 451 } // namespace chromeos |
441 | 452 |
442 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ | 453 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
OLD | NEW |