#include "services/network/proxy_resolver_factory_mojo.h"
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "net/base/ip_address.h"
#include "net/base/load_states.h"
#include "net/base/net_errors.h"
#include "net/base/network_anonymization_key.h"
#include "net/log/net_log.h"
#include "net/log/net_log_capture_mode.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_with_source.h"
#include "net/proxy_resolution/pac_file_data.h"
#include "net/proxy_resolution/proxy_info.h"
#include "net/proxy_resolution/proxy_resolve_dns_operation.h"
#include "net/proxy_resolution/proxy_resolver.h"
#include "net/proxy_resolution/proxy_resolver_error_observer.h"
#include "services/network/mojo_host_resolver_impl.h"
#include "services/network/proxy_auto_config_library.h"
#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
namespace net {
class NetworkAnonymizationKey;
}
namespace network {
namespace {
base::Value::Dict NetLogErrorParams(int line_number,
const std::string& message) { … }
template <typename ClientInterface>
class ClientMixin : public ClientInterface { … };
class ProxyResolverMojo : public net::ProxyResolver { … };
class ProxyResolverMojo::Job
: public ProxyResolver::Request,
public ClientMixin<proxy_resolver::mojom::ProxyResolverRequestClient> { … };
ProxyResolverMojo::Job::Job(
ProxyResolverMojo* resolver,
const GURL& url,
const net::NetworkAnonymizationKey& network_anonymization_key,
net::ProxyInfo* results,
net::CompletionOnceCallback callback,
const net::NetLogWithSource& net_log)
: … { … }
ProxyResolverMojo::Job::~Job() { … }
net::LoadState ProxyResolverMojo::Job::GetLoadState() { … }
void ProxyResolverMojo::Job::OnMojoDisconnect() { … }
void ProxyResolverMojo::Job::CompleteRequest(int result) { … }
void ProxyResolverMojo::Job::ReportResult(int32_t error,
const net::ProxyInfo& proxy_info) { … }
ProxyResolverMojo::ProxyResolverMojo(
mojo::PendingRemote<proxy_resolver::mojom::ProxyResolver> resolver_remote,
net::HostResolver* host_resolver,
std::unique_ptr<net::ProxyResolverErrorObserver> error_observer,
net::NetLog* net_log)
: … { … }
ProxyResolverMojo::~ProxyResolverMojo() { … }
void ProxyResolverMojo::OnMojoDisconnect() { … }
int ProxyResolverMojo::GetProxyForURL(
const GURL& url,
const net::NetworkAnonymizationKey& network_anonymization_key,
net::ProxyInfo* results,
net::CompletionOnceCallback callback,
std::unique_ptr<Request>* request,
const net::NetLogWithSource& net_log) { … }
}
class ProxyResolverFactoryMojo::Job
: public ClientMixin<
proxy_resolver::mojom::ProxyResolverFactoryRequestClient>,
public ProxyResolverFactory::Request { … };
ProxyResolverFactoryMojo::ProxyResolverFactoryMojo(
mojo::PendingRemote<proxy_resolver::mojom::ProxyResolverFactory>
mojo_proxy_factory,
net::HostResolver* host_resolver,
const base::RepeatingCallback<
std::unique_ptr<net::ProxyResolverErrorObserver>()>&
error_observer_factory,
net::NetLog* net_log)
: … { … }
ProxyResolverFactoryMojo::~ProxyResolverFactoryMojo() = default;
int ProxyResolverFactoryMojo::CreateProxyResolver(
const scoped_refptr<net::PacFileData>& pac_script,
std::unique_ptr<net::ProxyResolver>* resolver,
net::CompletionOnceCallback callback,
std::unique_ptr<net::ProxyResolverFactory::Request>* request) { … }
}