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

Unified Diff: net/proxy/proxy_service.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
Index: net/proxy/proxy_service.cc
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index b2fcc0e401c953cae4c38089582d667b3f46650f..8411d30b2a0c06baf231555b6821e2e4f36f318c 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -129,7 +129,7 @@ class DefaultPollPolicy : public ProxyService::PacPollPolicy {
// Re-try policy for failures.
const int kDelay1Seconds = 8;
const int kDelay2Seconds = 32;
- const int kDelay3Seconds = 2 * 60; // 2 minutes
+ const int kDelay3Seconds = 2 * 60; // 2 minutes
const int kDelay4Seconds = 4 * 60 * 60; // 4 Hours
// Initial poll.
@@ -165,8 +165,8 @@ class ProxyConfigServiceDirect : public ProxyConfigService {
// ProxyConfigService implementation:
virtual void AddObserver(Observer* observer) OVERRIDE {}
virtual void RemoveObserver(Observer* observer) OVERRIDE {}
- virtual ConfigAvailability GetLatestProxyConfig(ProxyConfig* config)
- OVERRIDE {
+ virtual ConfigAvailability GetLatestProxyConfig(
+ ProxyConfig* config) OVERRIDE {
*config = ProxyConfig::CreateDirect();
config->set_source(PROXY_CONFIG_SOURCE_UNKNOWN);
return CONFIG_VALID;
@@ -187,18 +187,14 @@ class ProxyResolverNull : public ProxyResolver {
return ERR_NOT_IMPLEMENTED;
}
- virtual void CancelRequest(RequestHandle request) OVERRIDE {
- NOTREACHED();
- }
+ virtual void CancelRequest(RequestHandle request) OVERRIDE { NOTREACHED(); }
virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE {
NOTREACHED();
return LOAD_STATE_IDLE;
}
- virtual void CancelSetPacScript() OVERRIDE {
- NOTREACHED();
- }
+ virtual void CancelSetPacScript() OVERRIDE { NOTREACHED(); }
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& /*script_data*/,
@@ -212,8 +208,7 @@ class ProxyResolverNull : public ProxyResolver {
class ProxyResolverFromPacString : public ProxyResolver {
public:
explicit ProxyResolverFromPacString(const std::string& pac_string)
- : ProxyResolver(false /*expects_pac_bytes*/),
- pac_string_(pac_string) {}
+ : ProxyResolver(false /*expects_pac_bytes*/), pac_string_(pac_string) {}
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
@@ -224,18 +219,14 @@ class ProxyResolverFromPacString : public ProxyResolver {
return OK;
}
- virtual void CancelRequest(RequestHandle request) OVERRIDE {
- NOTREACHED();
- }
+ virtual void CancelRequest(RequestHandle request) OVERRIDE { NOTREACHED(); }
virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE {
NOTREACHED();
return LOAD_STATE_IDLE;
}
- virtual void CancelSetPacScript() OVERRIDE {
- NOTREACHED();
- }
+ virtual void CancelSetPacScript() OVERRIDE { NOTREACHED(); }
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& pac_script,
@@ -294,7 +285,8 @@ base::Value* NetLogBadProxyListCallback(const ProxyRetryInfoMap* retry_info,
base::ListValue* list = new base::ListValue();
for (ProxyRetryInfoMap::const_iterator iter = retry_info->begin();
- iter != retry_info->end(); ++iter) {
+ iter != retry_info->end();
+ ++iter) {
list->Append(new base::StringValue(iter->first));
}
dict->Set("bad_proxy_list", list);
@@ -344,8 +336,7 @@ class ProxyService::InitProxyResolver {
InitProxyResolver()
: proxy_resolver_(NULL),
next_state_(STATE_NONE),
- quick_check_enabled_(true) {
- }
+ quick_check_enabled_(true) {}
~InitProxyResolver() {
// Note that the destruction of ProxyScriptDecider will automatically cancel
@@ -468,7 +459,9 @@ class ProxyService::InitProxyResolver {
next_state_ = STATE_DECIDE_PROXY_SCRIPT_COMPLETE;
return decider_->Start(
- config_, wait_delay_, proxy_resolver_->expects_pac_bytes(),
+ config_,
+ wait_delay_,
+ proxy_resolver_->expects_pac_bytes(),
base::Bind(&InitProxyResolver::OnIOCompletion, base::Unretained(this)));
}
@@ -492,9 +485,7 @@ class ProxyService::InitProxyResolver {
base::Bind(&InitProxyResolver::OnIOCompletion, base::Unretained(this)));
}
- int DoSetPacScriptComplete(int result) {
- return result;
- }
+ int DoSetPacScriptComplete(int result) { return result; }
void OnIOCompletion(int result) {
DCHECK_NE(STATE_NONE, next_state_);
@@ -529,8 +520,8 @@ class ProxyService::InitProxyResolver {
// the ChangeCallback.
class ProxyService::ProxyScriptDeciderPoller {
public:
- typedef base::Callback<void(int, ProxyResolverScriptData*,
- const ProxyConfig&)> ChangeCallback;
+ typedef base::Callback<
+ void(int, ProxyResolverScriptData*, const ProxyConfig&)> ChangeCallback;
// Builds a poller helper, and starts polling for updates. Whenever a change
// is observed, |callback| will be invoked with the details.
@@ -635,7 +626,9 @@ class ProxyService::ProxyScriptDeciderPoller {
proxy_script_fetcher_, dhcp_proxy_script_fetcher_, NULL));
decider_->set_quick_check_enabled(quick_check_enabled_);
int result = decider_->Start(
- config_, TimeDelta(), proxy_resolver_expects_pac_bytes_,
+ config_,
+ TimeDelta(),
+ proxy_resolver_expects_pac_bytes_,
base::Bind(&ProxyScriptDeciderPoller::OnProxyScriptDeciderCompleted,
base::Unretained(this)));
@@ -734,11 +727,11 @@ const ProxyService::PacPollPolicy*
class ProxyService::PacRequest
: public base::RefCounted<ProxyService::PacRequest> {
public:
- PacRequest(ProxyService* service,
- const GURL& url,
- ProxyInfo* results,
- const net::CompletionCallback& user_callback,
- const BoundNetLog& net_log)
+ PacRequest(ProxyService* service,
+ const GURL& url,
+ ProxyInfo* results,
+ const net::CompletionCallback& user_callback,
+ const BoundNetLog& net_log)
: service_(service),
user_callback_(user_callback),
results_(results),
@@ -762,9 +755,11 @@ class ProxyService::PacRequest
proxy_resolve_start_time_ = TimeTicks::Now();
return resolver()->GetProxyForURL(
- url_, results_,
+ url_,
+ results_,
base::Bind(&PacRequest::QueryComplete, base::Unretained(this)),
- &resolve_job_, net_log_);
+ &resolve_job_,
+ net_log_);
}
bool is_started() const {
@@ -803,9 +798,7 @@ class ProxyService::PacRequest
}
// Returns true if Cancel() has been called.
- bool was_cancelled() const {
- return user_callback_.is_null();
- }
+ bool was_cancelled() const { return user_callback_.is_null(); }
// Helper to call after ProxyResolver completion (both synchronous and
// asynchronous). Fixes up the result that is to be returned to user.
@@ -882,10 +875,10 @@ ProxyService::ProxyService(ProxyConfigService* config_service,
NetLog* net_log)
: resolver_(resolver),
next_config_id_(1),
- current_state_(STATE_NONE) ,
+ current_state_(STATE_NONE),
net_log_(net_log),
- stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds(
- kDelayAfterNetworkChangesMs)),
+ stall_proxy_auto_config_delay_(
+ TimeDelta::FromMilliseconds(kDelayAfterNetworkChangesMs)),
quick_check_enabled_(true) {
NetworkChangeNotifier::AddIPAddressObserver(this);
NetworkChangeNotifier::AddDNSObserver(this);
@@ -918,17 +911,16 @@ ProxyService* ProxyService::CreateUsingSystemProxyResolver(
ProxyService* ProxyService::CreateWithoutProxyResolver(
ProxyConfigService* proxy_config_service,
NetLog* net_log) {
- return new ProxyService(proxy_config_service,
- new ProxyResolverNull(),
- net_log);
+ return new ProxyService(
+ proxy_config_service, new ProxyResolverNull(), net_log);
}
// static
ProxyService* ProxyService::CreateFixed(const ProxyConfig& pc) {
// TODO(eroman): This isn't quite right, won't work if |pc| specifies
// a PAC script.
- return CreateUsingSystemProxyResolver(new ProxyConfigServiceFixed(pc),
- 0, NULL);
+ return CreateUsingSystemProxyResolver(
+ new ProxyConfigServiceFixed(pc), 0, NULL);
}
// static
@@ -945,14 +937,13 @@ ProxyService* ProxyService::CreateDirect() {
ProxyService* ProxyService::CreateDirectWithNetLog(NetLog* net_log) {
// Use direct connections.
- return new ProxyService(new ProxyConfigServiceDirect, new ProxyResolverNull,
- net_log);
+ return new ProxyService(
+ new ProxyConfigServiceDirect, new ProxyResolverNull, net_log);
}
// static
ProxyService* ProxyService::CreateFixedFromPacResult(
const std::string& pac_string) {
-
// We need the settings to contain an "automatic" setting, otherwise the
// ProxyResolver dependency we give it will never be used.
scoped_ptr<ProxyConfigService> proxy_config_service(
@@ -961,9 +952,8 @@ ProxyService* ProxyService::CreateFixedFromPacResult(
scoped_ptr<ProxyResolver> proxy_resolver(
new ProxyResolverFromPacString(pac_string));
- return new ProxyService(proxy_config_service.release(),
- proxy_resolver.release(),
- NULL);
+ return new ProxyService(
+ proxy_config_service.release(), proxy_resolver.release(), NULL);
}
int ProxyService::ResolveProxy(const GURL& raw_url,
@@ -980,7 +970,7 @@ int ProxyService::ResolveProxy(const GURL& raw_url,
// This way they can schedule their polls in response to network activity.
config_service_->OnLazyPoll();
if (script_poller_.get())
- script_poller_->OnLazyPoll();
+ script_poller_->OnLazyPoll();
if (current_state_ == STATE_NONE)
ApplyProxyConfigIfAvailable();
@@ -1206,15 +1196,12 @@ int ProxyService::ReconsiderProxyAfterError(const GURL& url,
return did_fallback ? OK : ERR_FAILED;
}
-bool ProxyService::MarkProxiesAsBadUntil(
- const ProxyInfo& result,
- base::TimeDelta retry_delay,
- const ProxyServer& another_bad_proxy,
- const BoundNetLog& net_log) {
- result.proxy_list_.UpdateRetryInfoOnFallback(&proxy_retry_info_, retry_delay,
- false,
- another_bad_proxy,
- net_log);
+bool ProxyService::MarkProxiesAsBadUntil(const ProxyInfo& result,
+ base::TimeDelta retry_delay,
+ const ProxyServer& another_bad_proxy,
+ const BoundNetLog& net_log) {
+ result.proxy_list_.UpdateRetryInfoOnFallback(
+ &proxy_retry_info_, retry_delay, false, another_bad_proxy, net_log);
if (another_bad_proxy.is_valid())
return result.proxy_list_.size() > 2;
else
@@ -1229,7 +1216,8 @@ void ProxyService::ReportSuccess(const ProxyInfo& result) {
return;
for (ProxyRetryInfoMap::const_iterator iter = new_retry_info.begin();
- iter != new_retry_info.end(); ++iter) {
+ iter != new_retry_info.end();
+ ++iter) {
ProxyRetryInfoMap::iterator existing = proxy_retry_info_.find(iter->first);
if (existing == proxy_retry_info_.end())
proxy_retry_info_[iter->first] = iter->second;
@@ -1258,15 +1246,15 @@ LoadState ProxyService::GetLoadState(const PacRequest* req) const {
}
bool ProxyService::ContainsPendingRequest(PacRequest* req) {
- PendingRequests::iterator it = std::find(
- pending_requests_.begin(), pending_requests_.end(), req);
+ PendingRequests::iterator it =
+ std::find(pending_requests_.begin(), pending_requests_.end(), req);
return pending_requests_.end() != it;
}
void ProxyService::RemovePendingRequest(PacRequest* req) {
DCHECK(ContainsPendingRequest(req));
- PendingRequests::iterator it = std::find(
- pending_requests_.begin(), pending_requests_.end(), req);
+ PendingRequests::iterator it =
+ std::find(pending_requests_.begin(), pending_requests_.end(), req);
pending_requests_.erase(it);
}
@@ -1377,8 +1365,7 @@ ProxyConfigService* ProxyService::CreateSystemProxyConfigService(
<< "be used only for examples.";
return new UnsetProxyConfigService;
#elif defined(OS_LINUX)
- ProxyConfigServiceLinux* linux_config_service =
- new ProxyConfigServiceLinux();
+ ProxyConfigServiceLinux* linux_config_service = new ProxyConfigServiceLinux();
// Assume we got called on the thread that runs the default glib
// main loop, so the current thread is where we should be running
@@ -1418,7 +1405,7 @@ const ProxyService::PacPollPolicy* ProxyService::set_pac_script_poll_policy(
// static
scoped_ptr<ProxyService::PacPollPolicy>
- ProxyService::CreateDefaultPacPollPolicy() {
+ProxyService::CreateDefaultPacPollPolicy() {
return scoped_ptr<PacPollPolicy>(new DefaultPollPolicy());
}
@@ -1433,10 +1420,12 @@ void ProxyService::RecordDataReductionProxyBypassInfo(
if (is_primary) {
UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassInfoPrimary",
- bypass_type, BYPASS_EVENT_TYPE_MAX);
+ bypass_type,
+ BYPASS_EVENT_TYPE_MAX);
} else {
UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassInfoFallback",
- bypass_type, BYPASS_EVENT_TYPE_MAX);
+ bypass_type,
+ BYPASS_EVENT_TYPE_MAX);
}
}
#endif // defined(SPDY_PROXY_AUTH_ORIGIN)
@@ -1463,10 +1452,10 @@ void ProxyService::OnProxyConfigChanged(
// Emit the proxy settings change to the NetLog stream.
if (net_log_) {
- net_log_->AddGlobalEntry(
- net::NetLog::TYPE_PROXY_CONFIG_CHANGED,
- base::Bind(&NetLogProxyConfigChangedCallback,
- &fetched_config_, &effective_config));
+ net_log_->AddGlobalEntry(net::NetLog::TYPE_PROXY_CONFIG_CHANGED,
+ base::Bind(&NetLogProxyConfigChangedCallback,
+ &fetched_config_,
+ &effective_config));
}
// Set the new configuration as the most recently fetched one.
@@ -1494,8 +1483,7 @@ void ProxyService::InitializeUsingLastFetchedConfig() {
current_state_ = STATE_WAITING_FOR_INIT_PROXY_RESOLVER;
// If we changed networks recently, we should delay running proxy auto-config.
- TimeDelta wait_delay =
- stall_proxy_autoconfig_until_ - TimeTicks::Now();
+ TimeDelta wait_delay = stall_proxy_autoconfig_until_ - TimeTicks::Now();
init_proxy_resolver_.reset(new InitProxyResolver());
init_proxy_resolver_->set_quick_check_enabled(quick_check_enabled_);
@@ -1569,8 +1557,8 @@ int SyncProxyServiceHelper::ResolveProxy(const GURL& url,
io_message_loop_->PostTask(
FROM_HERE,
- base::Bind(&SyncProxyServiceHelper::StartAsyncResolve, this, url,
- net_log));
+ base::Bind(
+ &SyncProxyServiceHelper::StartAsyncResolve, this, url, net_log));
event_.Wait();
@@ -1581,13 +1569,15 @@ int SyncProxyServiceHelper::ResolveProxy(const GURL& url,
}
int SyncProxyServiceHelper::ReconsiderProxyAfterError(
- const GURL& url, ProxyInfo* proxy_info, const BoundNetLog& net_log) {
+ const GURL& url,
+ ProxyInfo* proxy_info,
+ const BoundNetLog& net_log) {
DCHECK(io_message_loop_ != base::MessageLoop::current());
io_message_loop_->PostTask(
FROM_HERE,
- base::Bind(&SyncProxyServiceHelper::StartAsyncReconsider, this, url,
- net_log));
+ base::Bind(
+ &SyncProxyServiceHelper::StartAsyncReconsider, this, url, net_log));
event_.Wait();
@@ -1597,12 +1587,13 @@ int SyncProxyServiceHelper::ReconsiderProxyAfterError(
return result_;
}
-SyncProxyServiceHelper::~SyncProxyServiceHelper() {}
+SyncProxyServiceHelper::~SyncProxyServiceHelper() {
+}
void SyncProxyServiceHelper::StartAsyncResolve(const GURL& url,
const BoundNetLog& net_log) {
- result_ = proxy_service_->ResolveProxy(
- url, &proxy_info_, callback_, NULL, net_log);
+ result_ =
+ proxy_service_->ResolveProxy(url, &proxy_info_, callback_, NULL, net_log);
if (result_ != net::ERR_IO_PENDING) {
OnCompletion(result_);
}

Powered by Google App Engine
This is Rietveld 408576698