diff options
author | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-29 16:39:00 +0000 |
---|---|---|
committer | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-29 16:39:00 +0000 |
commit | 96e1933fd50fb512c5e678169d0d2c59841a7d1a (patch) | |
tree | e93a20434f5478025387ca0f022d3f511a9a7bf2 /net/proxy/proxy_service.cc | |
parent | 61b75a55cd3366f236584da844cc5f9fd5a37a99 (diff) | |
download | chromium_src-96e1933fd50fb512c5e678169d0d2c59841a7d1a.zip chromium_src-96e1933fd50fb512c5e678169d0d2c59841a7d1a.tar.gz chromium_src-96e1933fd50fb512c5e678169d0d2c59841a7d1a.tar.bz2 |
Only mark a proxy as bad if we have confirmation that another proxy succeeded for the same request.
BUG=87336
TEST=net_unittests --gtest_filter=ProxyServiceTest.ProxyFallback:HttpStreamFactoryTest.JobNotifiesProxy
Review URL: http://codereview.chromium.org/7532011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98643 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_service.cc')
-rw-r--r-- | net/proxy/proxy_service.cc | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index 66bf929..643b9be 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -264,6 +264,31 @@ 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) { + 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 +740,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); |