winhttp_proxy_resolver_functions.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2020 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. #ifndef SERVICES_PROXY_RESOLVER_WIN_WINHTTP_PROXY_RESOLVER_FUNCTIONS_H_
  5. #define SERVICES_PROXY_RESOLVER_WIN_WINHTTP_PROXY_RESOLVER_FUNCTIONS_H_
  6. #include <windows.h>
  7. #include <winhttp.h>
  8. #include "base/no_destructor.h"
  9. namespace proxy_resolver_win {
  10. // Not all WinHttp APIs we'll be using exist in all versions of Windows.
  11. // Several only exist in Windows 8+. Thus, each function entry point must be
  12. // loaded dynamically.
  13. struct WinHttpProxyResolverFunctions {
  14. public:
  15. WinHttpProxyResolverFunctions(const WinHttpProxyResolverFunctions&) = delete;
  16. WinHttpProxyResolverFunctions& operator=(
  17. const WinHttpProxyResolverFunctions&) = delete;
  18. bool are_all_functions_loaded() const;
  19. static const WinHttpProxyResolverFunctions& GetInstance();
  20. using WinHttpCreateProxyResolverFunc = decltype(WinHttpCreateProxyResolver)*;
  21. using WinHttpGetProxyForUrlExFunc = decltype(WinHttpGetProxyForUrlEx)*;
  22. using WinHttpGetProxyResultFunc = decltype(WinHttpGetProxyResult)*;
  23. using WinHttpFreeProxyResultFunc = decltype(WinHttpFreeProxyResult)*;
  24. WinHttpCreateProxyResolverFunc create_proxy_resolver = nullptr;
  25. WinHttpGetProxyForUrlExFunc get_proxy_for_url_ex = nullptr;
  26. WinHttpGetProxyResultFunc get_proxy_result = nullptr;
  27. WinHttpFreeProxyResultFunc free_proxy_result = nullptr;
  28. private:
  29. friend class base::NoDestructor<WinHttpProxyResolverFunctions>;
  30. WinHttpProxyResolverFunctions();
  31. ~WinHttpProxyResolverFunctions();
  32. };
  33. } // namespace proxy_resolver_win
  34. #endif // SERVICES_PROXY_RESOLVER_WIN_WINHTTP_PROXY_RESOLVER_FUNCTIONS_H_