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

Side by Side Diff: chrome/browser/chromeos/cros/network_library_impl_cros.cc

Issue 10554013: Add a CONNECT_REQUESTED state to Network ConnectionState. (Closed) Base URL: http://git.chromium.org/git/chromium/src@master
Patch Set: Rebase Created 8 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/chromeos/cros/network_library_impl_cros.h" 5 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h"
6 6
7 #include <dbus/dbus-glib.h> 7 #include <dbus/dbus-glib.h>
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_writer.h" // for debug output only. 9 #include "base/json/json_writer.h" // for debug output only.
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 case PROPERTY_INDEX_CHECK_PORTAL_LIST: { 701 case PROPERTY_INDEX_CHECK_PORTAL_LIST: {
702 DCHECK_EQ(value->GetType(), Value::TYPE_STRING); 702 DCHECK_EQ(value->GetType(), Value::TYPE_STRING);
703 value->GetAsString(&check_portal_list_); 703 value->GetAsString(&check_portal_list_);
704 break; 704 break;
705 } 705 }
706 case PROPERTY_INDEX_PORTAL_URL: 706 case PROPERTY_INDEX_PORTAL_URL:
707 case PROPERTY_INDEX_ARP_GATEWAY: 707 case PROPERTY_INDEX_ARP_GATEWAY:
708 // Currently we ignore PortalURL and ArpGateway. 708 // Currently we ignore PortalURL and ArpGateway.
709 break; 709 break;
710 default: 710 default:
711 LOG(WARNING) << "Manager: Unhandled key: " << key; 711 VLOG(2) << "Manager: Unhandled key: " << key;
712 break; 712 break;
713 } 713 }
714 base::TimeDelta delta = base::TimeTicks::Now() - start; 714 base::TimeDelta delta = base::TimeTicks::Now() - start;
715 VLOG(2) << "NetworkManagerStatusChanged: time: " 715 VLOG(2) << "NetworkManagerStatusChanged: time: "
716 << delta.InMilliseconds() << " ms."; 716 << delta.InMilliseconds() << " ms.";
717 HISTOGRAM_TIMES("CROS_NETWORK_UPDATE", delta); 717 HISTOGRAM_TIMES("CROS_NETWORK_UPDATE", delta);
718 return true; 718 return true;
719 } 719 }
720 720
721 void NetworkLibraryImplCros::NetworkManagerUpdate( 721 void NetworkLibraryImplCros::NetworkManagerUpdate(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 AddNetwork(found->second); 820 AddNetwork(found->second);
821 old_network_map.erase(found); 821 old_network_map.erase(found);
822 } 822 }
823 // Always request network updates. 823 // Always request network updates.
824 // TODO(stevenjb): Investigate why we are missing updates then 824 // TODO(stevenjb): Investigate why we are missing updates then
825 // rely on watched network updates and only request updates here for 825 // rely on watched network updates and only request updates here for
826 // new networks. 826 // new networks.
827 // Use update_request map to store network priority. 827 // Use update_request map to store network priority.
828 network_update_requests_[service_path] = network_priority_order++; 828 network_update_requests_[service_path] = network_priority_order++;
829 wifi_scanning_ = true; 829 wifi_scanning_ = true;
830 VLOG(2) << "UpdateNetworkServiceList, Service: " << service_path;
830 CrosRequestNetworkServiceProperties( 831 CrosRequestNetworkServiceProperties(
831 service_path, 832 service_path,
832 base::Bind(&NetworkLibraryImplCros::NetworkServiceUpdate, 833 base::Bind(&NetworkLibraryImplCros::NetworkServiceUpdate,
833 weak_ptr_factory_.GetWeakPtr())); 834 weak_ptr_factory_.GetWeakPtr()));
834 } 835 }
835 } 836 }
836 // Iterate through list of remaining networks that are no longer in the 837 // Iterate through list of remaining networks that are no longer in the
837 // list and delete them or update their status and re-add them to the list. 838 // list and delete them or update their status and re-add them to the list.
838 for (NetworkMap::iterator iter = old_network_map.begin(); 839 for (NetworkMap::iterator iter = old_network_map.begin();
839 iter != old_network_map.end(); ++iter) { 840 iter != old_network_map.end(); ++iter) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 weak_ptr_factory_.GetWeakPtr())); 880 weak_ptr_factory_.GetWeakPtr()));
880 } 881 }
881 } 882 }
882 } 883 }
883 884
884 void NetworkLibraryImplCros::NetworkServiceUpdate( 885 void NetworkLibraryImplCros::NetworkServiceUpdate(
885 const std::string& service_path, 886 const std::string& service_path,
886 const base::DictionaryValue* properties) { 887 const base::DictionaryValue* properties) {
887 if (!properties) 888 if (!properties)
888 return; // Network no longer in visible list, ignore. 889 return; // Network no longer in visible list, ignore.
890 VLOG(2) << "NetworkServiceUpdate: " << service_path;
889 ParseNetwork(service_path, *properties); 891 ParseNetwork(service_path, *properties);
890 } 892 }
891 893
892 // Called from NetworkServiceUpdate and WifiServiceUpdateAndConnect. 894 // Called from NetworkServiceUpdate and WifiServiceUpdateAndConnect.
893 Network* NetworkLibraryImplCros::ParseNetwork( 895 Network* NetworkLibraryImplCros::ParseNetwork(
894 const std::string& service_path, const DictionaryValue& info) { 896 const std::string& service_path, const DictionaryValue& info) {
895 Network* network = FindNetworkByPath(service_path); 897 Network* network = FindNetworkByPath(service_path);
896 if (!network) { 898 if (!network) {
897 NativeNetworkParser parser; 899 NativeNetworkParser parser;
898 network = parser.CreateNetworkFromInfo(service_path, info); 900 network = parser.CreateNetworkFromInfo(service_path, info);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 // |profile_entries| is a list of remembered networks from |profile_path|. 1022 // |profile_entries| is a list of remembered networks from |profile_path|.
1021 profile.services.clear(); 1023 profile.services.clear();
1022 for (ListValue::const_iterator iter2 = profile_entries->begin(); 1024 for (ListValue::const_iterator iter2 = profile_entries->begin();
1023 iter2 != profile_entries->end(); ++iter2) { 1025 iter2 != profile_entries->end(); ++iter2) {
1024 std::string service_path; 1026 std::string service_path;
1025 (*iter2)->GetAsString(&service_path); 1027 (*iter2)->GetAsString(&service_path);
1026 if (service_path.empty()) { 1028 if (service_path.empty()) {
1027 LOG(WARNING) << "Empty service path in profile."; 1029 LOG(WARNING) << "Empty service path in profile.";
1028 continue; 1030 continue;
1029 } 1031 }
1030 VLOG(1) << " Remembered service: " << service_path; 1032 VLOG(2) << " Remembered service: " << service_path;
1031 // Add service to profile list. 1033 // Add service to profile list.
1032 profile.services.insert(service_path); 1034 profile.services.insert(service_path);
1033 // Request update for remembered network. 1035 // Request update for remembered network.
1034 CrosRequestNetworkProfileEntryProperties( 1036 CrosRequestNetworkProfileEntryProperties(
1035 profile_path, 1037 profile_path,
1036 service_path, 1038 service_path,
1037 base::Bind(&NetworkLibraryImplCros::RememberedNetworkServiceUpdate, 1039 base::Bind(&NetworkLibraryImplCros::RememberedNetworkServiceUpdate,
1038 weak_ptr_factory_.GetWeakPtr())); 1040 weak_ptr_factory_.GetWeakPtr()));
1039 } 1041 }
1040 } 1042 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 delete remembered; 1077 delete remembered;
1076 return NULL; 1078 return NULL;
1077 } 1079 }
1078 } 1080 }
1079 1081
1080 if (!remembered->unique_id().empty()) 1082 if (!remembered->unique_id().empty())
1081 remembered_network_unique_id_map_[remembered->unique_id()] = remembered; 1083 remembered_network_unique_id_map_[remembered->unique_id()] = remembered;
1082 1084
1083 SetProfileTypeFromPath(remembered); 1085 SetProfileTypeFromPath(remembered);
1084 1086
1085 VLOG(1) << "ParseRememberedNetwork: " << remembered->name() 1087 VLOG(2) << "ParseRememberedNetwork: " << remembered->name()
1086 << " path: " << remembered->service_path() 1088 << " path: " << remembered->service_path()
1087 << " profile: " << remembered->profile_path_; 1089 << " profile: " << remembered->profile_path_;
1088 NotifyNetworkManagerChanged(false); // Not forced. 1090 NotifyNetworkManagerChanged(false); // Not forced.
1089 1091
1090 if (remembered->type() == TYPE_VPN) { 1092 if (remembered->type() == TYPE_VPN) {
1091 // VPNs are only stored in profiles. If we don't have a network for it, 1093 // VPNs are only stored in profiles. If we don't have a network for it,
1092 // request one. 1094 // request one.
1093 if (!FindNetworkByUniqueId(remembered->unique_id())) { 1095 if (!FindNetworkByUniqueId(remembered->unique_id())) {
1094 VirtualNetwork* vpn = static_cast<VirtualNetwork*>(remembered); 1096 VirtualNetwork* vpn = static_cast<VirtualNetwork*>(remembered);
1095 std::string provider_type = ProviderTypeToString(vpn->provider_type()); 1097 std::string provider_type = ProviderTypeToString(vpn->provider_type());
1096 VLOG(1) << "Requesting VPN: " << vpn->name() 1098 VLOG(2) << "Requesting VPN: " << vpn->name()
1097 << " Server: " << vpn->server_hostname() 1099 << " Server: " << vpn->server_hostname()
1098 << " Type: " << provider_type; 1100 << " Type: " << provider_type;
1099 CrosRequestVirtualNetworkProperties( 1101 CrosRequestVirtualNetworkProperties(
1100 vpn->name(), 1102 vpn->name(),
1101 vpn->server_hostname(), 1103 vpn->server_hostname(),
1102 provider_type, 1104 provider_type,
1103 base::Bind(&NetworkLibraryImplCros::NetworkServiceUpdate, 1105 base::Bind(&NetworkLibraryImplCros::NetworkServiceUpdate,
1104 weak_ptr_factory_.GetWeakPtr())); 1106 weak_ptr_factory_.GetWeakPtr()));
1105 } 1107 }
1106 } 1108 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 device->device_parser()->UpdateDeviceFromInfo(info, device); 1166 device->device_parser()->UpdateDeviceFromInfo(info, device);
1165 } else { 1167 } else {
1166 NativeNetworkDeviceParser parser; 1168 NativeNetworkDeviceParser parser;
1167 device = parser.CreateDeviceFromInfo(device_path, info); 1169 device = parser.CreateDeviceFromInfo(device_path, info);
1168 VLOG(2) << " Adding device: " << device_path; 1170 VLOG(2) << " Adding device: " << device_path;
1169 if (device) { 1171 if (device) {
1170 device_map_[device_path] = device; 1172 device_map_[device_path] = device;
1171 } 1173 }
1172 CHECK(device) << "Attempted to add NULL device for path: " << device_path; 1174 CHECK(device) << "Attempted to add NULL device for path: " << device_path;
1173 } 1175 }
1174 VLOG(1) << "ParseNetworkDevice:" << device->name(); 1176 VLOG(2) << "ParseNetworkDevice:" << device->name();
1175 if (device && device->type() == TYPE_CELLULAR) { 1177 if (device && device->type() == TYPE_CELLULAR) {
1176 if (!device->data_roaming_allowed() && IsCellularAlwaysInRoaming()) { 1178 if (!device->data_roaming_allowed() && IsCellularAlwaysInRoaming()) {
1177 SetCellularDataRoamingAllowed(true); 1179 SetCellularDataRoamingAllowed(true);
1178 } else { 1180 } else {
1179 bool settings_value; 1181 bool settings_value;
1180 if (CrosSettings::Get()->GetBoolean( 1182 if (CrosSettings::Get()->GetBoolean(
1181 kSignedDataRoamingEnabled, &settings_value) && 1183 kSignedDataRoamingEnabled, &settings_value) &&
1182 device->data_roaming_allowed() != settings_value) { 1184 device->data_roaming_allowed() != settings_value) {
1183 // Switch back to signed settings value. 1185 // Switch back to signed settings value.
1184 SetCellularDataRoamingAllowed(settings_value); 1186 SetCellularDataRoamingAllowed(settings_value);
1185 } 1187 }
1186 } 1188 }
1187 } 1189 }
1188 NotifyNetworkManagerChanged(false); // Not forced. 1190 NotifyNetworkManagerChanged(false); // Not forced.
1189 AddNetworkDeviceObserver(device_path, network_device_observer_.get()); 1191 AddNetworkDeviceObserver(device_path, network_device_observer_.get());
1190 } 1192 }
1191 1193
1192 } // namespace chromeos 1194 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/network_library_impl_base.cc ('k') | chrome/browser/chromeos/cros/network_library_impl_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698