Revert "Always activate MojoApplicationHost"
[chromium-blink-merge.git] / net / base / net_util_win.h
blobafa888b1320cf25b96be6555cc10acd9196aaa65
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.
5 #ifndef NET_BASE_NET_UTIL_WIN_H_
6 #define NET_BASE_NET_UTIL_WIN_H_
8 // This file is only used to expose some of the internals
9 // of net_util_win.cc to tests.
11 #include <wlanapi.h>
13 #include "base/win/scoped_handle.h"
14 #include "net/base/net_export.h"
16 namespace net {
17 namespace internal {
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*);
32 WlanApi();
33 static WlanApi& GetInstance();
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;
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;
56 struct WlanApiHandleTraits {
57 typedef HANDLE Handle;
59 static bool CloseHandle(HANDLE handle) {
60 return WlanApi::GetInstance().close_handle_func(handle, NULL) ==
61 ERROR_SUCCESS;
63 static bool IsHandleValid(HANDLE handle) {
64 return base::win::HandleTraits::IsHandleValid(handle);
66 static HANDLE NullHandle() {
67 return base::win::HandleTraits::NullHandle();
71 typedef base::win::GenericScopedHandle<
72 WlanApiHandleTraits,
73 base::win::DummyVerifierTraits> WlanHandle;
75 struct WlanApiDeleter {
76 inline void operator()(void* ptr) const {
77 WlanApi::GetInstance().free_memory_func(ptr);
81 } // namespace internal
83 } // namespace net
85 #endif // NET_BASE_NET_UTIL_WIN_H_