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

Side by Side Diff: net/base/net_util_win.cc

Issue 92173002: Merge 237541 "Revert of https://codereview.chromium.org/71013004/" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1721/src/
Patch Set: Created 7 years 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 | « device/bluetooth/bluetooth_task_manager_win.cc ('k') | printing/backend/win_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <iphlpapi.h> 7 #include <iphlpapi.h>
8 #include <wlanapi.h> 8 #include <wlanapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ::GetProcAddress(module, "WlanQueryInterface")); 54 ::GetProcAddress(module, "WlanQueryInterface"));
55 free_memory_func = reinterpret_cast<WlanFreeMemoryFunc>( 55 free_memory_func = reinterpret_cast<WlanFreeMemoryFunc>(
56 ::GetProcAddress(module, "WlanFreeMemory")); 56 ::GetProcAddress(module, "WlanFreeMemory"));
57 close_handle_func = reinterpret_cast<WlanCloseHandleFunc>( 57 close_handle_func = reinterpret_cast<WlanCloseHandleFunc>(
58 ::GetProcAddress(module, "WlanCloseHandle")); 58 ::GetProcAddress(module, "WlanCloseHandle"));
59 initialized = open_handle_func && enum_interfaces_func && 59 initialized = open_handle_func && enum_interfaces_func &&
60 query_interface_func && free_memory_func && 60 query_interface_func && free_memory_func &&
61 close_handle_func; 61 close_handle_func;
62 } 62 }
63 63
64 template <typename T>
65 DWORD OpenHandle(DWORD client_version, DWORD* cur_version, T* handle) const {
66 HANDLE temp_handle;
67 DWORD result = open_handle_func(client_version, NULL, cur_version,
68 &temp_handle);
69 if (result != ERROR_SUCCESS)
70 return result;
71 handle->Set(temp_handle);
72 return ERROR_SUCCESS;
73 }
74
75 HMODULE module; 64 HMODULE module;
76 WlanOpenHandleFunc open_handle_func; 65 WlanOpenHandleFunc open_handle_func;
77 WlanEnumInterfacesFunc enum_interfaces_func; 66 WlanEnumInterfacesFunc enum_interfaces_func;
78 WlanQueryInterfaceFunc query_interface_func; 67 WlanQueryInterfaceFunc query_interface_func;
79 WlanFreeMemoryFunc free_memory_func; 68 WlanFreeMemoryFunc free_memory_func;
80 WlanCloseHandleFunc close_handle_func; 69 WlanCloseHandleFunc close_handle_func;
81 bool initialized; 70 bool initialized;
82 }; 71 };
83 72
84 } // namespace 73 } // namespace
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 229 }
241 }; 230 };
242 231
243 const WlanApi& wlanapi = lazy_wlanapi.Get(); 232 const WlanApi& wlanapi = lazy_wlanapi.Get();
244 if (!wlanapi.initialized) 233 if (!wlanapi.initialized)
245 return WIFI_PHY_LAYER_PROTOCOL_NONE; 234 return WIFI_PHY_LAYER_PROTOCOL_NONE;
246 235
247 WlanHandle client; 236 WlanHandle client;
248 DWORD cur_version = 0; 237 DWORD cur_version = 0;
249 const DWORD kMaxClientVersion = 2; 238 const DWORD kMaxClientVersion = 2;
250 DWORD result = wlanapi.OpenHandle(kMaxClientVersion, &cur_version, &client); 239 DWORD result = wlanapi.open_handle_func(kMaxClientVersion, NULL, &cur_version,
240 client.Receive());
251 if (result != ERROR_SUCCESS) 241 if (result != ERROR_SUCCESS)
252 return WIFI_PHY_LAYER_PROTOCOL_NONE; 242 return WIFI_PHY_LAYER_PROTOCOL_NONE;
253 243
254 WLAN_INTERFACE_INFO_LIST* interface_list_ptr = NULL; 244 WLAN_INTERFACE_INFO_LIST* interface_list_ptr = NULL;
255 result = wlanapi.enum_interfaces_func(client, NULL, &interface_list_ptr); 245 result = wlanapi.enum_interfaces_func(client, NULL, &interface_list_ptr);
256 if (result != ERROR_SUCCESS) 246 if (result != ERROR_SUCCESS)
257 return WIFI_PHY_LAYER_PROTOCOL_NONE; 247 return WIFI_PHY_LAYER_PROTOCOL_NONE;
258 scoped_ptr<WLAN_INTERFACE_INFO_LIST, WlanApiDeleter> interface_list( 248 scoped_ptr<WLAN_INTERFACE_INFO_LIST, WlanApiDeleter> interface_list(
259 interface_list_ptr); 249 interface_list_ptr);
260 250
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 case dot11_phy_type_erp: 286 case dot11_phy_type_erp:
297 return WIFI_PHY_LAYER_PROTOCOL_G; 287 return WIFI_PHY_LAYER_PROTOCOL_G;
298 case dot11_phy_type_ht: 288 case dot11_phy_type_ht:
299 return WIFI_PHY_LAYER_PROTOCOL_N; 289 return WIFI_PHY_LAYER_PROTOCOL_N;
300 default: 290 default:
301 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; 291 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN;
302 } 292 }
303 } 293 }
304 294
305 } // namespace net 295 } // namespace net
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_task_manager_win.cc ('k') | printing/backend/win_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698