Chromium Code Reviews| Index: net/proxy/proxy_service.cc |
| =================================================================== |
| --- net/proxy/proxy_service.cc (revision 141814) |
| +++ net/proxy/proxy_service.cc (working copy) |
| @@ -333,62 +333,32 @@ |
| } |
| }; |
| -// NetLog parameter to describe a proxy configuration change. |
| -class ProxyConfigChangedNetLogParam : public NetLog::EventParameters { |
| - public: |
| - ProxyConfigChangedNetLogParam(const ProxyConfig& old_config, |
| - const ProxyConfig& new_config) |
| - : old_config_(old_config), |
| - new_config_(new_config) { |
| - } |
| +// Returns NetLog parameter describing a proxy configuration change. |
| +Value* NetLogProxyConfigChangedCallback(const ProxyConfig* old_config, |
| + const ProxyConfig* new_config, |
| + NetLog::LogLevel /* log_level */) { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + // The "old_config" is optional -- the first notification will not have |
| + // any "previous" configuration. |
| + if (old_config->is_valid()) |
| + dict->Set("old_config", old_config->ToValue()); |
| + dict->Set("new_config", new_config->ToValue()); |
| + return dict; |
| +} |
| - virtual Value* ToValue() const OVERRIDE { |
| - DictionaryValue* dict = new DictionaryValue(); |
| - // The "old_config" is optional -- the first notification will not have |
| - // any "previous" configuration. |
| - if (old_config_.is_valid()) |
| - dict->Set("old_config", old_config_.ToValue()); |
| - dict->Set("new_config", new_config_.ToValue()); |
| - return dict; |
| - } |
| +Value* NetLogBadProxyListCallback(const ProxyRetryInfoMap* retry_info, |
| + NetLog::LogLevel /* log_level */) { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + ListValue* list = new ListValue(); |
| - protected: |
| - virtual ~ProxyConfigChangedNetLogParam() {} |
| - |
| - private: |
| - const ProxyConfig old_config_; |
| - const ProxyConfig new_config_; |
| - 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); |
| - } |
| + for (ProxyRetryInfoMap::const_iterator iter = retry_info->begin(); |
| + iter != retry_info->end(); ++iter) { |
| + list->Append(Value::CreateStringValue(iter->first)); |
| } |
| + dict->Set("bad_proxy_list", list); |
| + return dict; |
| +} |
| - 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; |
| - } |
| - |
| - protected: |
| - virtual ~BadProxyListNetLogParam() {} |
| - |
| - private: |
| - std::vector<std::string> proxy_list_; |
| - DISALLOW_COPY_AND_ASSIGN(BadProxyListNetLogParam); |
| -}; |
| - |
| #if defined(OS_CHROMEOS) |
| class UnsetProxyConfigService : public ProxyConfigService { |
| public: |
| @@ -846,7 +816,7 @@ |
| } |
| void Cancel() { |
| - net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); |
| + net_log_.AddEvent(NetLog::TYPE_CANCELLED); |
| if (is_started()) |
| CancelResolveJob(); |
| @@ -856,7 +826,7 @@ |
| user_callback_.Reset(); |
| results_ = NULL; |
| - net_log_.EndEvent(NetLog::TYPE_PROXY_SERVICE, NULL); |
| + net_log_.EndEvent(NetLog::TYPE_PROXY_SERVICE); |
| } |
| // Returns true if Cancel() has been called. |
| @@ -1059,7 +1029,7 @@ |
| DCHECK(CalledOnValidThread()); |
| DCHECK(!callback.is_null()); |
| - net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE, NULL); |
| + net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE); |
| // Notify our polling-based dependencies that a resolve is taking place. |
| // This way they can schedule their polls in response to network activity. |
| @@ -1089,8 +1059,7 @@ |
| if (rv != ERR_IO_PENDING) |
| return req->QueryDidComplete(rv); |
| } else { |
| - req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC, |
| - NULL); |
| + req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC); |
| } |
| DCHECK_EQ(ERR_IO_PENDING, rv); |
| @@ -1149,7 +1118,7 @@ |
| req->CancelResolveJob(); |
| req->net_log()->BeginEvent( |
| - NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC, NULL); |
| + NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC); |
| } |
| } |
| } |
| @@ -1168,8 +1137,7 @@ |
| ++it) { |
| PacRequest* req = it->get(); |
| if (!req->is_started() && !req->was_cancelled()) { |
| - req->net_log()->EndEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC, |
| - NULL); |
| + req->net_log()->EndEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC); |
| // Note that we re-check for synchronous completion, in case we are |
| // no longer using a ProxyResolver (can happen if we fell-back to manual). |
| @@ -1299,8 +1267,7 @@ |
| if (net_log_) { |
| net_log_->AddGlobalEntry( |
| NetLog::TYPE_BAD_PROXY_LIST_REPORTED, |
| - make_scoped_refptr( |
| - new BadProxyListNetLogParam(new_retry_info))); |
| + base::Bind(&NetLogBadProxyListCallback, &new_retry_info)); |
| } |
| } |
| @@ -1336,17 +1303,15 @@ |
| if (result_code == OK) { |
| // When logging all events is enabled, dump the proxy list. |
| if (net_log.IsLoggingAllEvents()) { |
| + std::string pac_string = result->ToPacString(); |
|
eroman
2012/06/13 18:55:33
Can this be internalized into the NetLog callback?
mmenke
2012/06/13 20:27:58
Done. Didn't do it before because of the "IsLoggi
|
| net_log.AddEvent( |
| NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, |
| - make_scoped_refptr(new NetLogStringParameter( |
| - "pac_string", result->ToPacString()))); |
| + NetLog::StringCallback("pac_string", &pac_string)); |
| } |
| result->DeprioritizeBadProxies(proxy_retry_info_); |
| } else { |
| - net_log.AddEvent( |
| - NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, |
| - make_scoped_refptr(new NetLogIntegerParameter( |
| - "net_error", result_code))); |
| + net_log.AddEventWithNetErrorCode( |
| + NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, result_code); |
| if (!config_.pac_mandatory()) { |
| // Fall-back to direct when the proxy resolver fails. This corresponds |
| @@ -1363,7 +1328,7 @@ |
| } |
| } |
| - net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE, NULL); |
| + net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE); |
| return result_code; |
| } |
| @@ -1509,10 +1474,10 @@ |
| // Emit the proxy settings change to the NetLog stream. |
| if (net_log_) { |
| - scoped_refptr<NetLog::EventParameters> params( |
| - new ProxyConfigChangedNetLogParam(fetched_config_, effective_config)); |
| - net_log_->AddGlobalEntry(net::NetLog::TYPE_PROXY_CONFIG_CHANGED, |
| - params); |
| + 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. |