diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 21:00:23 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 21:00:23 +0000 |
commit | ebed34a009983b7207e88aa01a9c3eb2c1395bae (patch) | |
tree | d8c94afbcff5058ebd887b6c1093109fed6a5804 /net | |
parent | bd1ec999e09bc86c614b8a0cb95981e336f688d0 (diff) | |
download | chromium_src-ebed34a009983b7207e88aa01a9c3eb2c1395bae.zip chromium_src-ebed34a009983b7207e88aa01a9c3eb2c1395bae.tar.gz chromium_src-ebed34a009983b7207e88aa01a9c3eb2c1395bae.tar.bz2 |
NetLogEventParameter to Callback refactoring 7.
Get rid of all uses of NetLogEventParameters in net/proxy.
R=eroman@chromium.org
BUG=126243
Review URL: https://chromiumcodereview.appspot.com/10534132
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/proxy/multi_threaded_proxy_resolver.cc | 9 | ||||
-rw-r--r-- | net/proxy/multi_threaded_proxy_resolver_unittest.cc | 2 | ||||
-rw-r--r-- | net/proxy/proxy_list.cc | 6 | ||||
-rw-r--r-- | net/proxy/proxy_resolver_js_bindings.cc | 104 | ||||
-rw-r--r-- | net/proxy/proxy_script_decider.cc | 62 | ||||
-rw-r--r-- | net/proxy/proxy_script_decider.h | 10 | ||||
-rw-r--r-- | net/proxy/proxy_service.cc | 116 |
7 files changed, 133 insertions, 176 deletions
diff --git a/net/proxy/multi_threaded_proxy_resolver.cc b/net/proxy/multi_threaded_proxy_resolver.cc index e0a1bdd..de73913 100644 --- a/net/proxy/multi_threaded_proxy_resolver.cc +++ b/net/proxy/multi_threaded_proxy_resolver.cc @@ -239,22 +239,19 @@ class MultiThreadedProxyResolver::GetProxyForURLJob virtual void WaitingForThread() OVERRIDE { was_waiting_for_thread_ = true; - net_log_.BeginEvent( - NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD, NULL); + net_log_.BeginEvent(NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD); } virtual void FinishedWaitingForThread() OVERRIDE { DCHECK(executor()); if (was_waiting_for_thread_) { - net_log_.EndEvent( - NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD, NULL); + net_log_.EndEvent(NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD); } net_log_.AddEvent( NetLog::TYPE_SUBMITTED_TO_RESOLVER_THREAD, - make_scoped_refptr(new NetLogIntegerParameter( - "thread_number", executor()->thread_number()))); + NetLog::IntegerCallback("thread_number", executor()->thread_number())); } // Runs on the worker thread. diff --git a/net/proxy/multi_threaded_proxy_resolver_unittest.cc b/net/proxy/multi_threaded_proxy_resolver_unittest.cc index 595fd78..fc0f438 100644 --- a/net/proxy/multi_threaded_proxy_resolver_unittest.cc +++ b/net/proxy/multi_threaded_proxy_resolver_unittest.cc @@ -49,7 +49,7 @@ class MockProxyResolver : public ProxyResolver { EXPECT_TRUE(request == NULL); // Write something into |net_log| (doesn't really have any meaning.) - net_log.BeginEvent(NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE, NULL); + net_log.BeginEvent(NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE); results->UseNamedProxy(query_url.host()); diff --git a/net/proxy/proxy_list.cc b/net/proxy/proxy_list.cc index d4867e0..3a63c6c 100644 --- a/net/proxy/proxy_list.cc +++ b/net/proxy/proxy_list.cc @@ -4,6 +4,7 @@ #include "net/proxy/proxy_list.h" +#include "base/callback.h" #include "base/logging.h" #include "base/string_tokenizer.h" #include "base/time.h" @@ -161,9 +162,8 @@ bool ProxyList::Fallback(ProxyRetryInfoMap* proxy_retry_info, retry_info.bad_until = TimeTicks().Now() + retry_info.current_delay; (*proxy_retry_info)[key] = retry_info; } - net_log.AddEvent( - NetLog::TYPE_PROXY_LIST_FALLBACK, - make_scoped_refptr(new NetLogStringParameter("bad_proxy", key))); + net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, + NetLog::StringCallback("bad_proxy", &key)); } // Remove this proxy from our list. diff --git a/net/proxy/proxy_resolver_js_bindings.cc b/net/proxy/proxy_resolver_js_bindings.cc index dcffe3a..d849a24 100644 --- a/net/proxy/proxy_resolver_js_bindings.cc +++ b/net/proxy/proxy_resolver_js_bindings.cc @@ -4,6 +4,7 @@ #include "net/proxy/proxy_resolver_js_bindings.h" +#include "base/bind.h" #include "base/compiler_specific.h" #include "base/logging.h" #include "base/string_util.h" @@ -26,51 +27,15 @@ namespace { // DNS resolutions. const unsigned kCacheEntryTTLSeconds = 5 * 60; -// Event parameters for a PAC error message (line number + message). -class ErrorNetlogParams : public NetLog::EventParameters { - public: - ErrorNetlogParams(int line_number, - const string16& message) - : line_number_(line_number), - message_(message) { - } - - virtual Value* ToValue() const OVERRIDE { - DictionaryValue* dict = new DictionaryValue(); - dict->SetInteger("line_number", line_number_); - dict->SetString("message", message_); - return dict; - } - - protected: - virtual ~ErrorNetlogParams() {} - - private: - const int line_number_; - const string16 message_; - - DISALLOW_COPY_AND_ASSIGN(ErrorNetlogParams); -}; - -// Event parameters for a PAC alert(). -class AlertNetlogParams : public NetLog::EventParameters { - public: - explicit AlertNetlogParams(const string16& message) : message_(message) {} - - virtual Value* ToValue() const OVERRIDE { - DictionaryValue* dict = new DictionaryValue(); - dict->SetString("message", message_); - return dict; - } - - protected: - virtual ~AlertNetlogParams() {} - - private: - const string16 message_; - - DISALLOW_COPY_AND_ASSIGN(AlertNetlogParams); -}; +// Returns event parameters for a PAC error message (line number + message). +Value* NetLogErrorCallback(int line_number, + const string16* message, + NetLog::LogLevel /* log_level */) { + DictionaryValue* dict = new DictionaryValue(); + dict->SetInteger("line_number", line_number); + dict->SetString("message", *message); + return dict; +} // ProxyResolverJSBindings implementation. class DefaultJSBindings : public ProxyResolverJSBindings { @@ -88,8 +53,9 @@ class DefaultJSBindings : public ProxyResolverJSBindings { VLOG(1) << "PAC-alert: " << message; // Send to the NetLog. - LogEventToCurrentRequestAndGlobally(NetLog::TYPE_PAC_JAVASCRIPT_ALERT, - new AlertNetlogParams(message)); + LogEventToCurrentRequestAndGlobally( + NetLog::TYPE_PAC_JAVASCRIPT_ALERT, + NetLog::StringCallback("message", &message)); } // Handler for "myIpAddress()". @@ -97,28 +63,24 @@ class DefaultJSBindings : public ProxyResolverJSBindings { // getifaddrs(). virtual bool MyIpAddress(std::string* first_ip_address) OVERRIDE { LogEventToCurrentRequest(NetLog::PHASE_BEGIN, - NetLog::TYPE_PAC_JAVASCRIPT_MY_IP_ADDRESS, - NULL); + NetLog::TYPE_PAC_JAVASCRIPT_MY_IP_ADDRESS); bool ok = MyIpAddressImpl(first_ip_address); LogEventToCurrentRequest(NetLog::PHASE_END, - NetLog::TYPE_PAC_JAVASCRIPT_MY_IP_ADDRESS, - NULL); + NetLog::TYPE_PAC_JAVASCRIPT_MY_IP_ADDRESS); return ok; } // Handler for "myIpAddressEx()". virtual bool MyIpAddressEx(std::string* ip_address_list) OVERRIDE { LogEventToCurrentRequest(NetLog::PHASE_BEGIN, - NetLog::TYPE_PAC_JAVASCRIPT_MY_IP_ADDRESS_EX, - NULL); + NetLog::TYPE_PAC_JAVASCRIPT_MY_IP_ADDRESS_EX); bool ok = MyIpAddressExImpl(ip_address_list); LogEventToCurrentRequest(NetLog::PHASE_END, - NetLog::TYPE_PAC_JAVASCRIPT_MY_IP_ADDRESS_EX, - NULL); + NetLog::TYPE_PAC_JAVASCRIPT_MY_IP_ADDRESS_EX); return ok; } @@ -126,14 +88,12 @@ class DefaultJSBindings : public ProxyResolverJSBindings { virtual bool DnsResolve(const std::string& host, std::string* first_ip_address) OVERRIDE { LogEventToCurrentRequest(NetLog::PHASE_BEGIN, - NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE, - NULL); + NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE); bool ok = DnsResolveImpl(host, first_ip_address); LogEventToCurrentRequest(NetLog::PHASE_END, - NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE, - NULL); + NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE); return ok; } @@ -141,14 +101,12 @@ class DefaultJSBindings : public ProxyResolverJSBindings { virtual bool DnsResolveEx(const std::string& host, std::string* ip_address_list) OVERRIDE { LogEventToCurrentRequest(NetLog::PHASE_BEGIN, - NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE_EX, - NULL); + NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE_EX); bool ok = DnsResolveExImpl(host, ip_address_list); LogEventToCurrentRequest(NetLog::PHASE_END, - NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE_EX, - NULL); + NetLog::TYPE_PAC_JAVASCRIPT_DNS_RESOLVE_EX); return ok; } @@ -163,7 +121,7 @@ class DefaultJSBindings : public ProxyResolverJSBindings { // Send the error to the NetLog. LogEventToCurrentRequestAndGlobally( NetLog::TYPE_PAC_JAVASCRIPT_ERROR, - new ErrorNetlogParams(line_number, message)); + base::Bind(&NetLogErrorCallback, line_number, &message)); if (error_observer_.get()) error_observer_->OnPACScriptError(line_number, message); @@ -289,21 +247,29 @@ class DefaultJSBindings : public ProxyResolverJSBindings { void LogEventToCurrentRequest( NetLog::EventPhase phase, + NetLog::EventType type) { + const BoundNetLog* net_log = GetNetLogForCurrentRequest(); + if (net_log) + net_log->AddEntry(type, phase); + } + + void LogEventToCurrentRequest( + NetLog::EventPhase phase, NetLog::EventType type, - scoped_refptr<NetLog::EventParameters> params) { + const NetLog::ParametersCallback& parameters_callback) { const BoundNetLog* net_log = GetNetLogForCurrentRequest(); if (net_log) - net_log->AddEntry(type, phase, params); + net_log->AddEntry(type, phase, parameters_callback); } void LogEventToCurrentRequestAndGlobally( NetLog::EventType type, - scoped_refptr<NetLog::EventParameters> params) { - LogEventToCurrentRequest(NetLog::PHASE_NONE, type, params); + const NetLog::ParametersCallback& parameters_callback) { + LogEventToCurrentRequest(NetLog::PHASE_NONE, type, parameters_callback); // Emit to the global NetLog event stream. if (net_log_) - net_log_->AddGlobalEntry(type, params); + net_log_->AddGlobalEntry(type, parameters_callback); } scoped_ptr<SyncHostResolver> host_resolver_; diff --git a/net/proxy/proxy_script_decider.cc b/net/proxy/proxy_script_decider.cc index 5b5248d..21e3ae0 100644 --- a/net/proxy/proxy_script_decider.cc +++ b/net/proxy/proxy_script_decider.cc @@ -11,7 +11,7 @@ #include "base/logging.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "net/base/net_log.h" +#include "base/values.h" #include "net/base/net_errors.h" #include "net/proxy/dhcp_proxy_script_fetcher.h" #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" @@ -20,6 +20,7 @@ namespace net { namespace { + bool LooksLikePacScript(const string16& script) { // Note: this is only an approximation! It may not always work correctly, // however it is very likely that legitimate scripts have this exact string, @@ -29,6 +30,7 @@ bool LooksLikePacScript(const string16& script) { // An exact test would have to load the script in a javascript evaluator. return script.find(ASCIIToUTF16("FindProxyForURL")) != string16::npos; } + } // This is the hard-coded location used by the DNS portion of web proxy @@ -45,6 +47,28 @@ bool LooksLikePacScript(const string16& script) { // http://code.google.com/p/chromium/issues/detail?id=18575#c20 static const char kWpadUrl[] = "http://wpad/wpad.dat"; +Value* ProxyScriptDecider::PacSource::NetLogCallback( + const GURL* effective_pac_url, + NetLog::LogLevel /* log_level */) const { + DictionaryValue* dict = new DictionaryValue(); + std::string source; + switch (type) { + case PacSource::WPAD_DHCP: + source = "WPAD DHCP"; + break; + case PacSource::WPAD_DNS: + source = "WPAD DNS: "; + source += effective_pac_url->possibly_invalid_spec(); + break; + case PacSource::CUSTOM: + source = "Custom PAC URL: "; + source += effective_pac_url->possibly_invalid_spec(); + break; + } + dict->SetString("source", source); + return dict; +} + ProxyScriptDecider::ProxyScriptDecider( ProxyScriptFetcher* proxy_script_fetcher, DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher, @@ -72,7 +96,7 @@ int ProxyScriptDecider::Start( DCHECK(!callback.is_null()); DCHECK(config.HasAutomaticSettings()); - net_log_.BeginEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER, NULL); + net_log_.BeginEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER); fetch_pac_bytes_ = fetch_pac_bytes; @@ -187,7 +211,7 @@ int ProxyScriptDecider::DoWait() { // Otherwise wait the specified amount of time. wait_timer_.Start(FROM_HERE, wait_delay_, this, &ProxyScriptDecider::OnWaitTimerFired); - net_log_.BeginEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER_WAIT, NULL); + net_log_.BeginEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER_WAIT); return ERR_IO_PENDING; } @@ -209,16 +233,16 @@ int ProxyScriptDecider::DoFetchPacScript() { const PacSource& pac_source = current_pac_source(); GURL effective_pac_url; - NetLogStringParameter* log_parameter = - CreateNetLogParameterAndDetermineURL(pac_source, &effective_pac_url); + DetermineURL(pac_source, &effective_pac_url); - net_log_.BeginEvent( - NetLog::TYPE_PROXY_SCRIPT_DECIDER_FETCH_PAC_SCRIPT, - make_scoped_refptr(log_parameter)); + net_log_.BeginEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER_FETCH_PAC_SCRIPT, + base::Bind(&PacSource::NetLogCallback, + base::Unretained(&pac_source), + &effective_pac_url)); if (pac_source.type == PacSource::WPAD_DHCP) { if (!dhcp_proxy_script_fetcher_) { - net_log_.AddEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER_HAS_NO_FETCHER, NULL); + net_log_.AddEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER_HAS_NO_FETCHER); return ERR_UNEXPECTED; } @@ -228,7 +252,7 @@ int ProxyScriptDecider::DoFetchPacScript() { } if (!proxy_script_fetcher_) { - net_log_.AddEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER_HAS_NO_FETCHER, NULL); + net_log_.AddEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER_HAS_NO_FETCHER); return ERR_UNEXPECTED; } @@ -322,7 +346,7 @@ int ProxyScriptDecider::TryToFallbackPacSource(int error) { ++current_pac_source_index_; net_log_.AddEvent( - NetLog::TYPE_PROXY_SCRIPT_DECIDER_FALLING_BACK_TO_NEXT_PAC_SOURCE, NULL); + NetLog::TYPE_PROXY_SCRIPT_DECIDER_FALLING_BACK_TO_NEXT_PAC_SOURCE); next_state_ = GetStartState(); @@ -333,28 +357,20 @@ ProxyScriptDecider::State ProxyScriptDecider::GetStartState() const { return fetch_pac_bytes_ ? STATE_FETCH_PAC_SCRIPT : STATE_VERIFY_PAC_SCRIPT; } -NetLogStringParameter* ProxyScriptDecider::CreateNetLogParameterAndDetermineURL( - const PacSource& pac_source, - GURL* effective_pac_url) { +void ProxyScriptDecider::DetermineURL(const PacSource& pac_source, + GURL* effective_pac_url) { DCHECK(effective_pac_url); - std::string source_field; switch (pac_source.type) { case PacSource::WPAD_DHCP: - source_field = "WPAD DHCP"; break; case PacSource::WPAD_DNS: *effective_pac_url = GURL(kWpadUrl); - source_field = "WPAD DNS: "; - source_field += effective_pac_url->possibly_invalid_spec(); break; case PacSource::CUSTOM: *effective_pac_url = pac_source.url; - source_field = "Custom PAC URL: "; - source_field += effective_pac_url->possibly_invalid_spec(); break; } - return new NetLogStringParameter("source", source_field); } const ProxyScriptDecider::PacSource& @@ -368,13 +384,13 @@ void ProxyScriptDecider::OnWaitTimerFired() { } void ProxyScriptDecider::DidComplete() { - net_log_.EndEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER, NULL); + net_log_.EndEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER); } void ProxyScriptDecider::Cancel() { DCHECK_NE(STATE_NONE, next_state_); - net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); + net_log_.AddEvent(NetLog::TYPE_CANCELLED); switch (next_state_) { case STATE_WAIT_COMPLETE: diff --git a/net/proxy/proxy_script_decider.h b/net/proxy/proxy_script_decider.h index 7f680db..ae393cd 100644 --- a/net/proxy/proxy_script_decider.h +++ b/net/proxy/proxy_script_decider.h @@ -6,6 +6,7 @@ #define NET_PROXY_PROXY_SCRIPT_DECIDER_H_ #pragma once +#include <string> #include <vector> #include "base/memory/ref_counted.h" @@ -89,6 +90,12 @@ class NET_EXPORT_PRIVATE ProxyScriptDecider { PacSource(Type type, const GURL& url) : type(type), url(url) {} + // Returns a Value representing the PacSource. |effective_pac_url| must + // be non-NULL and point to the URL derived from information contained in + // |this|, if Type is not WPAD_DHCP. + base::Value* NetLogCallback(const GURL* effective_pac_url, + NetLog::LogLevel log_level) const; + Type type; GURL url; // Empty unless |type == PAC_SOURCE_CUSTOM|. }; @@ -131,8 +138,7 @@ class NET_EXPORT_PRIVATE ProxyScriptDecider { // ProxyResolver doesn't |expect_pac_bytes()|. State GetStartState() const; - NetLogStringParameter* CreateNetLogParameterAndDetermineURL( - const PacSource& pac_source, GURL* effective_pac_url); + void DetermineURL(const PacSource& pac_source, GURL* effective_pac_url); // Returns the current PAC URL we are fetching/testing. const PacSource& current_pac_source() const; diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index b210bd8..929cefe 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -333,61 +333,39 @@ class ProxyResolverFactoryForSystem : public ProxyResolverFactory { } }; -// 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) { - } - - 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; - } - - protected: - virtual ~ProxyConfigChangedNetLogParam() {} - - private: - const ProxyConfig old_config_; - const ProxyConfig new_config_; - DISALLOW_COPY_AND_ASSIGN(ProxyConfigChangedNetLogParam); -}; +// Returns NetLog parameters 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; +} -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); - } - } +Value* NetLogBadProxyListCallback(const ProxyRetryInfoMap* retry_info, + NetLog::LogLevel /* log_level */) { + DictionaryValue* dict = new DictionaryValue(); + ListValue* list = new ListValue(); - 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; + 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; +} - protected: - virtual ~BadProxyListNetLogParam() {} - - private: - std::vector<std::string> proxy_list_; - DISALLOW_COPY_AND_ASSIGN(BadProxyListNetLogParam); -}; +// Returns NetLog parameters on a successfuly proxy resolution. +Value* NetLogFinishedResolvingProxyCallback(ProxyInfo* result, + NetLog::LogLevel /* log_level */) { + DictionaryValue* dict = new DictionaryValue(); + dict->SetString("pac_string", result->ToPacString()); + return dict; +} #if defined(OS_CHROMEOS) class UnsetProxyConfigService : public ProxyConfigService { @@ -846,7 +824,7 @@ class ProxyService::PacRequest } void Cancel() { - net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); + net_log_.AddEvent(NetLog::TYPE_CANCELLED); if (is_started()) CancelResolveJob(); @@ -856,7 +834,7 @@ class ProxyService::PacRequest 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 +1037,7 @@ int ProxyService::ResolveProxy(const GURL& raw_url, 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 +1067,7 @@ int ProxyService::ResolveProxy(const GURL& raw_url, 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 +1126,7 @@ void ProxyService::SuspendAllPendingRequests() { 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 +1145,7 @@ void ProxyService::SetReady() { ++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 +1275,7 @@ void ProxyService::ReportSuccess(const ProxyInfo& result) { 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)); } } @@ -1338,15 +1313,12 @@ int ProxyService::DidFinishResolvingProxy(ProxyInfo* result, if (net_log.IsLoggingAllEvents()) { net_log.AddEvent( NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, - make_scoped_refptr(new NetLogStringParameter( - "pac_string", result->ToPacString()))); + base::Bind(&NetLogFinishedResolvingProxyCallback, result)); } 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 +1335,7 @@ int ProxyService::DidFinishResolvingProxy(ProxyInfo* result, } } - net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE, NULL); + net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE); return result_code; } @@ -1509,10 +1481,10 @@ void ProxyService::OnProxyConfigChanged( // 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. |