Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: chromeos/network/network_state_handler.cc

Issue 280023003: Implement networkingPrivate.getNetworks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nonchromeos Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/network_state_handler.h ('k') | chromeos/network/network_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d84784f33ed5a86523cef5a270221d9c72ed47d1 100644
--- a/chromeos/network/network_state_handler.cc
+++ b/chromeos/network/network_state_handler.cc
@@ -298,22 +298,43 @@ 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 */,
+ 0 /* no limit */,
+ list);
}
void NetworkStateHandler::GetFavoriteListByType(const NetworkTypePattern& type,
+ bool configured_only,
+ bool visible_only,
+ int limit,
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();
+ iter != network_list_.end(); ++iter) {
+ visible_networks.insert((*iter)->path());
+ }
+ }
FavoriteStateList result;
list->clear();
+ int count = 0;
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);
+ if (limit > 0 && ++count >= limit)
+ break;
}
}
@@ -418,6 +439,9 @@ const FavoriteState* NetworkStateHandler::GetEAPForEthernet(
FavoriteStateList list;
GetFavoriteListByType(NetworkTypePattern::Primitive(shill::kTypeEthernetEap),
+ true /* configured_only */,
+ false /* visible_only */,
+ 1 /* limit */,
&list);
if (list.empty()) {
NET_LOG_ERROR("GetEAPForEthernet",
@@ -427,7 +451,6 @@ const FavoriteState* NetworkStateHandler::GetEAPForEthernet(
service_path.c_str()));
return NULL;
}
- DCHECK(list.size() == 1);
return list.front();
}
« no previous file with comments | « chromeos/network/network_state_handler.h ('k') | chromeos/network/network_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698