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

Unified Diff: net/proxy/proxy_service.cc

Issue 7532011: Only mark a proxy as bad if we have confirmation that another proxy succeeded for the same request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better names Created 9 years, 4 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 d9173fb686d18d17ec82f56b8e9e17894749bad7..ccebf442f83f9d7a5b4c3e078db7c40fbc2312ce 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -264,6 +264,30 @@ class ProxyConfigChangedNetLogParam : public NetLog::EventParameters {
DISALLOW_COPY_AND_ASSIGN(ProxyConfigChangedNetLogParam);
};
+class BadProxyListNetLogParam : public NetLog::EventParameters {
+ public:
+ BadProxyListNetLogParam(const ProxyRetryInfoMap& retry_info) {
+ proxy_list_.reserve(retry_info.size());
+ for (ProxyRetryInfoMap::const_iterator iter = retry_info.begin();
+ iter != retry_info.end(); ++iter)
eroman 2011/08/19 21:25:32 nit: Please use curly braces for the body.
asanka 2011/08/19 22:09:37 Done.
+ proxy_list_.push_back(iter->first);
+ }
+
+ virtual Value* ToValue() const OVERRIDE {
+ DictionaryValue* dict = new DictionaryValue();
+ ListValue* list = new ListValue();
+ for (std::vector<std::string>::const_iterator iter = proxy_list_.begin();
+ iter != proxy_list_.end(); ++iter)
+ list->Append(Value::CreateStringValue(*iter));
+ dict->Set("bad_proxy_list", list);
+ return dict;
+ }
+
+ private:
+ std::vector<std::string> proxy_list_;
+ DISALLOW_COPY_AND_ASSIGN(BadProxyListNetLogParam);
+};
+
} // namespace
// ProxyService::PacRequest ---------------------------------------------------
@@ -715,13 +739,38 @@ int ProxyService::ReconsiderProxyAfterError(const GURL& url,
// We don't have new proxy settings to try, try to fallback to the next proxy
// in the list.
- bool did_fallback = result->Fallback(&proxy_retry_info_);
+ bool did_fallback = result->Fallback(net_log);
// Return synchronous failure if there is nothing left to fall-back to.
// TODO(eroman): This is a yucky API, clean it up.
return did_fallback ? OK : ERR_FAILED;
}
+void ProxyService::ReportSuccess(const ProxyInfo& result) {
+ DCHECK(CalledOnValidThread());
+
+ const ProxyRetryInfoMap& new_retry_info = result.proxy_retry_info();
+ if (new_retry_info.empty())
+ return;
+
+ for (ProxyRetryInfoMap::const_iterator iter = new_retry_info.begin();
+ 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;
+ else if (existing->second.bad_until < iter->second.bad_until)
+ existing->second.bad_until = iter->second.bad_until;
+ }
+ if (net_log_) {
+ net_log_->AddEntry(NetLog::TYPE_BAD_PROXY_LIST_REPORTED,
+ base::TimeTicks::Now(),
+ NetLog::Source(),
+ NetLog::PHASE_NONE,
+ make_scoped_refptr(
+ new BadProxyListNetLogParam(new_retry_info)));
+ }
+}
+
void ProxyService::CancelPacRequest(PacRequest* req) {
DCHECK(CalledOnValidThread());
DCHECK(req);

Powered by Google App Engine
This is Rietveld 408576698