Reland "Implement the WindowsSystemProxyResolutionService/Request"

This is a reland of 33f234e709a171acce00d6c4103b9730db303332

This change differs from the original change in that:
- This one dynamically loads WinHttp functions that are not supported
  in Windows 7 and below (see WinHttpProxyResolverFunctions).
- This change fixes a string copy issue in the unit tests.

This change creates a functional proxy resolver for Windows that relies
on WinHttp APIs. This is not in its final state, though. This CL
represents the simplest, least-work way to implement this proxy
resolution service. Work still to come includes:
- Complete NetLogs
- Better error reporting from WinHttp APIs
- Proxy Delegate
- Proxy retry info
- Assurance that the proxy configs we're receiving are from the system

The WindowsSystemProxyResolutionService is the object that external
callers use to resolve a proxy. These callers can keep track of the
status of this proxy resolution via a ProxyResolutionRequest,
implemented here as a WindowsSystemProxyResolutionRequest. The request
object is mainly intended to kick off a specific proxy resolution and
report a result via a caller-provided callback. Both of these objects
deal with a WindowsSystemProxyResolver.

The WindowsSystemProxyResolver is a new class that does all the required
interfacing with WinHttp APIs. It is a reference counted object created
by the WindowsSystemProxyResolutionService. Once created, it is used for
the lifetime of the WindowsSystemProxyResolutionService. Throughout that
time, the Resolver indirectly keeps a WinHttp session handle open. Each
WindowsSystemProxyResolutionRequest is given a reference to the new
resolver. When the Request object attempts to resolve a proxy for a
given URL, it'll call into the Resolver object. Under the hood, the
Resolver object creates a handle for the proxy resolution and runs the
async call to WinHttp. At any time, the Request object can choose to
ignore a pending result from the Resolver (ex: shutdown). The Resolver
object must be reference counted because async WinHttp calls call back
directly into the Resolver object, so it needs to stay alive as long as
we're waiting for an async response from WinHttp.

Another new object is the WinHttpAPIWrapper, which is just a thin
wrapper over WinHttp APIs which we use to enable easier testing and
to simplify some interactions with WinHttp. A WinHttpAPIWrapper is owned
by a WindowsSystemProxyResolver. The Resolver object is the only object
that should interact with the Wrapper object in any meaningful way.
Internally, the WinHttpAPIWrapper keeps track of the opened WinHttp
session handle that we're using for the lifetime of the Resolver object.

This feature is only supported in Windows 8 and above. Prior versions
of Windows will not be able to instantiate the
WindowsSystemProxyResolutionService. Loading the right functions for
Windows 8+ is handled by the WinHttpProxyResolverFunctions singleton.

This change includes tests for the WindowsSystemProxyResolver layer (by
mocking out the WinHttpAPIWrapper) and the
WindowsSystemProxyResolutionService (by mocking out the
WindowsSystemProxyResolver).

Bug: 1032820
Change-Id: I1075e5c918e5aa14f7317853e6a39103ad9383d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2310672
Reviewed-by: Ramin Halavati <[email protected]>
Reviewed-by: Bruce Dawson <[email protected]>
Reviewed-by: Eric Roman <[email protected]>
Commit-Queue: Nicolas Arciniega <[email protected]>
Cr-Commit-Position: refs/heads/master@{#792787}
16 files changed
tree: 5633cd8a4e0dd815d160970401a682d77afd8389
  1. android_webview/
  2. apps/
  3. ash/
  4. base/
  5. build/
  6. build_overrides/
  7. buildtools/
  8. cc/
  9. chrome/
  10. chromecast/
  11. chromeos/
  12. cloud_print/
  13. components/
  14. content/
  15. courgette/
  16. crypto/
  17. dbus/
  18. device/
  19. docs/
  20. extensions/
  21. fuchsia/
  22. gin/
  23. google_apis/
  24. google_update/
  25. gpu/
  26. headless/
  27. infra/
  28. ios/
  29. ipc/
  30. jingle/
  31. media/
  32. mojo/
  33. native_client_sdk/
  34. net/
  35. pdf/
  36. ppapi/
  37. printing/
  38. remoting/
  39. rlz/
  40. sandbox/
  41. services/
  42. skia/
  43. sql/
  44. storage/
  45. styleguide/
  46. testing/
  47. third_party/
  48. tools/
  49. ui/
  50. url/
  51. weblayer/
  52. .clang-format
  53. .clang-tidy
  54. .eslintrc.js
  55. .git-blame-ignore-revs
  56. .gitattributes
  57. .gitignore
  58. .gn
  59. .vpython
  60. .vpython3
  61. .yapfignore
  62. AUTHORS
  63. BUILD.gn
  64. CODE_OF_CONDUCT.md
  65. codereview.settings
  66. DEPS
  67. DIR_METADATA
  68. ENG_REVIEW_OWNERS
  69. LICENSE
  70. LICENSE.chromium_os
  71. OWNERS
  72. PRESUBMIT.py
  73. PRESUBMIT_test.py
  74. PRESUBMIT_test_mocks.py
  75. README.md
  76. WATCHLISTS
README.md

Logo Chromium

Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.

The project's web site is https://www.chromium.org.

Documentation in the source is rooted in docs/README.md.

Learn how to Get Around the Chromium Source Code Directory Structure .

For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.