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 #include "chromeos/network/network_state_handler.h" | 5 #include "chromeos/network/network_state_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 continue; | 193 continue; |
194 if (device->Matches(type) && device->scanning()) | 194 if (device->Matches(type) && device->scanning()) |
195 return true; | 195 return true; |
196 } | 196 } |
197 return false; | 197 return false; |
198 } | 198 } |
199 | 199 |
200 const NetworkState* NetworkStateHandler::GetNetworkState( | 200 const NetworkState* NetworkStateHandler::GetNetworkState( |
201 const std::string& service_path) const { | 201 const std::string& service_path) const { |
202 const NetworkState* network = GetModifiableNetworkState(service_path); | 202 const NetworkState* network = GetModifiableNetworkState(service_path); |
203 // This is a hack that I don't intend to keep here. | |
Ryan Hansberry
2017/02/15 19:57:39
Could/should NetworkListMd be changed to use Netwo
stevenjb
2017/02/15 20:59:04
We shouldn't do this hack. Ideally converting Netw
Ryan Hansberry
2017/02/16 22:42:20
Fixed after https://codereview.chromium.org/269847
| |
204 if (!network) { | |
205 return GetNetworkStateFromGuid(service_path); | |
206 } | |
203 if (network && !network->update_received()) | 207 if (network && !network->update_received()) |
204 return nullptr; | 208 return nullptr; |
205 return network; | 209 return network; |
206 } | 210 } |
207 | 211 |
208 const NetworkState* NetworkStateHandler::DefaultNetwork() const { | 212 const NetworkState* NetworkStateHandler::DefaultNetwork() const { |
209 if (default_network_path_.empty()) | 213 if (default_network_path_.empty()) |
210 return nullptr; | 214 return nullptr; |
211 return GetNetworkState(default_network_path_); | 215 return GetNetworkState(default_network_path_); |
212 } | 216 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 } | 286 } |
283 | 287 |
284 void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type, | 288 void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type, |
285 bool configured_only, | 289 bool configured_only, |
286 bool visible_only, | 290 bool visible_only, |
287 int limit, | 291 int limit, |
288 NetworkStateList* list) { | 292 NetworkStateList* list) { |
289 DCHECK(list); | 293 DCHECK(list); |
290 list->clear(); | 294 list->clear(); |
291 int count = 0; | 295 int count = 0; |
296 | |
297 if (NetworkTypePattern::Tether().MatchesPattern(type)) { | |
298 for (auto iter = tether_network_list_.begin(); | |
299 iter != tether_network_list_.end(); ++iter) { | |
300 list->push_back((*iter)->AsNetworkState()); | |
301 if (limit > 0 && ++count >= limit) | |
302 return; | |
303 } | |
304 } | |
305 | |
292 // Sort the network list if necessary. | 306 // Sort the network list if necessary. |
293 if (!network_list_sorted_) | 307 if (!network_list_sorted_) |
294 SortNetworkList(); | 308 SortNetworkList(); |
295 for (auto iter = network_list_.begin(); iter != network_list_.end(); ++iter) { | 309 for (auto iter = network_list_.begin(); iter != network_list_.end(); ++iter) { |
296 const NetworkState* network = (*iter)->AsNetworkState(); | 310 const NetworkState* network = (*iter)->AsNetworkState(); |
297 DCHECK(network); | 311 DCHECK(network); |
298 if (!network->update_received() || !network->Matches(type)) | 312 if (!network->update_received() || !network->Matches(type)) |
299 continue; | 313 continue; |
300 if (configured_only && !network->IsInProfile()) | 314 if (configured_only && !network->IsInProfile()) |
301 continue; | 315 continue; |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1046 if (type.MatchesType(shill::kTypeBluetooth)) | 1060 if (type.MatchesType(shill::kTypeBluetooth)) |
1047 technologies.emplace_back(shill::kTypeBluetooth); | 1061 technologies.emplace_back(shill::kTypeBluetooth); |
1048 if (type.MatchesType(shill::kTypeVPN)) | 1062 if (type.MatchesType(shill::kTypeVPN)) |
1049 technologies.emplace_back(shill::kTypeVPN); | 1063 technologies.emplace_back(shill::kTypeVPN); |
1050 | 1064 |
1051 CHECK_GT(technologies.size(), 0ul); | 1065 CHECK_GT(technologies.size(), 0ul); |
1052 return technologies; | 1066 return technologies; |
1053 } | 1067 } |
1054 | 1068 |
1055 } // namespace chromeos | 1069 } // namespace chromeos |
OLD | NEW |