proxy_resolver.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2011 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 NET_PROXY_RESOLUTION_PROXY_RESOLVER_H_
  5. #define NET_PROXY_RESOLUTION_PROXY_RESOLVER_H_
  6. #include "base/callback_forward.h"
  7. #include "base/memory/ref_counted.h"
  8. #include "net/base/completion_once_callback.h"
  9. #include "net/base/load_states.h"
  10. #include "net/base/net_export.h"
  11. #include "net/proxy_resolution/pac_file_data.h"
  12. #include "url/gurl.h"
  13. namespace net {
  14. class NetLogWithSource;
  15. class NetworkIsolationKey;
  16. class ProxyInfo;
  17. // Interface for "proxy resolvers". A ProxyResolver fills in a list of proxies
  18. // to use for a particular URL. Generally the backend for a ProxyResolver is
  19. // a PAC script, but it doesn't need to be. ProxyResolver can service multiple
  20. // requests at a time.
  21. class NET_EXPORT_PRIVATE ProxyResolver {
  22. public:
  23. class Request {
  24. public:
  25. virtual ~Request() = default; // Cancels the request
  26. virtual LoadState GetLoadState() = 0;
  27. };
  28. ProxyResolver() = default;
  29. ProxyResolver(const ProxyResolver&) = delete;
  30. ProxyResolver& operator=(const ProxyResolver&) = delete;
  31. virtual ~ProxyResolver() = default;
  32. // Gets a list of proxy servers to use for |url|. If the request will
  33. // complete asynchronously returns ERR_IO_PENDING and notifies the result
  34. // by running |callback|. If the result code is OK then
  35. // the request was successful and |results| contains the proxy
  36. // resolution information. In the case of asynchronous completion
  37. // |*request| is written to. Call request_.reset() to cancel the request.
  38. //
  39. // |network_isolation_key| is used for any DNS lookups associated with the
  40. // request, if net's HostResolver is used. If the underlying platform itself
  41. // handles proxy resolution, |network_isolation_key| will be ignored.
  42. virtual int GetProxyForURL(const GURL& url,
  43. const NetworkIsolationKey& network_isolation_key,
  44. ProxyInfo* results,
  45. CompletionOnceCallback callback,
  46. std::unique_ptr<Request>* request,
  47. const NetLogWithSource& net_log) = 0;
  48. };
  49. } // namespace net
  50. #endif // NET_PROXY_RESOLUTION_PROXY_RESOLVER_H_