Chromium Code Reviews| Index: chromeos/network/network_state_handler.cc |
| diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc |
| index 6540a0de48e86246a037ca94af6a1c9722cbf7c1..d3f713db6c6efc52dc1f7e37aba4e67951c44196 100644 |
| --- a/chromeos/network/network_state_handler.cc |
| +++ b/chromeos/network/network_state_handler.cc |
| @@ -298,22 +298,38 @@ void NetworkStateHandler::GetDeviceListByType(const NetworkTypePattern& type, |
| } |
| void NetworkStateHandler::GetFavoriteList(FavoriteStateList* list) const { |
| - GetFavoriteListByType(NetworkTypePattern::Default(), list); |
| + GetFavoriteListByType(NetworkTypePattern::Default(), |
| + true /* configured_only */, |
| + false /* visible_only */, |
| + list); |
| } |
| void NetworkStateHandler::GetFavoriteListByType(const NetworkTypePattern& type, |
| + bool configured_only, |
| + bool visible_only, |
| FavoriteStateList* list) const { |
| DCHECK(list); |
| + std::set<std::string> visible_networks; |
| + if (visible_only) { |
| + // Prepare a set of visible network service paths for fast lookup. |
| + for (ManagedStateList::const_iterator iter = network_list_.begin(); |
|
pneubeck (no reviews)
2014/05/15 18:28:38
I like this solution if we don't care about best r
stevenjb
2014/05/15 20:12:41
I thought about that, but honestly if performance
pneubeck (no reviews)
2014/05/16 13:18:55
Yes, totally reasonable.
|
| + iter != network_list_.end(); ++iter) { |
| + visible_networks.insert((*iter)->path()); |
| + } |
| + } |
| FavoriteStateList result; |
| list->clear(); |
| for (ManagedStateList::const_iterator iter = favorite_list_.begin(); |
| iter != favorite_list_.end(); ++iter) { |
| const FavoriteState* favorite = (*iter)->AsFavoriteState(); |
| DCHECK(favorite); |
| - if (favorite->update_received() && favorite->IsInProfile() && |
| - favorite->Matches(type)) { |
| - list->push_back(favorite); |
| - } |
| + if (!favorite->update_received() || !favorite->Matches(type)) |
| + continue; |
| + if (configured_only && !favorite->IsInProfile()) |
| + continue; |
| + if (visible_only && !ContainsKey(visible_networks, favorite->path())) |
| + continue; |
| + list->push_back(favorite); |
| } |
| } |
| @@ -418,6 +434,8 @@ const FavoriteState* NetworkStateHandler::GetEAPForEthernet( |
| FavoriteStateList list; |
| GetFavoriteListByType(NetworkTypePattern::Primitive(shill::kTypeEthernetEap), |
| + true /* configured_only */, |
| + false /* visible_only */, |
| &list); |
| if (list.empty()) { |
| NET_LOG_ERROR("GetEAPForEthernet", |