| Index: net/proxy/proxy_resolver_v8_tracing.cc
|
| diff --git a/net/proxy/proxy_resolver_v8_tracing.cc b/net/proxy/proxy_resolver_v8_tracing.cc
|
| index f772dc1271f943e4d28624b212c11aa64ea92917..4c2489797cebb7d673536e38ba7a538cf596566a 100644
|
| --- a/net/proxy/proxy_resolver_v8_tracing.cc
|
| +++ b/net/proxy/proxy_resolver_v8_tracing.cc
|
| @@ -145,7 +145,8 @@ class ProxyResolverV8Tracing::Job
|
|
|
| void RecordMetrics() const;
|
|
|
| - void Start(Operation op, bool blocking_dns,
|
| + void Start(Operation op,
|
| + bool blocking_dns,
|
| const CompletionCallback& callback);
|
|
|
| void ExecuteBlocking();
|
| @@ -172,18 +173,22 @@ class ProxyResolverV8Tracing::Job
|
| bool PostDnsOperationAndWait(const std::string& host,
|
| ResolveDnsOperation op,
|
| bool* completed_synchronously)
|
| - WARN_UNUSED_RESULT;
|
| + WARN_UNUSED_RESULT;
|
|
|
| void DoDnsOperation();
|
| void OnDnsOperationComplete(int result);
|
|
|
| void ScheduleRestartWithBlockingDns();
|
|
|
| - bool GetDnsFromLocalCache(const std::string& host, ResolveDnsOperation op,
|
| - std::string* output, bool* return_value);
|
| + bool GetDnsFromLocalCache(const std::string& host,
|
| + ResolveDnsOperation op,
|
| + std::string* output,
|
| + bool* return_value);
|
|
|
| - void SaveDnsToLocalCache(const std::string& host, ResolveDnsOperation op,
|
| - int net_error, const net::AddressList& addresses);
|
| + void SaveDnsToLocalCache(const std::string& host,
|
| + ResolveDnsOperation op,
|
| + int net_error,
|
| + const net::AddressList& addresses);
|
|
|
| // Builds a RequestInfo to service the specified PAC DNS operation.
|
| static HostResolver::RequestInfo MakeDnsRequestInfo(const std::string& host,
|
| @@ -194,10 +199,12 @@ class ProxyResolverV8Tracing::Job
|
| static std::string MakeDnsCacheKey(const std::string& host,
|
| ResolveDnsOperation op);
|
|
|
| - void HandleAlertOrError(bool is_alert, int line_number,
|
| + void HandleAlertOrError(bool is_alert,
|
| + int line_number,
|
| const base::string16& message);
|
| void DispatchBufferedAlertsAndErrors();
|
| - void DispatchAlertOrError(bool is_alert, int line_number,
|
| + void DispatchAlertOrError(bool is_alert,
|
| + int line_number,
|
| const base::string16& message);
|
|
|
| void LogEventToCurrentRequestAndGlobally(
|
| @@ -493,8 +500,7 @@ void ProxyResolverV8Tracing::Job::NotifyCaller(int result) {
|
| metrics_end_time_ = base::TimeTicks::Now();
|
|
|
| origin_loop_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&Job::NotifyCallerOnOriginLoop, this, result));
|
| + FROM_HERE, base::Bind(&Job::NotifyCallerOnOriginLoop, this, result));
|
| }
|
|
|
| void ProxyResolverV8Tracing::Job::NotifyCallerOnOriginLoop(int result) {
|
| @@ -531,37 +537,42 @@ void ProxyResolverV8Tracing::Job::RecordMetrics() const {
|
|
|
| base::TimeTicks now = base::TimeTicks::Now();
|
|
|
| - // Metrics are output for each completed request to GetProxyForURL()).
|
| - //
|
| - // Note that a different set of histograms is used to record the metrics for
|
| - // requests that completed in non-blocking mode versus blocking mode. The
|
| - // expectation is for requests to complete in non-blocking mode each time.
|
| - // If they don't then something strange is happening, and the purpose of the
|
| - // seprate statistics is to better understand that trend.
|
| -#define UPDATE_HISTOGRAMS(base_name) \
|
| - do {\
|
| - UMA_HISTOGRAM_MEDIUM_TIMES(base_name "TotalTime", now - metrics_start_time_);\
|
| - UMA_HISTOGRAM_MEDIUM_TIMES(base_name "TotalTimeWorkerThread",\
|
| - metrics_end_time_ - metrics_start_time_);\
|
| - UMA_HISTOGRAM_TIMES(base_name "OriginThreadLatency",\
|
| - now - metrics_end_time_);\
|
| - UMA_HISTOGRAM_MEDIUM_TIMES(base_name "TotalTimeDNS",\
|
| - metrics_dns_total_time_);\
|
| - UMA_HISTOGRAM_MEDIUM_TIMES(base_name "ExecutionTime",\
|
| - metrics_execution_time_);\
|
| - UMA_HISTOGRAM_MEDIUM_TIMES(base_name "AbandonedExecutionTotalTime",\
|
| - metrics_abandoned_execution_total_time_);\
|
| - UMA_HISTOGRAM_MEDIUM_TIMES(base_name "DnsWaitTotalTime",\
|
| - metrics_nonblocking_dns_wait_total_time_);\
|
| - UMA_HISTOGRAM_CUSTOM_COUNTS(\
|
| - base_name "NumRestarts", metrics_num_executions_ - 1,\
|
| - 1, kMaxUniqueResolveDnsPerExec, kMaxUniqueResolveDnsPerExec);\
|
| - UMA_HISTOGRAM_CUSTOM_COUNTS(\
|
| - base_name "UniqueDNS", metrics_num_unique_dns_,\
|
| - 1, kMaxUniqueResolveDnsPerExec, kMaxUniqueResolveDnsPerExec);\
|
| - UMA_HISTOGRAM_COUNTS_100(base_name "NumAlerts", metrics_num_alerts_);\
|
| - UMA_HISTOGRAM_CUSTOM_COUNTS(\
|
| - base_name "NumErrors", metrics_num_errors_, 1, 10, 10);\
|
| +// Metrics are output for each completed request to GetProxyForURL()).
|
| +//
|
| +// Note that a different set of histograms is used to record the metrics for
|
| +// requests that completed in non-blocking mode versus blocking mode. The
|
| +// expectation is for requests to complete in non-blocking mode each time.
|
| +// If they don't then something strange is happening, and the purpose of the
|
| +// seprate statistics is to better understand that trend.
|
| +#define UPDATE_HISTOGRAMS(base_name) \
|
| + do { \
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base_name "TotalTime", \
|
| + now - metrics_start_time_); \
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base_name "TotalTimeWorkerThread", \
|
| + metrics_end_time_ - metrics_start_time_); \
|
| + UMA_HISTOGRAM_TIMES(base_name "OriginThreadLatency", \
|
| + now - metrics_end_time_); \
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base_name "TotalTimeDNS", \
|
| + metrics_dns_total_time_); \
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base_name "ExecutionTime", \
|
| + metrics_execution_time_); \
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base_name "AbandonedExecutionTotalTime", \
|
| + metrics_abandoned_execution_total_time_); \
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base_name "DnsWaitTotalTime", \
|
| + metrics_nonblocking_dns_wait_total_time_); \
|
| + UMA_HISTOGRAM_CUSTOM_COUNTS(base_name "NumRestarts", \
|
| + metrics_num_executions_ - 1, \
|
| + 1, \
|
| + kMaxUniqueResolveDnsPerExec, \
|
| + kMaxUniqueResolveDnsPerExec); \
|
| + UMA_HISTOGRAM_CUSTOM_COUNTS(base_name "UniqueDNS", \
|
| + metrics_num_unique_dns_, \
|
| + 1, \
|
| + kMaxUniqueResolveDnsPerExec, \
|
| + kMaxUniqueResolveDnsPerExec); \
|
| + UMA_HISTOGRAM_COUNTS_100(base_name "NumAlerts", metrics_num_alerts_); \
|
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \
|
| + base_name "NumErrors", metrics_num_errors_, 1, 10, 10); \
|
| } while (false)
|
|
|
| if (!blocking_dns_)
|
| @@ -602,8 +613,8 @@ void ProxyResolverV8Tracing::Job::RecordMetrics() const {
|
| }
|
| }
|
|
|
| -
|
| -void ProxyResolverV8Tracing::Job::Start(Operation op, bool blocking_dns,
|
| +void ProxyResolverV8Tracing::Job::Start(Operation op,
|
| + bool blocking_dns,
|
| const CompletionCallback& callback) {
|
| CheckIsOnOriginThread();
|
|
|
| @@ -615,8 +626,9 @@ void ProxyResolverV8Tracing::Job::Start(Operation op, bool blocking_dns,
|
| owned_self_reference_ = this;
|
|
|
| worker_loop()->PostTask(FROM_HERE,
|
| - blocking_dns_ ? base::Bind(&Job::ExecuteBlocking, this) :
|
| - base::Bind(&Job::ExecuteNonBlocking, this));
|
| + blocking_dns_
|
| + ? base::Bind(&Job::ExecuteBlocking, this)
|
| + : base::Bind(&Job::ExecuteNonBlocking, this));
|
| }
|
|
|
| void ProxyResolverV8Tracing::Job::ExecuteBlocking() {
|
| @@ -675,19 +687,18 @@ int ProxyResolverV8Tracing::Job::ExecuteProxyResolver() {
|
|
|
| switch (operation_) {
|
| case SET_PAC_SCRIPT:
|
| - result = v8_resolver()->SetPacScript(
|
| - script_data_, CompletionCallback());
|
| + result = v8_resolver()->SetPacScript(script_data_, CompletionCallback());
|
| break;
|
| case GET_PROXY_FOR_URL:
|
| result = v8_resolver()->GetProxyForURL(
|
| - url_,
|
| - // Important: Do not write directly into |user_results_|, since if the
|
| - // request were to be cancelled from the origin thread, must guarantee
|
| - // that |user_results_| is not accessed anymore.
|
| - &results_,
|
| - CompletionCallback(),
|
| - NULL,
|
| - bound_net_log_);
|
| + url_,
|
| + // Important: Do not write directly into |user_results_|, since if the
|
| + // request were to be cancelled from the origin thread, must guarantee
|
| + // that |user_results_| is not accessed anymore.
|
| + &results_,
|
| + CompletionCallback(),
|
| + NULL,
|
| + bound_net_log_);
|
| break;
|
| }
|
|
|
| @@ -712,9 +723,8 @@ bool ProxyResolverV8Tracing::Job::ResolveDns(const std::string& host,
|
| return false;
|
| }
|
|
|
| - return blocking_dns_ ?
|
| - ResolveDnsBlocking(host, op, output) :
|
| - ResolveDnsNonBlocking(host, op, output, terminate);
|
| + return blocking_dns_ ? ResolveDnsBlocking(host, op, output)
|
| + : ResolveDnsNonBlocking(host, op, output, terminate);
|
| }
|
|
|
| void ProxyResolverV8Tracing::Job::Alert(const base::string16& message) {
|
| @@ -812,9 +822,9 @@ bool ProxyResolverV8Tracing::Job::ResolveDnsNonBlocking(const std::string& host,
|
| }
|
|
|
| bool ProxyResolverV8Tracing::Job::PostDnsOperationAndWait(
|
| - const std::string& host, ResolveDnsOperation op,
|
| + const std::string& host,
|
| + ResolveDnsOperation op,
|
| bool* completed_synchronously) {
|
| -
|
| base::TimeTicks start = base::TimeTicks::Now();
|
|
|
| // Post the DNS request to the origin thread.
|
| @@ -887,8 +897,8 @@ void ProxyResolverV8Tracing::Job::OnDnsOperationComplete(int result) {
|
| DCHECK(!cancelled_.IsSet());
|
| DCHECK(pending_dns_completed_synchronously_ == (pending_dns_ == NULL));
|
|
|
| - SaveDnsToLocalCache(pending_dns_host_, pending_dns_op_, result,
|
| - pending_dns_addresses_);
|
| + SaveDnsToLocalCache(
|
| + pending_dns_host_, pending_dns_op_, result, pending_dns_addresses_);
|
| pending_dns_ = NULL;
|
|
|
| metrics_dns_total_time_ +=
|
| @@ -920,11 +930,10 @@ void ProxyResolverV8Tracing::Job::ScheduleRestartWithBlockingDns() {
|
| should_restart_with_blocking_dns_ = true;
|
| }
|
|
|
| -bool ProxyResolverV8Tracing::Job::GetDnsFromLocalCache(
|
| - const std::string& host,
|
| - ResolveDnsOperation op,
|
| - std::string* output,
|
| - bool* return_value) {
|
| +bool ProxyResolverV8Tracing::Job::GetDnsFromLocalCache(const std::string& host,
|
| + ResolveDnsOperation op,
|
| + std::string* output,
|
| + bool* return_value) {
|
| CheckIsOnWorkerThread();
|
|
|
| DnsCache::const_iterator it = dns_cache_.find(MakeDnsCacheKey(host, op));
|
| @@ -954,7 +963,8 @@ void ProxyResolverV8Tracing::Job::SaveDnsToLocalCache(
|
| } else {
|
| // The *Ex versions are expected to return a semi-colon separated list.
|
| for (AddressList::const_iterator iter = addresses.begin();
|
| - iter != addresses.end(); ++iter) {
|
| + iter != addresses.end();
|
| + ++iter) {
|
| if (!cache_value.empty())
|
| cache_value += ";";
|
| cache_value += iter->ToStringWithoutPort();
|
| @@ -966,7 +976,8 @@ void ProxyResolverV8Tracing::Job::SaveDnsToLocalCache(
|
|
|
| // static
|
| HostResolver::RequestInfo ProxyResolverV8Tracing::Job::MakeDnsRequestInfo(
|
| - const std::string& host, ResolveDnsOperation op) {
|
| + const std::string& host,
|
| + ResolveDnsOperation op) {
|
| HostPortPair host_port = HostPortPair(host, 80);
|
| if (op == MY_IP_ADDRESS || op == MY_IP_ADDRESS_EX) {
|
| host_port.set_host(GetHostName());
|
| @@ -983,7 +994,8 @@ HostResolver::RequestInfo ProxyResolverV8Tracing::Job::MakeDnsRequestInfo(
|
| }
|
|
|
| std::string ProxyResolverV8Tracing::Job::MakeDnsCacheKey(
|
| - const std::string& host, ResolveDnsOperation op) {
|
| + const std::string& host,
|
| + ResolveDnsOperation op) {
|
| return base::StringPrintf("%d:%s", op, host.c_str());
|
| }
|
|
|
| @@ -1034,7 +1046,9 @@ void ProxyResolverV8Tracing::Job::DispatchBufferedAlertsAndErrors() {
|
| }
|
|
|
| void ProxyResolverV8Tracing::Job::DispatchAlertOrError(
|
| - bool is_alert, int line_number, const base::string16& message) {
|
| + bool is_alert,
|
| + int line_number,
|
| + const base::string16& message) {
|
| CheckIsOnWorkerThread();
|
|
|
| // Note that the handling of cancellation is racy with regard to
|
| @@ -1066,7 +1080,8 @@ void ProxyResolverV8Tracing::Job::DispatchAlertOrError(
|
| if (line_number == -1)
|
| VLOG(1) << "PAC-error: " << message;
|
| else
|
| - VLOG(1) << "PAC-error: " << "line: " << line_number << ": " << message;
|
| + VLOG(1) << "PAC-error: "
|
| + << "line: " << line_number << ": " << message;
|
|
|
| // Send the error to the NetLog.
|
| LogEventToCurrentRequestAndGlobally(
|
|
|