#include "net/proxy_resolution/multi_threaded_proxy_resolver.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/containers/circular_deque.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "base/threading/thread_checker.h"
#include "base/threading/thread_restrictions.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_event_type.h"
#include "net/log/net_log_with_source.h"
#include "net/proxy_resolution/proxy_info.h"
#include "net/proxy_resolution/proxy_resolver.h"
namespace net {
class NetworkAnonymizationKey;
class MultiThreadedProxyResolverScopedAllowJoinOnIO
: public base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope { … };
namespace {
class Job;
class Executor : public base::RefCountedThreadSafe<Executor> { … };
class MultiThreadedProxyResolver : public ProxyResolver,
public Executor::Coordinator { … };
class Job : public base::RefCountedThreadSafe<Job> { … };
class MultiThreadedProxyResolver::RequestImpl : public ProxyResolver::Request { … };
class CreateResolverJob : public Job { … };
class MultiThreadedProxyResolver::GetProxyForURLJob : public Job { … };
Executor::Executor(Executor::Coordinator* coordinator, int thread_number)
: … { … }
void Executor::StartJob(scoped_refptr<Job> job) { … }
void Executor::OnJobCompleted(Job* job) { … }
void Executor::Destroy() { … }
Executor::~Executor() { … }
MultiThreadedProxyResolver::MultiThreadedProxyResolver(
std::unique_ptr<ProxyResolverFactory> resolver_factory,
size_t max_num_threads,
const scoped_refptr<PacFileData>& script_data,
scoped_refptr<Executor> executor)
: … { … }
MultiThreadedProxyResolver::~MultiThreadedProxyResolver() { … }
int MultiThreadedProxyResolver::GetProxyForURL(
const GURL& url,
const NetworkAnonymizationKey& network_anonymization_key,
ProxyInfo* results,
CompletionOnceCallback callback,
std::unique_ptr<Request>* request,
const NetLogWithSource& net_log) { … }
Executor* MultiThreadedProxyResolver::FindIdleExecutor() { … }
void MultiThreadedProxyResolver::AddNewExecutor() { … }
void MultiThreadedProxyResolver::OnExecutorReady(Executor* executor) { … }
}
class MultiThreadedProxyResolverFactory::Job
: public ProxyResolverFactory::Request,
public Executor::Coordinator { … };
MultiThreadedProxyResolverFactory::MultiThreadedProxyResolverFactory(
size_t max_num_threads,
bool factory_expects_bytes)
: … { … }
MultiThreadedProxyResolverFactory::~MultiThreadedProxyResolverFactory() { … }
int MultiThreadedProxyResolverFactory::CreateProxyResolver(
const scoped_refptr<PacFileData>& pac_script,
std::unique_ptr<ProxyResolver>* resolver,
CompletionOnceCallback callback,
std::unique_ptr<Request>* request) { … }
void MultiThreadedProxyResolverFactory::RemoveJob(
MultiThreadedProxyResolverFactory::Job* job) { … }
}