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

Unified Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 2817036: Push change for stevenjb:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 6 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
Index: chrome/browser/chromeos/cros/network_library.cc
===================================================================
--- chrome/browser/chromeos/cros/network_library.cc (revision 50505)
+++ chrome/browser/chromeos/cros/network_library.cc (working copy)
@@ -263,6 +263,32 @@
observers_.RemoveObserver(observer);
}
+////////////////////////////////////////////////////////////////////////////////
+
+bool NetworkLibraryImpl::FindWifiNetworkByPath(
+ const std::string& path, WifiNetwork* result) const {
+ const WifiNetwork* wifi =
+ GetWirelessNetworkByPath(wifi_networks_, path);
+ if (wifi) {
+ if (result)
+ *result = *wifi;
+ return true;
+ }
+ return false;
+}
+
+bool NetworkLibraryImpl::FindCellularNetworkByPath(
+ const std::string& path, CellularNetwork* result) const {
+ const CellularNetwork* cellular =
+ GetWirelessNetworkByPath(cellular_networks_, path);
+ if (cellular) {
+ if (result)
+ *result = *cellular;
+ return true;
+ }
+ return false;
+}
+
void NetworkLibraryImpl::RequestWifiScan() {
if (CrosLibrary::Get()->EnsureLoaded()) {
RequestScan(TYPE_WIFI);
@@ -300,7 +326,7 @@
for (int i = 0; i < 30; i++) {
// Update the system and refetch the network.
UpdateSystemInfo();
- wifi = GetWifiNetworkByPath(wifi_path);
+ wifi = GetWirelessNetworkByPath(wifi_networks_, wifi_path);
// See if identity and certpath are available.
if (wifi && !wifi->identity().empty() && !wifi->cert_path().empty()) {
LOG(INFO) << "Google wifi set up after " << (i*0.1) << " seconds.";
@@ -386,7 +412,8 @@
void NetworkLibraryImpl::SaveWifiNetwork(const WifiNetwork& network) {
// Update the wifi network in the local cache.
- WifiNetwork* wifi = GetWifiNetworkByPath(network.service_path());
+ WifiNetwork* wifi = GetWirelessNetworkByPath(wifi_networks_,
+ network.service_path());
if (wifi)
*wifi = network;
@@ -619,15 +646,23 @@
return NULL;
}
-WifiNetwork* NetworkLibraryImpl::GetWifiNetworkByPath(const std::string& path) {
- for (size_t i = 0; i < wifi_networks_.size(); ++i) {
- if (wifi_networks_[i].service_path().compare(path) == 0) {
- return &wifi_networks_[i];
- }
- }
- return NULL;
+template<typename T> T* NetworkLibraryImpl::GetWirelessNetworkByPath(
+ std::vector<T>& networks, const std::string& path) {
+ typedef typename std::vector<T>::iterator iter_t;
+ iter_t iter = std::find_if(networks.begin(), networks.end(),
+ WirelessNetwork::ServicePathEq(path));
+ return (iter != networks.end()) ? &(*iter) : NULL;
}
+// const version
+template<typename T> const T* NetworkLibraryImpl::GetWirelessNetworkByPath(
+ const std::vector<T>& networks, const std::string& path) const {
+ typedef typename std::vector<T>::const_iterator iter_t;
+ iter_t iter = std::find_if(networks.begin(), networks.end(),
+ WirelessNetwork::ServicePathEq(path));
+ return (iter != networks.end()) ? &(*iter) : NULL;
+}
+
void NetworkLibraryImpl::EnableNetworkDeviceType(ConnectionType device,
bool enable) {
if (!CrosLibrary::Get()->EnsureLoaded())
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.h ('k') | chrome/browser/chromeos/status/network_menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698