Chromium Code Reviews| 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); |