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

Side by Side Diff: components/wifi/wifi_service_win.cc

Issue 250223002: Ignore ERROR_ADDRESS_NOT_ASSOCIATED from IpReleaseAddress in WiFiService::ResetDHCP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | components/wifi/wifi_test.cc » ('j') | components/wifi/wifi_test.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/wifi/wifi_service.h" 5 #include "components/wifi/wifi_service.h"
6 6
7 #include <iphlpapi.h> 7 #include <iphlpapi.h>
8 #include <objbase.h> 8 #include <objbase.h>
9 #include <wlanapi.h> 9 #include <wlanapi.h>
10 10
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 NetworkProperties connected_network_properties; 897 NetworkProperties connected_network_properties;
898 DWORD error = GetConnectedProperties(&connected_network_properties); 898 DWORD error = GetConnectedProperties(&connected_network_properties);
899 if (network_guid == connected_network_properties.guid && 899 if (network_guid == connected_network_properties.guid &&
900 connected_network_properties.connection_state == 900 connected_network_properties.connection_state ==
901 onc::connection_state::kConnected) { 901 onc::connection_state::kConnected) {
902 DVLOG(1) << "WiFi Connected, Reset DHCP: " << network_guid; 902 DVLOG(1) << "WiFi Connected, Reset DHCP: " << network_guid;
903 // Even though wireless network is now connected, it may still be unusable, 903 // Even though wireless network is now connected, it may still be unusable,
904 // e.g. after Chromecast device reset. Reset DHCP on wireless network to 904 // e.g. after Chromecast device reset. Reset DHCP on wireless network to
905 // work around this issue. 905 // work around this issue.
906 error = ResetDHCP(); 906 error = ResetDHCP();
907 if (error != ERROR_SUCCESS)
908 LOG(ERROR) << error;
afontan 2014/04/23 21:04:16 You are logging it twice as ResetDHCP already logs
mef 2014/04/23 21:41:23 Done.
907 // There is no need to keep created profile as network is connected. 909 // There is no need to keep created profile as network is connected.
908 created_profiles_.RemoveWithoutPathExpansion(network_guid, NULL); 910 created_profiles_.RemoveWithoutPathExpansion(network_guid, NULL);
909 // Restore previously suppressed notifications. 911 // Restore previously suppressed notifications.
910 enable_notify_network_changed_ = true; 912 enable_notify_network_changed_ = true;
911 RestoreNwCategoryWizard(); 913 RestoreNwCategoryWizard();
912 NotifyNetworkChanged(network_guid); 914 NotifyNetworkChanged(network_guid);
913 } else { 915 } else {
914 // Continue waiting for network connection state change. 916 // Continue waiting for network connection state change.
915 task_runner_->PostDelayedTask( 917 task_runner_->PostDelayedTask(
916 FROM_HERE, 918 FROM_HERE,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 } 964 }
963 965
964 void WiFiServiceImpl::SortNetworks(NetworkList* networks) { 966 void WiFiServiceImpl::SortNetworks(NetworkList* networks) {
965 networks->sort(NetworkProperties::OrderByType); 967 networks->sort(NetworkProperties::OrderByType);
966 } 968 }
967 969
968 DWORD WiFiServiceImpl::LoadWlanLibrary() { 970 DWORD WiFiServiceImpl::LoadWlanLibrary() {
969 // Use an absolute path to load the DLL to avoid DLL preloading attacks. 971 // Use an absolute path to load the DLL to avoid DLL preloading attacks.
970 base::FilePath path; 972 base::FilePath path;
971 if (!PathService::Get(base::DIR_SYSTEM, &path)) { 973 if (!PathService::Get(base::DIR_SYSTEM, &path)) {
972 DLOG(ERROR) << "Unable to get system path."; 974 LOG(ERROR) << "Unable to get system path.";
973 return ERROR_NOT_FOUND; 975 return ERROR_NOT_FOUND;
974 } 976 }
975 wlan_api_library_ = ::LoadLibraryEx(path.Append(kWlanApiDll).value().c_str(), 977 wlan_api_library_ = ::LoadLibraryEx(path.Append(kWlanApiDll).value().c_str(),
976 NULL, 978 NULL,
977 LOAD_WITH_ALTERED_SEARCH_PATH); 979 LOAD_WITH_ALTERED_SEARCH_PATH);
978 if (!wlan_api_library_) { 980 if (!wlan_api_library_) {
979 DLOG(ERROR) << "Unable to load WlanApi.dll."; 981 LOG(ERROR) << "Unable to load WlanApi.dll.";
980 return ERROR_NOT_FOUND; 982 return ERROR_NOT_FOUND;
981 } 983 }
982 984
983 // Initialize WlanApi function pointers 985 // Initialize WlanApi function pointers
984 WlanConnect_function_ = 986 WlanConnect_function_ =
985 reinterpret_cast<WlanConnectFunction>( 987 reinterpret_cast<WlanConnectFunction>(
986 ::GetProcAddress(wlan_api_library_, kWlanConnect)); 988 ::GetProcAddress(wlan_api_library_, kWlanConnect));
987 WlanCloseHandle_function_ = 989 WlanCloseHandle_function_ =
988 reinterpret_cast<WlanCloseHandleFunction>( 990 reinterpret_cast<WlanCloseHandleFunction>(
989 ::GetProcAddress(wlan_api_library_, kWlanCloseHandle)); 991 ::GetProcAddress(wlan_api_library_, kWlanCloseHandle));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 !WlanDisconnect_function_ || 1035 !WlanDisconnect_function_ ||
1034 !WlanEnumInterfaces_function_ || 1036 !WlanEnumInterfaces_function_ ||
1035 !WlanFreeMemory_function_ || 1037 !WlanFreeMemory_function_ ||
1036 !WlanGetAvailableNetworkList_function_ || 1038 !WlanGetAvailableNetworkList_function_ ||
1037 !WlanGetProfile_function_ || 1039 !WlanGetProfile_function_ ||
1038 !WlanOpenHandle_function_ || 1040 !WlanOpenHandle_function_ ||
1039 !WlanQueryInterface_function_ || 1041 !WlanQueryInterface_function_ ||
1040 !WlanRegisterNotification_function_ || 1042 !WlanRegisterNotification_function_ ||
1041 !WlanScan_function_ || 1043 !WlanScan_function_ ||
1042 !WlanSetProfile_function_) { 1044 !WlanSetProfile_function_) {
1043 DLOG(ERROR) << "Unable to find required WlanApi function."; 1045 LOG(ERROR) << "Unable to find required WlanApi function.";
1044 FreeLibrary(wlan_api_library_); 1046 FreeLibrary(wlan_api_library_);
1045 wlan_api_library_ = NULL; 1047 wlan_api_library_ = NULL;
1046 return ERROR_NOT_FOUND; 1048 return ERROR_NOT_FOUND;
1047 } 1049 }
1048 1050
1049 // Some WlanApi functions may not be available on XP. 1051 // Some WlanApi functions may not be available on XP.
1050 if (!WlanGetNetworkBssList_function_ || 1052 if (!WlanGetNetworkBssList_function_ ||
1051 !WlanSaveTemporaryProfile_function_) { 1053 !WlanSaveTemporaryProfile_function_) {
1052 DVLOG(1) << "WlanApi function is not be available on XP."; 1054 DVLOG(1) << "WlanApi function is not be available on XP.";
1053 } 1055 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 // Clean up.. 1091 // Clean up..
1090 if (interface_list != NULL) 1092 if (interface_list != NULL)
1091 WlanFreeMemory_function_(interface_list); 1093 WlanFreeMemory_function_(interface_list);
1092 } 1094 }
1093 return error; 1095 return error;
1094 } 1096 }
1095 1097
1096 DWORD WiFiServiceImpl::ResetDHCP() { 1098 DWORD WiFiServiceImpl::ResetDHCP() {
1097 IP_ADAPTER_INDEX_MAP adapter_index_map = {0}; 1099 IP_ADAPTER_INDEX_MAP adapter_index_map = {0};
1098 DWORD error = FindAdapterIndexMapByGUID(interface_guid_, &adapter_index_map); 1100 DWORD error = FindAdapterIndexMapByGUID(interface_guid_, &adapter_index_map);
1099 if (error == ERROR_SUCCESS) { 1101 if (error != ERROR_SUCCESS) {
1100 error = ::IpReleaseAddress(&adapter_index_map); 1102 LOG(ERROR) << error;
1101 if (error == ERROR_SUCCESS) { 1103 return error;
1102 error = ::IpRenewAddress(&adapter_index_map); 1104 }
1105 error = ::IpReleaseAddress(&adapter_index_map);
1106 if (error != ERROR_SUCCESS) {
1107 if (error != ERROR_ADDRESS_NOT_ASSOCIATED) {
1108 LOG(ERROR) << error;
1109 return error;
1103 } 1110 }
1111 DVLOG(1) << "Ignoring IpReleaseAddress Error: " << error;
1104 } 1112 }
1113 error = ::IpRenewAddress(&adapter_index_map);
1114 if (error != ERROR_SUCCESS)
1115 LOG(ERROR) << error;
1105 return error; 1116 return error;
1106 } 1117 }
1107 1118
1108 DWORD WiFiServiceImpl::FindAdapterIndexMapByGUID( 1119 DWORD WiFiServiceImpl::FindAdapterIndexMapByGUID(
1109 const GUID& interface_guid, 1120 const GUID& interface_guid,
1110 IP_ADAPTER_INDEX_MAP* adapter_index_map) { 1121 IP_ADAPTER_INDEX_MAP* adapter_index_map) {
1111 base::string16 guid_string; 1122 base::string16 guid_string;
1112 const int kGUIDSize = 39; 1123 const int kGUIDSize = 39;
1113 ::StringFromGUID2( 1124 ::StringFromGUID2(
1114 interface_guid, WriteInto(&guid_string, kGUIDSize), kGUIDSize); 1125 interface_guid, WriteInto(&guid_string, kGUIDSize), kGUIDSize);
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 NetworkGuidList changed_networks(1, network_guid); 1829 NetworkGuidList changed_networks(1, network_guid);
1819 message_loop_proxy_->PostTask( 1830 message_loop_proxy_->PostTask(
1820 FROM_HERE, 1831 FROM_HERE,
1821 base::Bind(networks_changed_observer_, changed_networks)); 1832 base::Bind(networks_changed_observer_, changed_networks));
1822 } 1833 }
1823 } 1834 }
1824 1835
1825 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } 1836 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); }
1826 1837
1827 } // namespace wifi 1838 } // namespace wifi
OLDNEW
« no previous file with comments | « no previous file | components/wifi/wifi_test.cc » ('j') | components/wifi/wifi_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698