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