Commit bc393104 authored by Nicolas Arciniega's avatar Nicolas Arciniega Committed by Commit Bot

Rename ProxyResolutionRequestImpl

Since the ProxyResolutionRequestImpl is specific to the
ConfiguredProxyResolutionService, it is appropriate to rename it to
ConfiguredProxyResolutionRequest.

Bug: 1032820
Change-Id: If8691fa721b5a41229b534ed7ad164d0aa7bd5a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2111835Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Commit-Queue: Eric Roman <eroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752234}
parent ae4f92d5
......@@ -811,6 +811,8 @@ component("net") {
"nqe/throughput_analyzer.cc",
"nqe/throughput_analyzer.h",
"nqe/weighted_observation.h",
"proxy_resolution/configured_proxy_resolution_request.cc",
"proxy_resolution/configured_proxy_resolution_request.h",
"proxy_resolution/configured_proxy_resolution_service.cc",
"proxy_resolution/configured_proxy_resolution_service.h",
"proxy_resolution/dhcp_pac_file_fetcher.cc",
......@@ -842,8 +844,6 @@ component("net") {
"proxy_resolution/proxy_list.cc",
"proxy_resolution/proxy_list.h",
"proxy_resolution/proxy_resolution_request.h",
"proxy_resolution/proxy_resolution_request_impl.cc",
"proxy_resolution/proxy_resolution_request_impl.h",
"proxy_resolution/proxy_resolution_service.h",
"proxy_resolution/proxy_resolve_dns_operation.h",
"proxy_resolution/proxy_resolver.h",
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/proxy_resolution/proxy_resolution_request_impl.h"
#include "net/proxy_resolution/configured_proxy_resolution_request.h"
#include <utility>
......@@ -15,7 +15,7 @@
namespace net {
ProxyResolutionRequestImpl::ProxyResolutionRequestImpl(
ConfiguredProxyResolutionRequest::ConfiguredProxyResolutionRequest(
ConfiguredProxyResolutionService* service,
const GURL& url,
const std::string& method,
......@@ -35,7 +35,7 @@ ProxyResolutionRequestImpl::ProxyResolutionRequestImpl(
DCHECK(!user_callback_.is_null());
}
ProxyResolutionRequestImpl::~ProxyResolutionRequestImpl() {
ConfiguredProxyResolutionRequest::~ConfiguredProxyResolutionRequest() {
if (service_) {
service_->RemovePendingRequest(this);
net_log_.AddEvent(NetLogEventType::CANCELLED);
......@@ -50,7 +50,7 @@ ProxyResolutionRequestImpl::~ProxyResolutionRequestImpl() {
}
// Starts the resolve proxy request.
int ProxyResolutionRequestImpl::Start() {
int ConfiguredProxyResolutionRequest::Start() {
DCHECK(!was_completed());
DCHECK(!is_started());
......@@ -63,12 +63,13 @@ int ProxyResolutionRequestImpl::Start() {
return service_->GetProxyResolver()->GetProxyForURL(
url_, network_isolation_key_, results_,
base::BindOnce(&ProxyResolutionRequestImpl::QueryComplete,
base::BindOnce(&ConfiguredProxyResolutionRequest::QueryComplete,
base::Unretained(this)),
&resolve_job_, net_log_);
}
void ProxyResolutionRequestImpl::StartAndCompleteCheckingForSynchronous() {
void ConfiguredProxyResolutionRequest::
StartAndCompleteCheckingForSynchronous() {
int rv = service_->TryToCompleteSynchronously(url_, results_);
if (rv == ERR_IO_PENDING)
rv = Start();
......@@ -76,14 +77,14 @@ void ProxyResolutionRequestImpl::StartAndCompleteCheckingForSynchronous() {
QueryComplete(rv);
}
void ProxyResolutionRequestImpl::CancelResolveJob() {
void ConfiguredProxyResolutionRequest::CancelResolveJob() {
DCHECK(is_started());
// The request may already be running in the resolver.
resolve_job_.reset();
DCHECK(!is_started());
}
int ProxyResolutionRequestImpl::QueryDidComplete(int result_code) {
int ConfiguredProxyResolutionRequest::QueryDidComplete(int result_code) {
DCHECK(!was_completed());
// Clear |resolve_job_| so is_started() returns false while
......@@ -96,18 +97,18 @@ int ProxyResolutionRequestImpl::QueryDidComplete(int result_code) {
// Make a note in the results which configuration was in use at the
// time of the resolve.
results_->did_use_pac_script_ = true;
results_->proxy_resolve_start_time_ = creation_time_;
results_->proxy_resolve_end_time_ = base::TimeTicks::Now();
results_->set_did_use_pac_script(true);
results_->set_proxy_resolve_start_time(creation_time_);
results_->set_proxy_resolve_end_time(base::TimeTicks::Now());
// If annotation is not already set, e.g. through TryToCompleteSynchronously
// function, use in-progress-resolve annotation.
if (!results_->traffic_annotation_.is_valid())
if (!results_->traffic_annotation().is_valid())
results_->set_traffic_annotation(traffic_annotation_);
// If proxy is set without error, ensure that an annotation is provided.
if (result_code != ERR_ABORTED && !rv)
DCHECK(results_->traffic_annotation_.is_valid());
DCHECK(results_->traffic_annotation().is_valid());
// Reset the state associated with in-progress-resolve.
traffic_annotation_.reset();
......@@ -115,13 +116,14 @@ int ProxyResolutionRequestImpl::QueryDidComplete(int result_code) {
return rv;
}
int ProxyResolutionRequestImpl::QueryDidCompleteSynchronously(int result_code) {
int ConfiguredProxyResolutionRequest::QueryDidCompleteSynchronously(
int result_code) {
int rv = QueryDidComplete(result_code);
service_ = nullptr;
return rv;
}
LoadState ProxyResolutionRequestImpl::GetLoadState() const {
LoadState ConfiguredProxyResolutionRequest::GetLoadState() const {
LoadState load_state = LOAD_STATE_IDLE;
if (service_ && service_->GetLoadStateIfAvailable(&load_state))
return load_state;
......@@ -132,7 +134,7 @@ LoadState ProxyResolutionRequestImpl::GetLoadState() const {
}
// Callback for when the ProxyResolver request has completed.
void ProxyResolutionRequestImpl::QueryComplete(int result_code) {
void ConfiguredProxyResolutionRequest::QueryComplete(int result_code) {
result_code = QueryDidComplete(result_code);
CompletionOnceCallback callback = std::move(user_callback_);
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_PROXY_RESOLUTION_PROXY_RESOLUTION_REQUEST_IMPL_H_
#define NET_PROXY_RESOLUTION_PROXY_RESOLUTION_REQUEST_IMPL_H_
#ifndef NET_PROXY_RESOLUTION_CONFIGURED_PROXY_RESOLUTION_REQUEST_H_
#define NET_PROXY_RESOLUTION_CONFIGURED_PROXY_RESOLUTION_REQUEST_H_
#include <memory>
#include <string>
......@@ -22,27 +22,26 @@ namespace net {
class ProxyInfo;
class ConfiguredProxyResolutionService;
// ProxyResolutionRequestImpl is the concrete implementation of
// ConfiguredProxyResolutionRequest is the concrete implementation of
// ProxyResolutionRequest used by ConfiguredProxyResolutionService. Manages a
// single asynchronous proxy resolution request.
//
// TODO(https://crbug.com/1032820): Rename this to
// ConfiguredProxyResolutionRequestImpl.
class ProxyResolutionRequestImpl final : public ProxyResolutionRequest {
class ConfiguredProxyResolutionRequest final : public ProxyResolutionRequest {
public:
ProxyResolutionRequestImpl(ConfiguredProxyResolutionService* service,
const GURL& url,
const std::string& method,
const NetworkIsolationKey& network_isolation_key,
ProxyInfo* results,
const CompletionOnceCallback user_callback,
const NetLogWithSource& net_log);
ProxyResolutionRequestImpl(const ProxyResolutionRequestImpl&) = delete;
ProxyResolutionRequestImpl& operator=(const ProxyResolutionRequestImpl&) =
ConfiguredProxyResolutionRequest(
ConfiguredProxyResolutionService* service,
const GURL& url,
const std::string& method,
const NetworkIsolationKey& network_isolation_key,
ProxyInfo* results,
const CompletionOnceCallback user_callback,
const NetLogWithSource& net_log);
ConfiguredProxyResolutionRequest(const ConfiguredProxyResolutionRequest&) =
delete;
ConfiguredProxyResolutionRequest& operator=(
const ConfiguredProxyResolutionRequest&) = delete;
~ProxyResolutionRequestImpl() override;
~ConfiguredProxyResolutionRequest() override;
// Starts the resolve proxy request.
int Start();
......@@ -97,4 +96,4 @@ class ProxyResolutionRequestImpl final : public ProxyResolutionRequest {
} // namespace net
#endif // NET_PROXY_RESOLUTION_PROXY_RESOLUTION_REQUEST_IMPL_H_
#endif // NET_PROXY_RESOLUTION_CONFIGURED_PROXY_RESOLUTION_REQUEST_H_
......@@ -30,12 +30,12 @@
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_util.h"
#include "net/log/net_log_with_source.h"
#include "net/proxy_resolution/configured_proxy_resolution_request.h"
#include "net/proxy_resolution/dhcp_pac_file_fetcher.h"
#include "net/proxy_resolution/multi_threaded_proxy_resolver.h"
#include "net/proxy_resolution/pac_file_decider.h"
#include "net/proxy_resolution/pac_file_fetcher.h"
#include "net/proxy_resolution/proxy_config_service_fixed.h"
#include "net/proxy_resolution/proxy_resolution_request_impl.h"
#include "net/proxy_resolution/proxy_resolver.h"
#include "net/proxy_resolution/proxy_resolver_factory.h"
#include "net/url_request/url_request_context.h"
......@@ -997,8 +997,8 @@ int ConfiguredProxyResolutionService::ResolveProxy(
return rv;
}
std::unique_ptr<ProxyResolutionRequestImpl> req =
std::make_unique<ProxyResolutionRequestImpl>(
std::unique_ptr<ConfiguredProxyResolutionRequest> req =
std::make_unique<ConfiguredProxyResolutionRequest>(
this, url, method, network_isolation_key, result, std::move(callback),
net_log);
......@@ -1065,14 +1065,14 @@ ConfiguredProxyResolutionService::~ConfiguredProxyResolutionService() {
// callbacks (if it deletes another request), iterating through the set in a
// for-loop will not work.
while (!pending_requests_.empty()) {
ProxyResolutionRequestImpl* req = *pending_requests_.begin();
ConfiguredProxyResolutionRequest* req = *pending_requests_.begin();
req->QueryComplete(ERR_ABORTED);
pending_requests_.erase(req);
}
}
void ConfiguredProxyResolutionService::SuspendAllPendingRequests() {
for (ProxyResolutionRequestImpl* req : pending_requests_) {
for (ConfiguredProxyResolutionRequest* req : pending_requests_) {
if (req->is_started()) {
req->CancelResolveJob();
......@@ -1185,10 +1185,10 @@ bool ConfiguredProxyResolutionService::MarkProxiesAsBadUntil(
base::TimeDelta retry_delay,
const std::vector<ProxyServer>& additional_bad_proxies,
const NetLogWithSource& net_log) {
result.proxy_list_.UpdateRetryInfoOnFallback(&proxy_retry_info_, retry_delay,
false, additional_bad_proxies,
OK, net_log);
return result.proxy_list_.size() > (additional_bad_proxies.size() + 1);
result.proxy_list().UpdateRetryInfoOnFallback(&proxy_retry_info_, retry_delay,
false, additional_bad_proxies,
OK, net_log);
return result.proxy_list().size() > (additional_bad_proxies.size() + 1);
}
void ConfiguredProxyResolutionService::ReportSuccess(const ProxyInfo& result) {
......@@ -1219,12 +1219,12 @@ void ConfiguredProxyResolutionService::ReportSuccess(const ProxyInfo& result) {
}
bool ConfiguredProxyResolutionService::ContainsPendingRequest(
ProxyResolutionRequestImpl* req) {
ConfiguredProxyResolutionRequest* req) {
return pending_requests_.count(req) == 1;
}
void ConfiguredProxyResolutionService::RemovePendingRequest(
ProxyResolutionRequestImpl* req) {
ConfiguredProxyResolutionRequest* req) {
DCHECK(ContainsPendingRequest(req));
pending_requests_.erase(req);
}
......
......@@ -41,12 +41,12 @@ class TimeDelta;
namespace net {
class ConfiguredProxyResolutionRequest;
class DhcpPacFileFetcher;
class NetLog;
class PacFileFetcher;
class ProxyDelegate;
class ProxyResolverFactory;
class ProxyResolutionRequestImpl;
struct PacFileDataWithSource;
// This class can be used to resolve the proxy server to use when loading a
......@@ -253,7 +253,7 @@ class NET_EXPORT ConfiguredProxyResolutionService
bool quick_check_enabled_for_testing() const { return quick_check_enabled_; }
private:
friend class ProxyResolutionRequestImpl;
friend class ConfiguredProxyResolutionRequest;
FRIEND_TEST_ALL_PREFIXES(ProxyResolutionServiceTest,
UpdateConfigAfterFailedAutodetect);
FRIEND_TEST_ALL_PREFIXES(ProxyResolutionServiceTest,
......@@ -261,7 +261,7 @@ class NET_EXPORT ConfiguredProxyResolutionService
class InitProxyResolver;
class PacFileDeciderPoller;
typedef std::set<ProxyResolutionRequestImpl*> PendingRequests;
typedef std::set<ConfiguredProxyResolutionRequest*> PendingRequests;
enum State {
STATE_NONE,
......@@ -307,10 +307,10 @@ class NET_EXPORT ConfiguredProxyResolutionService
void SetReady();
// Returns true if |pending_requests_| contains |req|.
bool ContainsPendingRequest(ProxyResolutionRequestImpl* req);
bool ContainsPendingRequest(ConfiguredProxyResolutionRequest* req);
// Removes |req| from the list of pending requests.
void RemovePendingRequest(ProxyResolutionRequestImpl* req);
void RemovePendingRequest(ConfiguredProxyResolutionRequest* req);
// Called when proxy resolution has completed (either synchronously or
// asynchronously). Handles logging the result, and cleaning out
......
......@@ -122,6 +122,10 @@ class NET_EXPORT ProxyInfo {
return did_bypass_proxy_;
}
void set_did_use_pac_script(bool did_use_pac_script) {
did_use_pac_script_ = did_use_pac_script;
}
// Returns true if the proxy resolution was done using a PAC script.
bool did_use_pac_script() const {
return did_use_pac_script_;
......@@ -131,6 +135,9 @@ class NET_EXPORT ProxyInfo {
// to call this function.
const ProxyServer& proxy_server() const { return proxy_list_.Get(); }
// Returns the full list of proxies to use.
const ProxyList& proxy_list() const { return proxy_list_; }
// See description in ProxyList::ToPacString().
std::string ToPacString() const;
......@@ -148,18 +155,23 @@ class NET_EXPORT ProxyInfo {
// Deletes any entry which doesn't have one of the specified proxy schemes.
void RemoveProxiesWithoutScheme(int scheme_bit_field);
// Returns the list of proxies to use.
const ProxyList& proxy_list() const {
return proxy_list_;
}
// Returns the alternative proxy, which may be invalid.
const ProxyServer& alternative_proxy() const { return alternative_proxy_; }
void set_proxy_resolve_start_time(
const base::TimeTicks& proxy_resolve_start_time) {
proxy_resolve_start_time_ = proxy_resolve_start_time;
}
base::TimeTicks proxy_resolve_start_time() const {
return proxy_resolve_start_time_;
}
void set_proxy_resolve_end_time(
const base::TimeTicks& proxy_resolve_end_time) {
proxy_resolve_end_time_ = proxy_resolve_end_time;
}
base::TimeTicks proxy_resolve_end_time() const {
return proxy_resolve_end_time_;
}
......@@ -173,15 +185,11 @@ class NET_EXPORT ProxyInfo {
return traffic_annotation_;
}
private:
friend class ConfiguredProxyResolutionService;
friend class ProxyResolutionRequestImpl;
FRIEND_TEST_ALL_PREFIXES(ProxyInfoTest, UseVsOverrideProxyList);
const ProxyRetryInfoMap& proxy_retry_info() const {
return proxy_retry_info_;
}
private:
// Reset proxy and config settings.
void Reset();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment