Rename net::Proxy::PacRequest to net::Proxy::Request
TBR=raymes@chromium.org TBR=dimich@chromium.org TBR=yhirano@chromium.org TBR=boliu@chromium.org Bug: 613640 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo Change-Id: I0841e8cd01a1eb970327a8a6247efac20ba734eb Reviewed-on: https://chromium-review.googlesource.com/847460 Commit-Queue: Lily Houghton <lilyhoughton@chromium.org> Reviewed-by: Bo <boliu@chromium.org> Reviewed-by: Eric Roman <eroman@chromium.org> Cr-Commit-Position: refs/heads/master@{#529071}
This commit is contained in:

committed by
Commit Bot

parent
76473d4ff5
commit
00e124d42c
content
google_apis/gcm/engine
net
http
proxy
url_request
services/network/public/cpp
@ -51,8 +51,8 @@ PepperNetworkProxyHost::~PepperNetworkProxyHost() {
|
||||
// If the proxy_service_ is NULL, we shouldn't have any outstanding
|
||||
// requests.
|
||||
DCHECK(proxy_service_);
|
||||
net::ProxyService::PacRequest* request = pending_requests_.front();
|
||||
proxy_service_->CancelPacRequest(request);
|
||||
net::ProxyService::Request* request = pending_requests_.front();
|
||||
proxy_service_->CancelRequest(request);
|
||||
pending_requests_.pop();
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,7 @@ void PepperNetworkProxyHost::TryToSendUnsentRequests() {
|
||||
} else {
|
||||
// Everything looks valid, so try to resolve the proxy.
|
||||
net::ProxyInfo* proxy_info = new net::ProxyInfo;
|
||||
net::ProxyService::PacRequest* pending_request = nullptr;
|
||||
net::ProxyService::Request* pending_request = nullptr;
|
||||
base::Callback<void(int)> callback =
|
||||
base::Bind(&PepperNetworkProxyHost::OnResolveProxyCompleted,
|
||||
weak_factory_.GetWeakPtr(),
|
||||
|
@ -97,7 +97,7 @@ class CONTENT_EXPORT PepperNetworkProxyHost : public ppapi::host::ResourceHost {
|
||||
|
||||
// Requests awaiting a response from ProxyService. We need to store these so
|
||||
// that we can cancel them if we get destroyed.
|
||||
base::queue<net::ProxyService::PacRequest*> pending_requests_;
|
||||
base::queue<net::ProxyService::Request*> pending_requests_;
|
||||
|
||||
base::WeakPtrFactory<PepperNetworkProxyHost> weak_factory_;
|
||||
|
||||
|
@ -50,7 +50,7 @@ ResolveProxyMsgHelper::~ResolveProxyMsgHelper() {
|
||||
// default request context or override).
|
||||
if (!pending_requests_.empty()) {
|
||||
PendingRequest req = pending_requests_.front();
|
||||
proxy_service_->CancelPacRequest(req.pac_req);
|
||||
proxy_service_->CancelRequest(req.request);
|
||||
}
|
||||
|
||||
for (PendingRequestList::iterator it = pending_requests_.begin();
|
||||
@ -82,7 +82,7 @@ void ResolveProxyMsgHelper::StartPendingRequest() {
|
||||
PendingRequest& req = pending_requests_.front();
|
||||
|
||||
// Verify the request wasn't started yet.
|
||||
DCHECK(nullptr == req.pac_req);
|
||||
DCHECK(nullptr == req.request);
|
||||
|
||||
if (context_getter_.get()) {
|
||||
proxy_service_ = context_getter_->GetURLRequestContext()->proxy_service();
|
||||
@ -94,7 +94,7 @@ void ResolveProxyMsgHelper::StartPendingRequest() {
|
||||
req.url, std::string(), &proxy_info_,
|
||||
base::Bind(&ResolveProxyMsgHelper::OnResolveProxyCompleted,
|
||||
base::Unretained(this)),
|
||||
&req.pac_req, nullptr, net::NetLogWithSource());
|
||||
&req.request, nullptr, net::NetLogWithSource());
|
||||
|
||||
// Completed synchronously.
|
||||
if (result != net::ERR_IO_PENDING)
|
||||
|
@ -57,17 +57,17 @@ class CONTENT_EXPORT ResolveProxyMsgHelper : public BrowserMessageFilter {
|
||||
// A PendingRequest is a resolve request that is in progress, or queued.
|
||||
struct PendingRequest {
|
||||
public:
|
||||
PendingRequest(const GURL& url, IPC::Message* reply_msg) :
|
||||
url(url), reply_msg(reply_msg), pac_req(NULL) { }
|
||||
PendingRequest(const GURL& url, IPC::Message* reply_msg)
|
||||
: url(url), reply_msg(reply_msg), request(NULL) {}
|
||||
|
||||
// The URL of the request.
|
||||
GURL url;
|
||||
// The URL of the request.
|
||||
GURL url;
|
||||
|
||||
// Data to pass back to the delegate on completion (we own it until then).
|
||||
IPC::Message* reply_msg;
|
||||
// Data to pass back to the delegate on completion (we own it until then).
|
||||
IPC::Message* reply_msg;
|
||||
|
||||
// Handle for cancelling the current request if it has started (else NULL).
|
||||
net::ProxyService::PacRequest* pac_req;
|
||||
// Handle for cancelling the current request if it has started (else NULL).
|
||||
net::ProxyService::Request* request;
|
||||
};
|
||||
|
||||
// Info about the current outstanding proxy request.
|
||||
|
@ -619,10 +619,10 @@ TEST_F(NetworkContextTest, NoInitialProxyConfig) {
|
||||
// Before there's a proxy configuration, proxy requests should hang.
|
||||
net::ProxyInfo proxy_info;
|
||||
net::TestCompletionCallback test_callback;
|
||||
net::ProxyService::PacRequest* pac_request = nullptr;
|
||||
net::ProxyService::Request* request = nullptr;
|
||||
ASSERT_EQ(net::ERR_IO_PENDING,
|
||||
proxy_service->ResolveProxy(GURL("http://bar/"), "GET", &proxy_info,
|
||||
test_callback.callback(), &pac_request,
|
||||
test_callback.callback(), &request,
|
||||
nullptr, net::NetLogWithSource()));
|
||||
scoped_task_environment_.RunUntilIdle();
|
||||
EXPECT_FALSE(proxy_service->config().is_valid());
|
||||
|
@ -62,7 +62,7 @@ ConnectionFactoryImpl::ConnectionFactoryImpl(
|
||||
http_network_session_(http_network_session),
|
||||
net_log_(
|
||||
net::NetLogWithSource::Make(net_log, net::NetLogSourceType::SOCKET)),
|
||||
pac_request_(NULL),
|
||||
proxy_resolve_request_(NULL),
|
||||
connecting_(false),
|
||||
waiting_for_backoff_(false),
|
||||
waiting_for_network_online_(false),
|
||||
@ -78,9 +78,10 @@ ConnectionFactoryImpl::ConnectionFactoryImpl(
|
||||
ConnectionFactoryImpl::~ConnectionFactoryImpl() {
|
||||
CloseSocket();
|
||||
net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
|
||||
if (pac_request_) {
|
||||
gcm_network_session_->proxy_service()->CancelPacRequest(pac_request_);
|
||||
pac_request_ = NULL;
|
||||
if (proxy_resolve_request_) {
|
||||
gcm_network_session_->proxy_service()->CancelRequest(
|
||||
proxy_resolve_request_);
|
||||
proxy_resolve_request_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,14 +327,10 @@ void ConnectionFactoryImpl::StartConnection() {
|
||||
recorder_->RecordConnectionInitiated(current_endpoint.host());
|
||||
UpdateFromHttpNetworkSession();
|
||||
int status = gcm_network_session_->proxy_service()->ResolveProxy(
|
||||
current_endpoint,
|
||||
std::string(),
|
||||
&proxy_info_,
|
||||
current_endpoint, std::string(), &proxy_info_,
|
||||
base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
&pac_request_,
|
||||
NULL,
|
||||
net_log_);
|
||||
&proxy_resolve_request_, NULL, net_log_);
|
||||
if (status != net::ERR_IO_PENDING)
|
||||
OnProxyResolveDone(status);
|
||||
}
|
||||
@ -447,7 +444,7 @@ void ConnectionFactoryImpl::ConnectionHandlerCallback(int result) {
|
||||
// HttpStreamFactoryImpl::Job::DoResolveProxyComplete. This should be
|
||||
// refactored into some common place.
|
||||
void ConnectionFactoryImpl::OnProxyResolveDone(int status) {
|
||||
pac_request_ = NULL;
|
||||
proxy_resolve_request_ = NULL;
|
||||
DVLOG(1) << "Proxy resolution status: " << status;
|
||||
|
||||
DCHECK_NE(status, net::ERR_IO_PENDING);
|
||||
@ -497,7 +494,7 @@ void ConnectionFactoryImpl::OnProxyResolveDone(int status) {
|
||||
// a proxy it always returns ERR_IO_PENDING and posts a call to
|
||||
// OnProxyResolveDone with the result of the reconsideration.
|
||||
int ConnectionFactoryImpl::ReconsiderProxyAfterError(int error) {
|
||||
DCHECK(!pac_request_);
|
||||
DCHECK(!proxy_resolve_request_);
|
||||
DCHECK_NE(error, net::OK);
|
||||
DCHECK_NE(error, net::ERR_IO_PENDING);
|
||||
// A failure to resolve the hostname or any error related to establishing a
|
||||
@ -553,7 +550,7 @@ int ConnectionFactoryImpl::ReconsiderProxyAfterError(int error) {
|
||||
GetCurrentEndpoint(), std::string(), error, &proxy_info_,
|
||||
base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
&pac_request_, NULL, net_log_);
|
||||
&proxy_resolve_request_, NULL, net_log_);
|
||||
if (status == net::OK || status == net::ERR_IO_PENDING) {
|
||||
CloseSocket();
|
||||
} else {
|
||||
|
@ -159,8 +159,9 @@ class GCM_EXPORT ConnectionFactoryImpl :
|
||||
net::HttpNetworkSession* http_network_session_;
|
||||
// Net log to use in connection attempts.
|
||||
net::NetLogWithSource net_log_;
|
||||
// The current PAC request, if one exists. Owned by the proxy service.
|
||||
net::ProxyService::PacRequest* pac_request_;
|
||||
// The current proxy resolution request, if one exists. Owned by the proxy
|
||||
// service.
|
||||
net::ProxyService::Request* proxy_resolve_request_;
|
||||
// The current proxy info.
|
||||
net::ProxyInfo proxy_info_;
|
||||
// The handle to the socket for the current connection, if one exists.
|
||||
|
@ -84,7 +84,7 @@ HttpStreamFactoryImpl::JobController::JobController(
|
||||
bound_job_(nullptr),
|
||||
can_start_alternative_proxy_job_(true),
|
||||
next_state_(STATE_RESOLVE_PROXY),
|
||||
pac_request_(nullptr),
|
||||
proxy_resolve_request_(nullptr),
|
||||
io_callback_(
|
||||
base::Bind(&JobController::OnIOComplete, base::Unretained(this))),
|
||||
request_info_(request_info),
|
||||
@ -106,9 +106,9 @@ HttpStreamFactoryImpl::JobController::~JobController() {
|
||||
main_job_.reset();
|
||||
alternative_job_.reset();
|
||||
bound_job_ = nullptr;
|
||||
if (pac_request_) {
|
||||
if (proxy_resolve_request_) {
|
||||
DCHECK_EQ(STATE_RESOLVE_PROXY_COMPLETE, next_state_);
|
||||
session_->proxy_service()->CancelPacRequest(pac_request_);
|
||||
session_->proxy_service()->CancelRequest(proxy_resolve_request_);
|
||||
}
|
||||
net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER);
|
||||
}
|
||||
@ -161,7 +161,7 @@ void HttpStreamFactoryImpl::JobController::Preconnect(int num_streams) {
|
||||
LoadState HttpStreamFactoryImpl::JobController::GetLoadState() const {
|
||||
DCHECK(request_);
|
||||
if (next_state_ == STATE_RESOLVE_PROXY_COMPLETE)
|
||||
return session_->proxy_service()->GetLoadState(pac_request_);
|
||||
return session_->proxy_service()->GetLoadState(proxy_resolve_request_);
|
||||
if (bound_job_)
|
||||
return bound_job_->GetLoadState();
|
||||
if (main_job_)
|
||||
@ -739,7 +739,7 @@ int HttpStreamFactoryImpl::JobController::DoLoop(int rv) {
|
||||
}
|
||||
|
||||
int HttpStreamFactoryImpl::JobController::DoResolveProxy() {
|
||||
DCHECK(!pac_request_);
|
||||
DCHECK(!proxy_resolve_request_);
|
||||
DCHECK(session_);
|
||||
|
||||
next_state_ = STATE_RESOLVE_PROXY_COMPLETE;
|
||||
@ -754,13 +754,13 @@ int HttpStreamFactoryImpl::JobController::DoResolveProxy() {
|
||||
|
||||
return session_->proxy_service()->ResolveProxy(
|
||||
origin_url, request_info_.method, &proxy_info_, io_callback_,
|
||||
&pac_request_, session_->context().proxy_delegate, net_log_);
|
||||
&proxy_resolve_request_, session_->context().proxy_delegate, net_log_);
|
||||
}
|
||||
|
||||
int HttpStreamFactoryImpl::JobController::DoResolveProxyComplete(int rv) {
|
||||
DCHECK_NE(ERR_IO_PENDING, rv);
|
||||
|
||||
pac_request_ = nullptr;
|
||||
proxy_resolve_request_ = nullptr;
|
||||
net_log_.AddEvent(
|
||||
NetLogEventType::HTTP_STREAM_JOB_CONTROLLER_PROXY_SERVER_RESOLVED,
|
||||
base::Bind(
|
||||
@ -1275,7 +1275,7 @@ int HttpStreamFactoryImpl::JobController::ReconsiderProxyAfterError(Job* job,
|
||||
int error) {
|
||||
// ReconsiderProxyAfterError() should only be called when the last job fails.
|
||||
DCHECK(!(alternative_job_ && main_job_));
|
||||
DCHECK(!pac_request_);
|
||||
DCHECK(!proxy_resolve_request_);
|
||||
DCHECK(session_);
|
||||
|
||||
if (!job->should_reconsider_proxy())
|
||||
@ -1300,7 +1300,7 @@ int HttpStreamFactoryImpl::JobController::ReconsiderProxyAfterError(Job* job,
|
||||
|
||||
int rv = session_->proxy_service()->ReconsiderProxyAfterError(
|
||||
origin_url, request_info_.method, error, &proxy_info_, io_callback_,
|
||||
&pac_request_, session_->context().proxy_delegate, net_log_);
|
||||
&proxy_resolve_request_, session_->context().proxy_delegate, net_log_);
|
||||
if (rv == OK || rv == ERR_IO_PENDING) {
|
||||
if (!job->using_quic())
|
||||
RemoveRequestFromSpdySessionRequestMap();
|
||||
|
@ -369,7 +369,7 @@ class HttpStreamFactoryImpl::JobController
|
||||
bool can_start_alternative_proxy_job_;
|
||||
|
||||
State next_state_;
|
||||
ProxyService::PacRequest* pac_request_;
|
||||
ProxyService::Request* proxy_resolve_request_;
|
||||
CompletionCallback io_callback_;
|
||||
const HttpRequestInfo request_info_;
|
||||
ProxyInfo proxy_info_;
|
||||
|
@ -773,18 +773,17 @@ class ProxyService::ProxyScriptDeciderPoller {
|
||||
const ProxyService::PacPollPolicy*
|
||||
ProxyService::ProxyScriptDeciderPoller::poll_policy_ = NULL;
|
||||
|
||||
// ProxyService::PacRequest ---------------------------------------------------
|
||||
// ProxyService::Request ---------------------------------------------------
|
||||
|
||||
class ProxyService::PacRequest
|
||||
: public base::RefCounted<ProxyService::PacRequest> {
|
||||
class ProxyService::Request : public base::RefCounted<ProxyService::Request> {
|
||||
public:
|
||||
PacRequest(ProxyService* service,
|
||||
const GURL& url,
|
||||
const std::string& method,
|
||||
ProxyDelegate* proxy_delegate,
|
||||
ProxyInfo* results,
|
||||
const CompletionCallback& user_callback,
|
||||
const NetLogWithSource& net_log)
|
||||
Request(ProxyService* service,
|
||||
const GURL& url,
|
||||
const std::string& method,
|
||||
ProxyDelegate* proxy_delegate,
|
||||
ProxyInfo* results,
|
||||
const CompletionCallback& user_callback,
|
||||
const NetLogWithSource& net_log)
|
||||
: service_(service),
|
||||
user_callback_(user_callback),
|
||||
results_(results),
|
||||
@ -811,7 +810,7 @@ class ProxyService::PacRequest
|
||||
|
||||
return resolver()->GetProxyForURL(
|
||||
url_, results_,
|
||||
base::Bind(&PacRequest::QueryComplete, base::Unretained(this)),
|
||||
base::Bind(&Request::QueryComplete, base::Unretained(this)),
|
||||
&resolve_job_, net_log_);
|
||||
}
|
||||
|
||||
@ -892,15 +891,15 @@ class ProxyService::PacRequest
|
||||
}
|
||||
|
||||
private:
|
||||
friend class base::RefCounted<ProxyService::PacRequest>;
|
||||
friend class base::RefCounted<ProxyService::Request>;
|
||||
|
||||
~PacRequest() = default;
|
||||
~Request() = default;
|
||||
|
||||
// Callback for when the ProxyResolver request has completed.
|
||||
void QueryComplete(int result_code) {
|
||||
result_code = QueryDidComplete(result_code);
|
||||
|
||||
// Remove this completed PacRequest from the service's pending list.
|
||||
// Remove this completed Request from the service's pending list.
|
||||
/// (which will probably cause deletion of |this|).
|
||||
if (!user_callback_.is_null()) {
|
||||
CompletionCallback callback = user_callback_;
|
||||
@ -1020,7 +1019,7 @@ int ProxyService::ResolveProxy(const GURL& raw_url,
|
||||
const std::string& method,
|
||||
ProxyInfo* result,
|
||||
const CompletionCallback& callback,
|
||||
PacRequest** pac_request,
|
||||
Request** pac_request,
|
||||
ProxyDelegate* proxy_delegate,
|
||||
const NetLogWithSource& net_log) {
|
||||
DCHECK(!callback.is_null());
|
||||
@ -1032,7 +1031,7 @@ int ProxyService::ResolveProxyHelper(const GURL& raw_url,
|
||||
const std::string& method,
|
||||
ProxyInfo* result,
|
||||
const CompletionCallback& callback,
|
||||
PacRequest** pac_request,
|
||||
Request** pac_request,
|
||||
ProxyDelegate* proxy_delegate,
|
||||
const NetLogWithSource& net_log) {
|
||||
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
||||
@ -1066,8 +1065,8 @@ int ProxyService::ResolveProxyHelper(const GURL& raw_url,
|
||||
if (callback.is_null())
|
||||
return ERR_IO_PENDING;
|
||||
|
||||
scoped_refptr<PacRequest> req(new PacRequest(
|
||||
this, url, method, proxy_delegate, result, callback, net_log));
|
||||
scoped_refptr<Request> req(new Request(this, url, method, proxy_delegate,
|
||||
result, callback, net_log));
|
||||
|
||||
if (current_state_ == STATE_READY) {
|
||||
// Start the resolve request.
|
||||
@ -1146,7 +1145,7 @@ void ProxyService::SuspendAllPendingRequests() {
|
||||
for (PendingRequests::iterator it = pending_requests_.begin();
|
||||
it != pending_requests_.end();
|
||||
++it) {
|
||||
PacRequest* req = it->get();
|
||||
Request* req = it->get();
|
||||
if (req->is_started()) {
|
||||
req->CancelResolveJob();
|
||||
|
||||
@ -1161,14 +1160,14 @@ void ProxyService::SetReady() {
|
||||
current_state_ = STATE_READY;
|
||||
|
||||
// Make a copy in case |this| is deleted during the synchronous completion
|
||||
// of one of the requests. If |this| is deleted then all of the PacRequest
|
||||
// of one of the requests. If |this| is deleted then all of the Request
|
||||
// instances will be Cancel()-ed.
|
||||
PendingRequests pending_copy = pending_requests_;
|
||||
|
||||
for (PendingRequests::iterator it = pending_copy.begin();
|
||||
it != pending_copy.end();
|
||||
++it) {
|
||||
PacRequest* req = it->get();
|
||||
Request* req = it->get();
|
||||
if (!req->is_started() && !req->was_cancelled()) {
|
||||
req->net_log()->EndEvent(
|
||||
NetLogEventType::PROXY_SERVICE_WAITING_FOR_INIT_PAC);
|
||||
@ -1256,7 +1255,7 @@ int ProxyService::ReconsiderProxyAfterError(const GURL& url,
|
||||
int net_error,
|
||||
ProxyInfo* result,
|
||||
const CompletionCallback& callback,
|
||||
PacRequest** pac_request,
|
||||
Request** pac_request,
|
||||
ProxyDelegate* proxy_delegate,
|
||||
const NetLogWithSource& net_log) {
|
||||
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
||||
@ -1329,25 +1328,25 @@ void ProxyService::ReportSuccess(const ProxyInfo& result,
|
||||
}
|
||||
}
|
||||
|
||||
void ProxyService::CancelPacRequest(PacRequest* req) {
|
||||
void ProxyService::CancelRequest(Request* req) {
|
||||
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
||||
DCHECK(req);
|
||||
req->Cancel();
|
||||
RemovePendingRequest(req);
|
||||
}
|
||||
|
||||
LoadState ProxyService::GetLoadState(const PacRequest* req) const {
|
||||
LoadState ProxyService::GetLoadState(const Request* req) const {
|
||||
CHECK(req);
|
||||
if (current_state_ == STATE_WAITING_FOR_INIT_PROXY_RESOLVER)
|
||||
return init_proxy_resolver_->GetLoadState();
|
||||
return req->GetLoadState();
|
||||
}
|
||||
|
||||
bool ProxyService::ContainsPendingRequest(PacRequest* req) {
|
||||
bool ProxyService::ContainsPendingRequest(Request* req) {
|
||||
return pending_requests_.count(req) == 1;
|
||||
}
|
||||
|
||||
void ProxyService::RemovePendingRequest(PacRequest* req) {
|
||||
void ProxyService::RemovePendingRequest(Request* req) {
|
||||
DCHECK(ContainsPendingRequest(req));
|
||||
pending_requests_.erase(req);
|
||||
}
|
||||
|
@ -119,9 +119,8 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
|
||||
|
||||
~ProxyService() override;
|
||||
|
||||
// Used internally to handle PAC queries.
|
||||
// TODO(eroman): consider naming this simply "Request".
|
||||
class PacRequest;
|
||||
// Used to track proxy resolution requests that complete asynchronously.
|
||||
class Request;
|
||||
|
||||
// Determines the appropriate proxy for |url| for a |method| request and
|
||||
// stores the result in |results|. If |method| is empty, the caller can expect
|
||||
@ -133,9 +132,9 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
|
||||
// ResolveProxy.
|
||||
//
|
||||
// The caller is responsible for ensuring that |results| and |callback|
|
||||
// remain valid until the callback is run or until |pac_request| is cancelled
|
||||
// via CancelPacRequest. |pac_request| is only valid while the completion
|
||||
// callback is still pending. NULL can be passed for |pac_request| if
|
||||
// remain valid until the callback is run or until |request| is cancelled
|
||||
// via CancelRequest. |request| is only valid while the completion
|
||||
// callback is still pending. NULL can be passed for |request| if
|
||||
// the caller will not need to cancel the request.
|
||||
//
|
||||
// We use the three possible proxy access types in the following order,
|
||||
@ -150,7 +149,7 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
|
||||
const std::string& method,
|
||||
ProxyInfo* results,
|
||||
const CompletionCallback& callback,
|
||||
PacRequest** pac_request,
|
||||
Request** request,
|
||||
ProxyDelegate* proxy_delegate,
|
||||
const NetLogWithSource& net_log);
|
||||
|
||||
@ -170,7 +169,7 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
|
||||
// list of possible values. The semantics of this call are otherwise
|
||||
// similar to ResolveProxy.
|
||||
//
|
||||
// NULL can be passed for |pac_request| if the caller will not need to
|
||||
// NULL can be passed for |request| if the caller will not need to
|
||||
// cancel the request.
|
||||
//
|
||||
// Returns ERR_FAILED if there is not another proxy config to try.
|
||||
@ -181,7 +180,7 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
|
||||
int net_error,
|
||||
ProxyInfo* results,
|
||||
const CompletionCallback& callback,
|
||||
PacRequest** pac_request,
|
||||
Request** request,
|
||||
ProxyDelegate* proxy_delegate,
|
||||
const NetLogWithSource& net_log);
|
||||
|
||||
@ -208,11 +207,11 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
|
||||
void ReportSuccess(const ProxyInfo& proxy_info,
|
||||
ProxyDelegate* proxy_delegate);
|
||||
|
||||
// Call this method with a non-null |pac_request| to cancel the PAC request.
|
||||
void CancelPacRequest(PacRequest* pac_request);
|
||||
// Call this method with a non-null |request| to cancel the PAC request.
|
||||
void CancelRequest(Request* request);
|
||||
|
||||
// Returns the LoadState for this |pac_request| which must be non-NULL.
|
||||
LoadState GetLoadState(const PacRequest* pac_request) const;
|
||||
// Returns the LoadState for this |request| which must be non-NULL.
|
||||
LoadState GetLoadState(const Request* request) const;
|
||||
|
||||
// Sets the ProxyScriptFetcher and DhcpProxyScriptFetcher dependencies. This
|
||||
// is needed if the ProxyResolver is of type ProxyResolverWithoutFetch.
|
||||
@ -318,11 +317,11 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
|
||||
private:
|
||||
FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect);
|
||||
FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect);
|
||||
friend class PacRequest;
|
||||
friend class Request;
|
||||
class InitProxyResolver;
|
||||
class ProxyScriptDeciderPoller;
|
||||
|
||||
typedef std::set<scoped_refptr<PacRequest>> PendingRequests;
|
||||
typedef std::set<scoped_refptr<Request>> PendingRequests;
|
||||
|
||||
enum State {
|
||||
STATE_NONE,
|
||||
@ -361,7 +360,7 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
|
||||
const std::string& method,
|
||||
ProxyInfo* results,
|
||||
const CompletionCallback& callback,
|
||||
PacRequest** pac_request,
|
||||
Request** request,
|
||||
ProxyDelegate* proxy_delegate,
|
||||
const NetLogWithSource& net_log);
|
||||
|
||||
@ -374,10 +373,10 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
|
||||
void SetReady();
|
||||
|
||||
// Returns true if |pending_requests_| contains |req|.
|
||||
bool ContainsPendingRequest(PacRequest* req);
|
||||
bool ContainsPendingRequest(Request* req);
|
||||
|
||||
// Removes |req| from the list of pending requests.
|
||||
void RemovePendingRequest(PacRequest* req);
|
||||
void RemovePendingRequest(Request* req);
|
||||
|
||||
// Called when proxy resolution has completed (either synchronously or
|
||||
// asynchronously). Handles logging the result, and cleaning out
|
||||
|
@ -499,7 +499,7 @@ TEST_F(ProxyServiceTest, PAC) {
|
||||
|
||||
ProxyInfo info;
|
||||
TestCompletionCallback callback;
|
||||
ProxyService::PacRequest* request;
|
||||
ProxyService::Request* request;
|
||||
BoundTestNetLog log;
|
||||
|
||||
int rv = service.ResolveProxy(url, std::string(), &info, callback.callback(),
|
||||
@ -1948,7 +1948,7 @@ TEST_F(ProxyServiceTest, CancelInProgressRequest) {
|
||||
|
||||
ProxyInfo info2;
|
||||
TestCompletionCallback callback2;
|
||||
ProxyService::PacRequest* request2;
|
||||
ProxyService::Request* request2;
|
||||
rv = service.ResolveProxy(url2, std::string(), &info2, callback2.callback(),
|
||||
&request2, nullptr, NetLogWithSource());
|
||||
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
|
||||
@ -1963,7 +1963,7 @@ TEST_F(ProxyServiceTest, CancelInProgressRequest) {
|
||||
GetPendingJobsForURLs(resolver, url1, url2, url3);
|
||||
|
||||
// Cancel the second request
|
||||
service.CancelPacRequest(request2);
|
||||
service.CancelRequest(request2);
|
||||
|
||||
JobMap jobs = GetPendingJobsForURLs(resolver, url1, url3);
|
||||
|
||||
@ -2009,7 +2009,7 @@ TEST_F(ProxyServiceTest, InitialPACScriptDownload) {
|
||||
|
||||
ProxyInfo info1;
|
||||
TestCompletionCallback callback1;
|
||||
ProxyService::PacRequest* request1;
|
||||
ProxyService::Request* request1;
|
||||
int rv =
|
||||
service.ResolveProxy(url1, std::string(), &info1, callback1.callback(),
|
||||
&request1, nullptr, NetLogWithSource());
|
||||
@ -2021,14 +2021,14 @@ TEST_F(ProxyServiceTest, InitialPACScriptDownload) {
|
||||
|
||||
ProxyInfo info2;
|
||||
TestCompletionCallback callback2;
|
||||
ProxyService::PacRequest* request2;
|
||||
ProxyService::Request* request2;
|
||||
rv = service.ResolveProxy(url2, std::string(), &info2, callback2.callback(),
|
||||
&request2, nullptr, NetLogWithSource());
|
||||
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
|
||||
|
||||
ProxyInfo info3;
|
||||
TestCompletionCallback callback3;
|
||||
ProxyService::PacRequest* request3;
|
||||
ProxyService::Request* request3;
|
||||
rv = service.ResolveProxy(url3, std::string(), &info3, callback3.callback(),
|
||||
&request3, nullptr, NetLogWithSource());
|
||||
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
|
||||
@ -2178,7 +2178,7 @@ TEST_F(ProxyServiceTest, CancelWhilePACFetching) {
|
||||
// Start 3 requests.
|
||||
ProxyInfo info1;
|
||||
TestCompletionCallback callback1;
|
||||
ProxyService::PacRequest* request1;
|
||||
ProxyService::Request* request1;
|
||||
BoundTestNetLog log1;
|
||||
int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info1,
|
||||
callback1.callback(), &request1, nullptr,
|
||||
@ -2191,7 +2191,7 @@ TEST_F(ProxyServiceTest, CancelWhilePACFetching) {
|
||||
|
||||
ProxyInfo info2;
|
||||
TestCompletionCallback callback2;
|
||||
ProxyService::PacRequest* request2;
|
||||
ProxyService::Request* request2;
|
||||
rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
|
||||
callback2.callback(), &request2, nullptr,
|
||||
NetLogWithSource());
|
||||
@ -2208,8 +2208,8 @@ TEST_F(ProxyServiceTest, CancelWhilePACFetching) {
|
||||
EXPECT_TRUE(factory->pending_requests().empty());
|
||||
|
||||
// Cancel the first 2 jobs.
|
||||
service.CancelPacRequest(request1);
|
||||
service.CancelPacRequest(request2);
|
||||
service.CancelRequest(request1);
|
||||
service.CancelRequest(request2);
|
||||
|
||||
// At this point the ProxyService should be waiting for the
|
||||
// ProxyScriptFetcher to invoke its completion callback, notifying it of
|
||||
@ -2285,7 +2285,7 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac) {
|
||||
|
||||
ProxyInfo info2;
|
||||
TestCompletionCallback callback2;
|
||||
ProxyService::PacRequest* request2;
|
||||
ProxyService::Request* request2;
|
||||
rv = service.ResolveProxy(url2, std::string(), &info2, callback2.callback(),
|
||||
&request2, nullptr, NetLogWithSource());
|
||||
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
|
||||
@ -2369,7 +2369,7 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac2) {
|
||||
|
||||
ProxyInfo info2;
|
||||
TestCompletionCallback callback2;
|
||||
ProxyService::PacRequest* request2;
|
||||
ProxyService::Request* request2;
|
||||
rv = service.ResolveProxy(url2, std::string(), &info2, callback2.callback(),
|
||||
&request2, nullptr, NetLogWithSource());
|
||||
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
|
||||
@ -2446,7 +2446,7 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomToManual) {
|
||||
|
||||
ProxyInfo info2;
|
||||
TestCompletionCallback callback2;
|
||||
ProxyService::PacRequest* request2;
|
||||
ProxyService::Request* request2;
|
||||
rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
|
||||
callback2.callback(), &request2, nullptr,
|
||||
NetLogWithSource());
|
||||
@ -3700,7 +3700,7 @@ TEST_F(ProxyServiceTest, OnShutdownWithLiveRequest) {
|
||||
|
||||
ProxyInfo info;
|
||||
TestCompletionCallback callback;
|
||||
ProxyService::PacRequest* request;
|
||||
ProxyService::Request* request;
|
||||
int rv = service.ResolveProxy(GURL("http://request/"), std::string(), &info,
|
||||
callback.callback(), &request, nullptr,
|
||||
NetLogWithSource());
|
||||
@ -3736,7 +3736,7 @@ TEST_F(ProxyServiceTest, OnShutdownFollowedByRequest) {
|
||||
|
||||
ProxyInfo info;
|
||||
TestCompletionCallback callback;
|
||||
ProxyService::PacRequest* request;
|
||||
ProxyService::Request* request;
|
||||
int rv = service.ResolveProxy(GURL("http://request/"), std::string(), &info,
|
||||
callback.callback(), &request, nullptr,
|
||||
NetLogWithSource());
|
||||
|
@ -45,7 +45,7 @@ URLRequestFtpJob::URLRequestFtpJob(
|
||||
: URLRequestJob(request, network_delegate),
|
||||
priority_(DEFAULT_PRIORITY),
|
||||
proxy_service_(request_->context()->proxy_service()),
|
||||
pac_request_(NULL),
|
||||
proxy_resolve_request_(NULL),
|
||||
http_response_info_(NULL),
|
||||
read_in_progress_(false),
|
||||
ftp_transaction_factory_(ftp_transaction_factory),
|
||||
@ -104,7 +104,7 @@ void URLRequestFtpJob::SetPriority(RequestPriority priority) {
|
||||
}
|
||||
|
||||
void URLRequestFtpJob::Start() {
|
||||
DCHECK(!pac_request_);
|
||||
DCHECK(!proxy_resolve_request_);
|
||||
DCHECK(!ftp_transaction_);
|
||||
DCHECK(!http_transaction_);
|
||||
|
||||
@ -117,7 +117,7 @@ void URLRequestFtpJob::Start() {
|
||||
request_->url(), "GET", &proxy_info_,
|
||||
base::Bind(&URLRequestFtpJob::OnResolveProxyComplete,
|
||||
base::Unretained(this)),
|
||||
&pac_request_, NULL, request_->net_log());
|
||||
&proxy_resolve_request_, NULL, request_->net_log());
|
||||
|
||||
if (rv == ERR_IO_PENDING)
|
||||
return;
|
||||
@ -126,9 +126,9 @@ void URLRequestFtpJob::Start() {
|
||||
}
|
||||
|
||||
void URLRequestFtpJob::Kill() {
|
||||
if (pac_request_) {
|
||||
proxy_service_->CancelPacRequest(pac_request_);
|
||||
pac_request_ = nullptr;
|
||||
if (proxy_resolve_request_) {
|
||||
proxy_service_->CancelRequest(proxy_resolve_request_);
|
||||
proxy_resolve_request_ = nullptr;
|
||||
}
|
||||
if (ftp_transaction_)
|
||||
ftp_transaction_.reset();
|
||||
@ -139,7 +139,7 @@ void URLRequestFtpJob::Kill() {
|
||||
}
|
||||
|
||||
void URLRequestFtpJob::OnResolveProxyComplete(int result) {
|
||||
pac_request_ = NULL;
|
||||
proxy_resolve_request_ = NULL;
|
||||
|
||||
if (result != OK) {
|
||||
OnStartCompletedAsync(result);
|
||||
@ -278,8 +278,8 @@ void URLRequestFtpJob::RestartTransactionWithAuth() {
|
||||
}
|
||||
|
||||
LoadState URLRequestFtpJob::GetLoadState() const {
|
||||
if (pac_request_)
|
||||
return proxy_service_->GetLoadState(pac_request_);
|
||||
if (proxy_resolve_request_)
|
||||
return proxy_service_->GetLoadState(proxy_resolve_request_);
|
||||
if (proxy_info_.is_direct()) {
|
||||
return ftp_transaction_ ?
|
||||
ftp_transaction_->GetLoadState() : LOAD_STATE_IDLE;
|
||||
|
@ -81,7 +81,7 @@ class NET_EXPORT_PRIVATE URLRequestFtpJob : public URLRequestJob {
|
||||
|
||||
ProxyService* proxy_service_;
|
||||
ProxyInfo proxy_info_;
|
||||
ProxyService::PacRequest* pac_request_;
|
||||
ProxyService::Request* proxy_resolve_request_;
|
||||
|
||||
FtpRequestInfo ftp_request_info_;
|
||||
std::unique_ptr<FtpTransaction> ftp_transaction_;
|
||||
|
@ -34,7 +34,7 @@ ProxyResolvingClientSocket::ProxyResolvingClientSocket(
|
||||
const net::SSLConfig& ssl_config,
|
||||
const GURL& url)
|
||||
: ssl_config_(ssl_config),
|
||||
pac_request_(NULL),
|
||||
proxy_resolve_request_(NULL),
|
||||
url_(url),
|
||||
net_log_(net::NetLogWithSource::Make(
|
||||
request_context_getter->GetURLRequestContext()->net_log(),
|
||||
@ -148,7 +148,7 @@ int ProxyResolvingClientSocket::Connect(
|
||||
url_, "POST", &proxy_info_,
|
||||
base::BindRepeating(&ProxyResolvingClientSocket::ConnectToProxy,
|
||||
base::Unretained(this)),
|
||||
&pac_request_, nullptr /*proxy_delegate*/, net_log_);
|
||||
&proxy_resolve_request_, nullptr /*proxy_delegate*/, net_log_);
|
||||
if (net_error != net::ERR_IO_PENDING) {
|
||||
// Defer execution of ConnectToProxy instead of calling it
|
||||
// directly here for simplicity. From the caller's point of view,
|
||||
@ -163,9 +163,9 @@ int ProxyResolvingClientSocket::Connect(
|
||||
|
||||
void ProxyResolvingClientSocket::Disconnect() {
|
||||
CloseTransportSocket();
|
||||
if (pac_request_) {
|
||||
network_session_->proxy_service()->CancelPacRequest(pac_request_);
|
||||
pac_request_ = NULL;
|
||||
if (proxy_resolve_request_) {
|
||||
network_session_->proxy_service()->CancelRequest(proxy_resolve_request_);
|
||||
proxy_resolve_request_ = NULL;
|
||||
}
|
||||
user_connect_callback_.Reset();
|
||||
}
|
||||
@ -258,7 +258,7 @@ void ProxyResolvingClientSocket::ApplySocketTag(const net::SocketTag& tag) {
|
||||
}
|
||||
|
||||
void ProxyResolvingClientSocket::ConnectToProxy(int net_error) {
|
||||
pac_request_ = NULL;
|
||||
proxy_resolve_request_ = NULL;
|
||||
|
||||
DCHECK_NE(net_error, net::ERR_IO_PENDING);
|
||||
if (net_error == net::OK) {
|
||||
@ -330,7 +330,7 @@ void ProxyResolvingClientSocket::CloseTransportSocket() {
|
||||
// reconsider a proxy it always returns ERR_IO_PENDING and posts a call to
|
||||
// ConnectToProxy with the result of the reconsideration.
|
||||
int ProxyResolvingClientSocket::ReconsiderProxyAfterError(int error) {
|
||||
DCHECK(!pac_request_);
|
||||
DCHECK(!proxy_resolve_request_);
|
||||
DCHECK_NE(error, net::OK);
|
||||
DCHECK_NE(error, net::ERR_IO_PENDING);
|
||||
// A failure to resolve the hostname or any error related to establishing a
|
||||
@ -388,7 +388,7 @@ int ProxyResolvingClientSocket::ReconsiderProxyAfterError(int error) {
|
||||
url_, std::string(), error, &proxy_info_,
|
||||
base::BindRepeating(&ProxyResolvingClientSocket::ConnectToProxy,
|
||||
base::Unretained(this)),
|
||||
&pac_request_, NULL, net_log_);
|
||||
&proxy_resolve_request_, NULL, net_log_);
|
||||
if (rv == net::OK || rv == net::ERR_IO_PENDING) {
|
||||
CloseTransportSocket();
|
||||
} else {
|
||||
|
@ -107,7 +107,7 @@ class ProxyResolvingClientSocket : public net::StreamSocket {
|
||||
std::unique_ptr<net::ClientSocketHandle> transport_;
|
||||
|
||||
const net::SSLConfig ssl_config_;
|
||||
net::ProxyService::PacRequest* pac_request_;
|
||||
net::ProxyService::Request* proxy_resolve_request_;
|
||||
net::ProxyInfo proxy_info_;
|
||||
const GURL url_;
|
||||
net::NetLogWithSource net_log_;
|
||||
|
Reference in New Issue
Block a user