Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: net/proxy/proxy_service.cc

Issue 2110973002: Removing load_flags from ProxyService and ProxyDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_service.h ('k') | net/proxy/proxy_service_mojo_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_service.cc
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 295bad2780281904c862d23ea2f34337da101f85..9f7484c8f5169b481949e772ab080f2d80222acd 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -17,21 +17,20 @@
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/completion_callback.h"
-#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/proxy_delegate.h"
#include "net/base/url_util.h"
#include "net/log/net_log.h"
#include "net/proxy/dhcp_proxy_script_fetcher.h"
#include "net/proxy/multi_threaded_proxy_resolver.h"
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/proxy/proxy_resolver.h"
#include "net/proxy/proxy_resolver_factory.h"
#include "net/proxy/proxy_script_decider.h"
@@ -782,31 +781,29 @@ const ProxyService::PacPollPolicy*
ProxyService::ProxyScriptDeciderPoller::poll_policy_ = NULL;
// ProxyService::PacRequest ---------------------------------------------------
class ProxyService::PacRequest
: public base::RefCounted<ProxyService::PacRequest> {
public:
PacRequest(ProxyService* service,
const GURL& url,
const std::string& method,
- int load_flags,
ProxyDelegate* proxy_delegate,
ProxyInfo* results,
const CompletionCallback& user_callback,
const BoundNetLog& net_log)
: service_(service),
user_callback_(user_callback),
results_(results),
url_(url),
method_(method),
- load_flags_(load_flags),
proxy_delegate_(proxy_delegate),
resolve_job_(NULL),
config_id_(ProxyConfig::kInvalidConfigID),
config_source_(PROXY_CONFIG_SOURCE_UNKNOWN),
net_log_(net_log),
creation_time_(TimeTicks::Now()) {
DCHECK(!user_callback.is_null());
}
// Starts the resolve proxy request.
@@ -824,22 +821,22 @@ class ProxyService::PacRequest
base::Bind(&PacRequest::QueryComplete, base::Unretained(this)),
&resolve_job_, net_log_);
}
bool is_started() const {
// Note that !! casts to bool. (VS gives a warning otherwise).
return !!resolve_job_;
}
void StartAndCompleteCheckingForSynchronous() {
- int rv = service_->TryToCompleteSynchronously(url_, load_flags_,
- proxy_delegate_, results_);
+ int rv =
+ service_->TryToCompleteSynchronously(url_, proxy_delegate_, results_);
if (rv == ERR_IO_PENDING)
rv = Start();
if (rv != ERR_IO_PENDING)
QueryComplete(rv);
}
void CancelResolveJob() {
DCHECK(is_started());
// The request may already be running in the resolver.
resolver()->CancelRequest(resolve_job_);
@@ -872,23 +869,23 @@ class ProxyService::PacRequest
DCHECK(!was_cancelled());
// This state is cleared when resolve_job_ is set to nullptr below.
bool script_executed = is_started();
// Clear |resolve_job_| so is_started() returns false while
// DidFinishResolvingProxy() runs.
resolve_job_ = nullptr;
// Note that DidFinishResolvingProxy might modify |results_|.
- int rv = service_->DidFinishResolvingProxy(
- url_, method_, load_flags_, proxy_delegate_, results_, result_code,
- net_log_, creation_time_, script_executed);
+ int rv = service_->DidFinishResolvingProxy(url_, method_, proxy_delegate_,
+ results_, result_code, net_log_,
+ creation_time_, script_executed);
// Make a note in the results which configuration was in use at the
// time of the resolve.
results_->config_id_ = config_id_;
results_->config_source_ = config_source_;
results_->did_use_pac_script_ = true;
results_->proxy_resolve_start_time_ = creation_time_;
results_->proxy_resolve_end_time_ = TimeTicks::Now();
// Reset the state associated with in-progress-resolve.
@@ -927,21 +924,20 @@ class ProxyService::PacRequest
ProxyResolver* resolver() const { return service_->resolver_.get(); }
// Note that we don't hold a reference to the ProxyService. Outstanding
// requests are cancelled during ~ProxyService, so this is guaranteed
// to be valid throughout our lifetime.
ProxyService* service_;
CompletionCallback user_callback_;
ProxyInfo* results_;
GURL url_;
std::string method_;
- int load_flags_;
ProxyDelegate* proxy_delegate_;
ProxyResolver::RequestHandle resolve_job_;
ProxyConfig::ID config_id_; // The config id when the resolve was started.
ProxyConfigSource config_source_; // The source of proxy settings.
BoundNetLog net_log_;
// Time when the request was created. Stored here rather than in |results_|
// because the time in |results_| will be cleared.
TimeTicks creation_time_;
};
@@ -1032,34 +1028,32 @@ std::unique_ptr<ProxyService> ProxyService::CreateFixedFromPacResult(
new ProxyConfigServiceFixed(ProxyConfig::CreateAutoDetect()));
return base::WrapUnique(new ProxyService(
std::move(proxy_config_service),
base::WrapUnique(new ProxyResolverFactoryForPacResult(pac_string)),
NULL));
}
int ProxyService::ResolveProxy(const GURL& raw_url,
const std::string& method,
- int load_flags,
ProxyInfo* result,
const CompletionCallback& callback,
PacRequest** pac_request,
ProxyDelegate* proxy_delegate,
const BoundNetLog& net_log) {
DCHECK(!callback.is_null());
- return ResolveProxyHelper(raw_url, method, load_flags, result, callback,
- pac_request, proxy_delegate, net_log);
+ return ResolveProxyHelper(raw_url, method, result, callback, pac_request,
+ proxy_delegate, net_log);
}
int ProxyService::ResolveProxyHelper(const GURL& raw_url,
const std::string& method,
- int load_flags,
ProxyInfo* result,
const CompletionCallback& callback,
PacRequest** pac_request,
ProxyDelegate* proxy_delegate,
const BoundNetLog& net_log) {
DCHECK(CalledOnValidThread());
net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE);
// Notify our polling-based dependencies that a resolve is taking place.
@@ -1072,34 +1066,33 @@ int ProxyService::ResolveProxyHelper(const GURL& raw_url,
ApplyProxyConfigIfAvailable();
// Sanitize the URL before passing it on to the proxy resolver (i.e. PAC
// script). The goal is to remove sensitive data (like embedded user names
// and password), and local data (i.e. reference fragment) which does not need
// to be disclosed to the resolver.
GURL url = SanitizeUrl(raw_url, sanitize_url_policy_);
// Check if the request can be completed right away. (This is the case when
// using a direct connection for example).
- int rv = TryToCompleteSynchronously(url, load_flags, proxy_delegate, result);
+ int rv = TryToCompleteSynchronously(url, proxy_delegate, result);
if (rv != ERR_IO_PENDING) {
rv = DidFinishResolvingProxy(
- url, method, load_flags, proxy_delegate, result, rv, net_log,
+ url, method, proxy_delegate, result, rv, net_log,
callback.is_null() ? TimeTicks() : TimeTicks::Now(), false);
return rv;
}
if (callback.is_null())
return ERR_IO_PENDING;
- scoped_refptr<PacRequest> req(new PacRequest(this, url, method, load_flags,
- proxy_delegate, result, callback,
- net_log));
+ scoped_refptr<PacRequest> req(new PacRequest(
+ this, url, method, proxy_delegate, result, callback, net_log));
if (current_state_ == STATE_READY) {
// Start the resolve request.
rv = req->Start();
if (rv != ERR_IO_PENDING)
return req->QueryDidComplete(rv);
} else {
req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
}
@@ -1109,32 +1102,30 @@ int ProxyService::ResolveProxyHelper(const GURL& raw_url,
// Completion will be notified through |callback|, unless the caller cancels
// the request using |pac_request|.
if (pac_request)
*pac_request = req.get();
return rv; // ERR_IO_PENDING
}
bool ProxyService::TryResolveProxySynchronously(const GURL& raw_url,
const std::string& method,
- int load_flags,
ProxyInfo* result,
ProxyDelegate* proxy_delegate,
const BoundNetLog& net_log) {
CompletionCallback null_callback;
- return ResolveProxyHelper(raw_url, method, load_flags, result, null_callback,
+ return ResolveProxyHelper(raw_url, method, result, null_callback,
nullptr /* pac_request*/, proxy_delegate,
net_log) == OK;
}
int ProxyService::TryToCompleteSynchronously(const GURL& url,
- int load_flags,
ProxyDelegate* proxy_delegate,
ProxyInfo* result) {
DCHECK_NE(STATE_NONE, current_state_);
if (current_state_ != STATE_READY)
return ERR_IO_PENDING; // Still initializing.
DCHECK_NE(config_.id(), ProxyConfig::kInvalidConfigID);
// If it was impossible to fetch or parse the PAC script, we cannot complete
@@ -1275,41 +1266,40 @@ void ProxyService::OnInitProxyResolverComplete(int result) {
config_.set_id(fetched_config_.id());
config_.set_source(fetched_config_.source());
// Resume any requests which we had to defer until the PAC script was
// downloaded.
SetReady();
}
int ProxyService::ReconsiderProxyAfterError(const GURL& url,
const std::string& method,
- int load_flags,
int net_error,
ProxyInfo* result,
const CompletionCallback& callback,
PacRequest** pac_request,
ProxyDelegate* proxy_delegate,
const BoundNetLog& net_log) {
DCHECK(CalledOnValidThread());
// Check to see if we have a new config since ResolveProxy was called. We
// want to re-run ResolveProxy in two cases: 1) we have a new config, or 2) a
// direct connection failed and we never tried the current config.
DCHECK(result);
bool re_resolve = result->config_id_ != config_.id();
if (re_resolve) {
// If we have a new config or the config was never tried, we delete the
// list of bad proxies and we try again.
proxy_retry_info_.clear();
- return ResolveProxy(url, method, load_flags, result, callback, pac_request,
+ return ResolveProxy(url, method, result, callback, pac_request,
proxy_delegate, net_log);
}
DCHECK(!result->is_empty());
ProxyServer bad_proxy = result->proxy_server();
// We don't have new proxy settings to try, try to fallback to the next proxy
// in the list.
bool did_fallback = result->Fallback(net_error, net_log);
@@ -1377,21 +1367,20 @@ bool ProxyService::ContainsPendingRequest(PacRequest* req) {
return pending_requests_.count(req) == 1;
}
void ProxyService::RemovePendingRequest(PacRequest* req) {
DCHECK(ContainsPendingRequest(req));
pending_requests_.erase(req);
}
int ProxyService::DidFinishResolvingProxy(const GURL& url,
const std::string& method,
- int load_flags,
ProxyDelegate* proxy_delegate,
ProxyInfo* result,
int result_code,
const BoundNetLog& net_log,
base::TimeTicks start_time,
bool script_executed) {
// Don't track any metrics if start_time is 0, which will happen when the user
// calls |TryResolveProxySynchronously|.
if (!start_time.is_null()) {
TimeDelta diff = TimeTicks::Now() - start_time;
@@ -1412,21 +1401,21 @@ int ProxyService::DidFinishResolvingProxy(const GURL& url,
UMA_HISTOGRAM_CUSTOM_TIMES("Net.ProxyService.ResolveProxyTime", diff,
base::TimeDelta::FromMicroseconds(100),
base::TimeDelta::FromSeconds(20), 50);
}
// Log the result of the proxy resolution.
if (result_code == OK) {
// Allow the proxy delegate to interpose on the resolution decision,
// possibly modifying the ProxyInfo.
if (proxy_delegate)
- proxy_delegate->OnResolveProxy(url, method, load_flags, *this, result);
+ proxy_delegate->OnResolveProxy(url, method, *this, result);
net_log.AddEvent(NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST,
base::Bind(&NetLogFinishedResolvingProxyCallback, result));
// This check is done to only log the NetLog event when necessary, it's
// not a performance optimization.
if (!proxy_retry_info_.empty()) {
result->DeprioritizeBadProxies(proxy_retry_info_);
net_log.AddEvent(
NetLog::TYPE_PROXY_SERVICE_DEPRIORITIZED_BAD_PROXIES,
@@ -1444,21 +1433,21 @@ int ProxyService::DidFinishResolvingProxy(const GURL& url,
// This implicit fall-back to direct matches Firefox 3.5 and
// Internet Explorer 8. For more information, see:
//
// http://www.chromium.org/developers/design-documents/proxy-settings-fallback
result->UseDirect();
result_code = OK;
// Allow the proxy delegate to interpose on the resolution decision,
// possibly modifying the ProxyInfo.
if (proxy_delegate)
- proxy_delegate->OnResolveProxy(url, method, load_flags, *this, result);
+ proxy_delegate->OnResolveProxy(url, method, *this, result);
} else {
result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED;
}
if (reset_config) {
ResetProxyConfig(false);
// If the ProxyResolver crashed, force it to be re-initialized for the
// next request by resetting the proxy config. If there are other pending
// requests, trigger the recreation immediately so those requests retry.
if (pending_requests_.size() > 1)
ApplyProxyConfigIfAvailable();
« no previous file with comments | « net/proxy/proxy_service.h ('k') | net/proxy/proxy_service_mojo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698