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

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

Issue 647883002: git cl format the final third of the net/base directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 #ifndef NET_BASE_NET_UTIL_WIN_H_ 5 #ifndef NET_BASE_NET_UTIL_WIN_H_
6 #define NET_BASE_NET_UTIL_WIN_H_ 6 #define NET_BASE_NET_UTIL_WIN_H_
7 7
8 // This file is only used to expose some of the internals 8 // This file is only used to expose some of the internals
9 // of net_util_win.cc to tests. 9 // of net_util_win.cc to tests.
10 10
11 #include <wlanapi.h> 11 #include <wlanapi.h>
12 12
13 #include "base/win/scoped_handle.h" 13 #include "base/win/scoped_handle.h"
14 #include "net/base/net_export.h" 14 #include "net/base/net_export.h"
15 15
16 namespace net { 16 namespace net {
17 namespace internal { 17 namespace internal {
18 18
19 struct NET_EXPORT WlanApi { 19 struct NET_EXPORT WlanApi {
20 typedef DWORD (WINAPI *WlanOpenHandleFunc)( 20 typedef DWORD(WINAPI* WlanOpenHandleFunc)(DWORD, VOID*, DWORD*, HANDLE*);
21 DWORD, VOID*, DWORD*, HANDLE*); 21 typedef DWORD(WINAPI* WlanEnumInterfacesFunc)(HANDLE,
22 typedef DWORD (WINAPI *WlanEnumInterfacesFunc)( 22 VOID*,
23 HANDLE, VOID*, WLAN_INTERFACE_INFO_LIST**); 23 WLAN_INTERFACE_INFO_LIST**);
24 typedef DWORD (WINAPI *WlanQueryInterfaceFunc)( 24 typedef DWORD(WINAPI* WlanQueryInterfaceFunc)(HANDLE,
25 HANDLE, const GUID*, WLAN_INTF_OPCODE, VOID*, DWORD*, VOID**, 25 const GUID*,
26 WLAN_OPCODE_VALUE_TYPE*); 26 WLAN_INTF_OPCODE,
27 typedef DWORD (WINAPI *WlanSetInterfaceFunc)( 27 VOID*,
28 HANDLE, const GUID*, WLAN_INTF_OPCODE, DWORD, const VOID*, VOID*); 28 DWORD*,
29 typedef VOID (WINAPI *WlanFreeMemoryFunc)(VOID*); 29 VOID**,
30 typedef DWORD (WINAPI *WlanCloseHandleFunc)(HANDLE, VOID*); 30 WLAN_OPCODE_VALUE_TYPE*);
31 typedef DWORD(WINAPI* WlanSetInterfaceFunc)(HANDLE,
32 const GUID*,
33 WLAN_INTF_OPCODE,
34 DWORD,
35 const VOID*,
36 VOID*);
37 typedef VOID(WINAPI* WlanFreeMemoryFunc)(VOID*);
38 typedef DWORD(WINAPI* WlanCloseHandleFunc)(HANDLE, VOID*);
31 39
32 WlanApi(); 40 WlanApi();
33 static WlanApi& GetInstance(); 41 static WlanApi& GetInstance();
34 42
35 template <typename T> 43 template <typename T>
36 DWORD OpenHandle(DWORD client_version, DWORD* cur_version, T* handle) const { 44 DWORD OpenHandle(DWORD client_version, DWORD* cur_version, T* handle) const {
37 HANDLE temp_handle; 45 HANDLE temp_handle;
38 DWORD result = open_handle_func(client_version, NULL, cur_version, 46 DWORD result =
39 &temp_handle); 47 open_handle_func(client_version, NULL, cur_version, &temp_handle);
40 if (result != ERROR_SUCCESS) 48 if (result != ERROR_SUCCESS)
41 return result; 49 return result;
42 handle->Set(temp_handle); 50 handle->Set(temp_handle);
43 return ERROR_SUCCESS; 51 return ERROR_SUCCESS;
44 } 52 }
45 53
46 HMODULE module; 54 HMODULE module;
47 WlanOpenHandleFunc open_handle_func; 55 WlanOpenHandleFunc open_handle_func;
48 WlanEnumInterfacesFunc enum_interfaces_func; 56 WlanEnumInterfacesFunc enum_interfaces_func;
49 WlanQueryInterfaceFunc query_interface_func; 57 WlanQueryInterfaceFunc query_interface_func;
50 WlanSetInterfaceFunc set_interface_func; 58 WlanSetInterfaceFunc set_interface_func;
51 WlanFreeMemoryFunc free_memory_func; 59 WlanFreeMemoryFunc free_memory_func;
52 WlanCloseHandleFunc close_handle_func; 60 WlanCloseHandleFunc close_handle_func;
53 bool initialized; 61 bool initialized;
54 }; 62 };
55 63
56 struct WlanApiHandleTraits { 64 struct WlanApiHandleTraits {
57 typedef HANDLE Handle; 65 typedef HANDLE Handle;
58 66
59 static bool CloseHandle(HANDLE handle) { 67 static bool CloseHandle(HANDLE handle) {
60 return WlanApi::GetInstance().close_handle_func(handle, NULL) == 68 return WlanApi::GetInstance().close_handle_func(handle, NULL) ==
61 ERROR_SUCCESS; 69 ERROR_SUCCESS;
62 } 70 }
63 static bool IsHandleValid(HANDLE handle) { 71 static bool IsHandleValid(HANDLE handle) {
64 return base::win::HandleTraits::IsHandleValid(handle); 72 return base::win::HandleTraits::IsHandleValid(handle);
65 } 73 }
66 static HANDLE NullHandle() { 74 static HANDLE NullHandle() { return base::win::HandleTraits::NullHandle(); }
67 return base::win::HandleTraits::NullHandle();
68 }
69 }; 75 };
70 76
71 typedef base::win::GenericScopedHandle< 77 typedef base::win::GenericScopedHandle<WlanApiHandleTraits,
72 WlanApiHandleTraits, 78 base::win::DummyVerifierTraits>
73 base::win::DummyVerifierTraits> WlanHandle; 79 WlanHandle;
74 80
75 struct WlanApiDeleter { 81 struct WlanApiDeleter {
76 inline void operator()(void* ptr) const { 82 inline void operator()(void* ptr) const {
77 WlanApi::GetInstance().free_memory_func(ptr); 83 WlanApi::GetInstance().free_memory_func(ptr);
78 } 84 }
79 }; 85 };
80 86
81 } // namespace internal 87 } // namespace internal
82 88
83 } // namespace net 89 } // namespace net
84 90
85 #endif // NET_BASE_NET_UTIL_WIN_H_ 91 #endif // NET_BASE_NET_UTIL_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698