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

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

Issue 566243005: Cast: Allow extension to control wifi options on windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 years, 3 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
« no previous file with comments | « net/base/net_util_unittest.cc ('k') | net/base/net_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_BASE_NET_UTIL_WIN_H_
6 #define NET_BASE_NET_UTIL_WIN_H_
7
8 // This file is only used to expose some of the internals
9 // of net_util_win.cc to tests.
10
11 #include <wlanapi.h>
12
13 #include "base/win/scoped_handle.h"
14 #include "net/base/net_export.h"
15
16 namespace net {
17 namespace internal {
18
19 struct NET_EXPORT WlanApi {
20 typedef DWORD (WINAPI *WlanOpenHandleFunc)(
21 DWORD, VOID*, DWORD*, HANDLE*);
22 typedef DWORD (WINAPI *WlanEnumInterfacesFunc)(
23 HANDLE, VOID*, WLAN_INTERFACE_INFO_LIST**);
24 typedef DWORD (WINAPI *WlanQueryInterfaceFunc)(
25 HANDLE, const GUID*, WLAN_INTF_OPCODE, VOID*, DWORD*, VOID**,
26 WLAN_OPCODE_VALUE_TYPE*);
27 typedef DWORD (WINAPI *WlanSetInterfaceFunc)(
28 HANDLE, const GUID*, WLAN_INTF_OPCODE, DWORD, const VOID*, VOID*);
29 typedef VOID (WINAPI *WlanFreeMemoryFunc)(VOID*);
30 typedef DWORD (WINAPI *WlanCloseHandleFunc)(HANDLE, VOID*);
31
32 WlanApi();
33 static WlanApi& GetInstance();
34
35 template <typename T>
36 DWORD OpenHandle(DWORD client_version, DWORD* cur_version, T* handle) const {
37 HANDLE temp_handle;
38 DWORD result = open_handle_func(client_version, NULL, cur_version,
39 &temp_handle);
40 if (result != ERROR_SUCCESS)
41 return result;
42 handle->Set(temp_handle);
43 return ERROR_SUCCESS;
44 }
45
46 HMODULE module;
47 WlanOpenHandleFunc open_handle_func;
48 WlanEnumInterfacesFunc enum_interfaces_func;
49 WlanQueryInterfaceFunc query_interface_func;
50 WlanSetInterfaceFunc set_interface_func;
51 WlanFreeMemoryFunc free_memory_func;
52 WlanCloseHandleFunc close_handle_func;
53 bool initialized;
54 };
55
56 struct WlanApiHandleTraits {
57 typedef HANDLE Handle;
58
59 static bool CloseHandle(HANDLE handle) {
60 return WlanApi::GetInstance().close_handle_func(handle, NULL) ==
61 ERROR_SUCCESS;
62 }
63 static bool IsHandleValid(HANDLE handle) {
64 return base::win::HandleTraits::IsHandleValid(handle);
65 }
66 static HANDLE NullHandle() {
67 return base::win::HandleTraits::NullHandle();
68 }
69 };
70
71 typedef base::win::GenericScopedHandle<
72 WlanApiHandleTraits,
73 base::win::DummyVerifierTraits> WlanHandle;
74
75 struct WlanApiDeleter {
76 inline void operator()(void* ptr) const {
77 WlanApi::GetInstance().free_memory_func(ptr);
78 }
79 };
80
81 } // namespace internal
82
83 } // namespace net
84
85 #endif // NET_BASE_NET_UTIL_WIN_H_
OLDNEW
« no previous file with comments | « net/base/net_util_unittest.cc ('k') | net/base/net_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698