| Index: net/dns/host_resolver_impl.cc
|
| diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
|
| index a1ab0e5b9b4f54bf12e65ee4e91e40b1b5a2f160..4aba0fc68f796dce547a472aec83cd6c52b640f9 100644
|
| --- a/net/dns/host_resolver_impl.cc
|
| +++ b/net/dns/host_resolver_impl.cc
|
| @@ -142,9 +142,8 @@ enum DnsResolveStatus {
|
| };
|
|
|
| void UmaAsyncDnsResolveStatus(DnsResolveStatus result) {
|
| - UMA_HISTOGRAM_ENUMERATION("AsyncDNS.ResolveStatus",
|
| - result,
|
| - RESOLVE_STATUS_MAX);
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + "AsyncDNS.ResolveStatus", result, RESOLVE_STATUS_MAX);
|
| }
|
|
|
| bool ResemblesNetBIOSName(const std::string& hostname) {
|
| @@ -159,11 +158,13 @@ bool ResemblesMulticastDNSName(const std::string& hostname) {
|
| const size_t kSuffixLenTrimmed = kSuffixLen - 1;
|
| if (hostname[hostname.size() - 1] == '.') {
|
| return hostname.size() > kSuffixLen &&
|
| - !hostname.compare(hostname.size() - kSuffixLen, kSuffixLen, kSuffix);
|
| + !hostname.compare(hostname.size() - kSuffixLen, kSuffixLen, kSuffix);
|
| }
|
| return hostname.size() > kSuffixLenTrimmed &&
|
| - !hostname.compare(hostname.size() - kSuffixLenTrimmed, kSuffixLenTrimmed,
|
| - kSuffix, kSuffixLenTrimmed);
|
| + !hostname.compare(hostname.size() - kSuffixLenTrimmed,
|
| + kSuffixLenTrimmed,
|
| + kSuffix,
|
| + kSuffixLenTrimmed);
|
| }
|
|
|
| // Attempts to connect a UDP socket to |dest|:53.
|
| @@ -187,10 +188,9 @@ bool IsGloballyReachable(const IPAddressNumber& dest,
|
| bool is_link_local = (address[0] == 0xFE) && ((address[1] & 0xC0) == 0x80);
|
| if (is_link_local)
|
| return false;
|
| - const uint8 kTeredoPrefix[] = { 0x20, 0x01, 0, 0 };
|
| - bool is_teredo = std::equal(kTeredoPrefix,
|
| - kTeredoPrefix + arraysize(kTeredoPrefix),
|
| - address.begin());
|
| + const uint8 kTeredoPrefix[] = {0x20, 0x01, 0, 0};
|
| + bool is_teredo = std::equal(
|
| + kTeredoPrefix, kTeredoPrefix + arraysize(kTeredoPrefix), address.begin());
|
| if (is_teredo)
|
| return false;
|
| return true;
|
| @@ -198,21 +198,37 @@ bool IsGloballyReachable(const IPAddressNumber& dest,
|
|
|
| // Provide a common macro to simplify code and readability. We must use a
|
| // macro as the underlying HISTOGRAM macro creates static variables.
|
| -#define DNS_HISTOGRAM(name, time) UMA_HISTOGRAM_CUSTOM_TIMES(name, time, \
|
| - base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 100)
|
| +#define DNS_HISTOGRAM(name, time) \
|
| + UMA_HISTOGRAM_CUSTOM_TIMES(name, \
|
| + time, \
|
| + base::TimeDelta::FromMilliseconds(1), \
|
| + base::TimeDelta::FromHours(1), \
|
| + 100)
|
|
|
| // A macro to simplify code and readability.
|
| #define DNS_HISTOGRAM_BY_PRIORITY(basename, priority, time) \
|
| - do { \
|
| - switch (priority) { \
|
| - case HIGHEST: DNS_HISTOGRAM(basename "_HIGHEST", time); break; \
|
| - case MEDIUM: DNS_HISTOGRAM(basename "_MEDIUM", time); break; \
|
| - case LOW: DNS_HISTOGRAM(basename "_LOW", time); break; \
|
| - case LOWEST: DNS_HISTOGRAM(basename "_LOWEST", time); break; \
|
| - case IDLE: DNS_HISTOGRAM(basename "_IDLE", time); break; \
|
| - default: NOTREACHED(); break; \
|
| - } \
|
| - DNS_HISTOGRAM(basename, time); \
|
| + do { \
|
| + switch (priority) { \
|
| + case HIGHEST: \
|
| + DNS_HISTOGRAM(basename "_HIGHEST", time); \
|
| + break; \
|
| + case MEDIUM: \
|
| + DNS_HISTOGRAM(basename "_MEDIUM", time); \
|
| + break; \
|
| + case LOW: \
|
| + DNS_HISTOGRAM(basename "_LOW", time); \
|
| + break; \
|
| + case LOWEST: \
|
| + DNS_HISTOGRAM(basename "_LOWEST", time); \
|
| + break; \
|
| + case IDLE: \
|
| + DNS_HISTOGRAM(basename "_IDLE", time); \
|
| + break; \
|
| + default: \
|
| + NOTREACHED(); \
|
| + break; \
|
| + } \
|
| + DNS_HISTOGRAM(basename, time); \
|
| } while (0)
|
|
|
| // Record time from Request creation until a valid DNS response.
|
| @@ -235,9 +251,11 @@ void RecordTotalTime(bool had_dns_config,
|
| }
|
|
|
| void RecordTTL(base::TimeDelta ttl) {
|
| - UMA_HISTOGRAM_CUSTOM_TIMES("AsyncDNS.TTL", ttl,
|
| + UMA_HISTOGRAM_CUSTOM_TIMES("AsyncDNS.TTL",
|
| + ttl,
|
| base::TimeDelta::FromSeconds(1),
|
| - base::TimeDelta::FromDays(1), 100);
|
| + base::TimeDelta::FromDays(1),
|
| + 100);
|
| }
|
|
|
| bool ConfigureAsyncDnsNoFallbackFieldTrial() {
|
| @@ -299,14 +317,14 @@ base::Value* NetLogProcTaskFailedCallback(uint32 attempt_number,
|
| #elif defined(OS_WIN)
|
| // Map the error code to a human-readable string.
|
| LPWSTR error_string = NULL;
|
| - int size = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
| - FORMAT_MESSAGE_FROM_SYSTEM,
|
| - 0, // Use the internal message table.
|
| - os_error,
|
| - 0, // Use default language.
|
| - (LPWSTR)&error_string,
|
| - 0, // Buffer size.
|
| - 0); // Arguments (unused).
|
| + int size = FormatMessage(
|
| + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
| + 0, // Use the internal message table.
|
| + os_error,
|
| + 0, // Use default language.
|
| + (LPWSTR) & error_string,
|
| + 0, // Buffer size.
|
| + 0); // Arguments (unused).
|
| dict->SetString("os_error_string", base::WideToUTF8(error_string));
|
| LocalFree(error_string);
|
| #endif
|
| @@ -335,8 +353,7 @@ base::Value* NetLogRequestInfoCallback(const NetLog::Source& source,
|
| source.AddToEventParameters(dict);
|
|
|
| dict->SetString("host", info->host_port_pair().ToString());
|
| - dict->SetInteger("address_family",
|
| - static_cast<int>(info->address_family()));
|
| + dict->SetInteger("address_family", static_cast<int>(info->address_family()));
|
| dict->SetBoolean("allow_cached_response", info->allow_cached_response());
|
| dict->SetBoolean("is_speculative", info->is_speculative());
|
| return dict;
|
| @@ -413,13 +430,9 @@ class PriorityTracker {
|
| memset(counts_, 0, sizeof(counts_));
|
| }
|
|
|
| - RequestPriority highest_priority() const {
|
| - return highest_priority_;
|
| - }
|
| + RequestPriority highest_priority() const { return highest_priority_; }
|
|
|
| - size_t total_count() const {
|
| - return total_count_;
|
| - }
|
| + size_t total_count() const { return total_count_; }
|
|
|
| void Add(RequestPriority req_priority) {
|
| ++total_count_;
|
| @@ -434,7 +447,8 @@ class PriorityTracker {
|
| --total_count_;
|
| --counts_[req_priority];
|
| size_t i;
|
| - for (i = highest_priority_; i > MINIMUM_PRIORITY && !counts_[i]; --i);
|
| + for (i = highest_priority_; i > MINIMUM_PRIORITY && !counts_[i]; --i)
|
| + ;
|
| highest_priority_ = static_cast<RequestPriority>(i);
|
|
|
| // In absence of requests, default to MINIMUM_PRIORITY.
|
| @@ -481,9 +495,7 @@ class HostResolverImpl::Request {
|
| callback_.Reset();
|
| }
|
|
|
| - bool was_canceled() const {
|
| - return callback_.is_null();
|
| - }
|
| + bool was_canceled() const { return callback_.is_null(); }
|
|
|
| void set_job(Job* job) {
|
| DCHECK(job);
|
| @@ -501,23 +513,15 @@ class HostResolverImpl::Request {
|
| callback.Run(error);
|
| }
|
|
|
| - Job* job() const {
|
| - return job_;
|
| - }
|
| + Job* job() const { return job_; }
|
|
|
| // NetLog for the source, passed in HostResolver::Resolve.
|
| - const BoundNetLog& source_net_log() {
|
| - return source_net_log_;
|
| - }
|
| + const BoundNetLog& source_net_log() { return source_net_log_; }
|
|
|
| // NetLog for this request.
|
| - const BoundNetLog& request_net_log() {
|
| - return request_net_log_;
|
| - }
|
| + const BoundNetLog& request_net_log() { return request_net_log_; }
|
|
|
| - const RequestInfo& info() const {
|
| - return info_;
|
| - }
|
| + const RequestInfo& info() const { return info_; }
|
|
|
| RequestPriority priority() const { return priority_; }
|
|
|
| @@ -562,8 +566,8 @@ class HostResolverImpl::Request {
|
| class HostResolverImpl::ProcTask
|
| : public base::RefCountedThreadSafe<HostResolverImpl::ProcTask> {
|
| public:
|
| - typedef base::Callback<void(int net_error,
|
| - const AddressList& addr_list)> Callback;
|
| + typedef base::Callback<void(int net_error, const AddressList& addr_list)>
|
| + Callback;
|
|
|
| ProcTask(const Key& key,
|
| const ProcTaskParams& params,
|
| @@ -637,10 +641,14 @@ class HostResolverImpl::ProcTask
|
| // Since we could be running within Resolve() right now, we can't just
|
| // call OnLookupComplete(). Instead we must wait until Resolve() has
|
| // returned (IO_PENDING).
|
| - origin_loop_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&ProcTask::OnLookupComplete, this, AddressList(),
|
| - start_time, attempt_number_, ERR_UNEXPECTED, 0));
|
| + origin_loop_->PostTask(FROM_HERE,
|
| + base::Bind(&ProcTask::OnLookupComplete,
|
| + this,
|
| + AddressList(),
|
| + start_time,
|
| + attempt_number_,
|
| + ERR_UNEXPECTED,
|
| + 0));
|
| return;
|
| }
|
|
|
| @@ -675,10 +683,14 @@ class HostResolverImpl::ProcTask
|
| &results,
|
| &os_error);
|
|
|
| - origin_loop_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&ProcTask::OnLookupComplete, this, results, start_time,
|
| - attempt_number, error, os_error));
|
| + origin_loop_->PostTask(FROM_HERE,
|
| + base::Bind(&ProcTask::OnLookupComplete,
|
| + this,
|
| + results,
|
| + start_time,
|
| + attempt_number,
|
| + error,
|
| + os_error));
|
| }
|
|
|
| // Makes next attempt if DoLookup() has not finished (runs on origin thread).
|
| @@ -725,13 +737,11 @@ class HostResolverImpl::ProcTask
|
|
|
| NetLog::ParametersCallback net_log_callback;
|
| if (error != OK) {
|
| - net_log_callback = base::Bind(&NetLogProcTaskFailedCallback,
|
| - attempt_number,
|
| - error,
|
| - os_error);
|
| + net_log_callback = base::Bind(
|
| + &NetLogProcTaskFailedCallback, attempt_number, error, os_error);
|
| } else {
|
| - net_log_callback = NetLog::IntegerCallback("attempt_number",
|
| - attempt_number);
|
| + net_log_callback =
|
| + NetLog::IntegerCallback("attempt_number", attempt_number);
|
| }
|
| net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_ATTEMPT_FINISHED,
|
| net_log_callback);
|
| @@ -751,8 +761,8 @@ class HostResolverImpl::ProcTask
|
| }
|
|
|
| if (error != OK) {
|
| - net_log_callback = base::Bind(&NetLogProcTaskFailedCallback,
|
| - 0, error, os_error);
|
| + net_log_callback =
|
| + base::Bind(&NetLogProcTaskFailedCallback, 0, error, os_error);
|
| } else {
|
| net_log_callback = results_.CreateNetLogCallback();
|
| }
|
| @@ -787,7 +797,7 @@ class HostResolverImpl::ProcTask
|
|
|
| // Log DNS lookups based on |address_family|. This will help us determine
|
| // if IPv4 or IPv4/6 lookups are faster or slower.
|
| - switch(key_.address_family) {
|
| + switch (key_.address_family) {
|
| case ADDRESS_FAMILY_IPV4:
|
| DNS_HISTOGRAM("DNS.ResolveSuccess_FAMILY_IPV4", duration);
|
| break;
|
| @@ -808,7 +818,7 @@ class HostResolverImpl::ProcTask
|
| }
|
| // Log DNS lookups based on |address_family|. This will help us determine
|
| // if IPv4 or IPv4/6 lookups are faster or slower.
|
| - switch(key_.address_family) {
|
| + switch (key_.address_family) {
|
| case ADDRESS_FAMILY_IPV4:
|
| DNS_HISTOGRAM("DNS.ResolveFail_FAMILY_IPV4", duration);
|
| break;
|
| @@ -929,8 +939,7 @@ class HostResolverImpl::ProcTask
|
| class HostResolverImpl::LoopbackProbeJob {
|
| public:
|
| explicit LoopbackProbeJob(const base::WeakPtr<HostResolverImpl>& resolver)
|
| - : resolver_(resolver),
|
| - result_(false) {
|
| + : resolver_(resolver), result_(false) {
|
| DCHECK(resolver.get());
|
| const bool kIsSlow = true;
|
| base::WorkerPool::PostTaskAndReply(
|
| @@ -944,9 +953,7 @@ class HostResolverImpl::LoopbackProbeJob {
|
|
|
| private:
|
| // Runs on worker thread.
|
| - void DoProbe() {
|
| - result_ = HaveOnlyLoopbackAddresses();
|
| - }
|
| + void DoProbe() { result_ = HaveOnlyLoopbackAddresses(); }
|
|
|
| void OnProbeComplete() {
|
| if (!resolver_.get())
|
| @@ -1041,9 +1048,10 @@ class HostResolverImpl::DnsTask : public base::SupportsWeakPtr<DnsTask> {
|
| DCHECK_NE(ADDRESS_FAMILY_UNSPECIFIED, family);
|
| return client_->GetTransactionFactory()->CreateTransaction(
|
| key_.hostname,
|
| - family == ADDRESS_FAMILY_IPV6 ? dns_protocol::kTypeAAAA :
|
| - dns_protocol::kTypeA,
|
| - base::Bind(&DnsTask::OnTransactionComplete, base::Unretained(this),
|
| + family == ADDRESS_FAMILY_IPV6 ? dns_protocol::kTypeAAAA
|
| + : dns_protocol::kTypeA,
|
| + base::Bind(&DnsTask::OnTransactionComplete,
|
| + base::Unretained(this),
|
| base::TimeTicks::Now()),
|
| net_log_);
|
| }
|
| @@ -1120,9 +1128,8 @@ class HostResolverImpl::DnsTask : public base::SupportsWeakPtr<DnsTask> {
|
| // Sort addresses if needed. Sort could complete synchronously.
|
| client_->GetAddressSorter()->Sort(
|
| addr_list_,
|
| - base::Bind(&DnsTask::OnSortComplete,
|
| - AsWeakPtr(),
|
| - base::TimeTicks::Now()));
|
| + base::Bind(
|
| + &DnsTask::OnSortComplete, AsWeakPtr(), base::TimeTicks::Now()));
|
| } else {
|
| OnSuccess(addr_list_);
|
| }
|
| @@ -1138,8 +1145,7 @@ class HostResolverImpl::DnsTask : public base::SupportsWeakPtr<DnsTask> {
|
| return;
|
| }
|
|
|
| - DNS_HISTOGRAM("AsyncDNS.SortSuccess",
|
| - base::TimeTicks::Now() - start_time);
|
| + DNS_HISTOGRAM("AsyncDNS.SortSuccess", base::TimeTicks::Now() - start_time);
|
|
|
| // AddressSorter prunes unusable destinations.
|
| if (addr_list.empty()) {
|
| @@ -1156,8 +1162,8 @@ class HostResolverImpl::DnsTask : public base::SupportsWeakPtr<DnsTask> {
|
| net_log_.EndEvent(
|
| NetLog::TYPE_HOST_RESOLVER_IMPL_DNS_TASK,
|
| base::Bind(&NetLogDnsTaskFailedCallback, net_error, result));
|
| - delegate_->OnDnsTaskComplete(task_start_time_, net_error, AddressList(),
|
| - base::TimeDelta());
|
| + delegate_->OnDnsTaskComplete(
|
| + task_start_time_, net_error, AddressList(), base::TimeDelta());
|
| }
|
|
|
| void OnSuccess(const AddressList& addr_list) {
|
| @@ -1213,11 +1219,10 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB)) {
|
| request_net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_CREATE_JOB);
|
|
|
| - net_log_.BeginEvent(
|
| - NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
|
| - base::Bind(&NetLogJobCreationCallback,
|
| - request_net_log.source(),
|
| - &key_.hostname));
|
| + net_log_.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
|
| + base::Bind(&NetLogJobCreationCallback,
|
| + request_net_log.source(),
|
| + &key_.hostname));
|
| }
|
|
|
| virtual ~Job() {
|
| @@ -1242,13 +1247,14 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
|
|
| // Log any remaining Requests as cancelled.
|
| for (RequestsList::const_iterator it = requests_.begin();
|
| - it != requests_.end(); ++it) {
|
| + it != requests_.end();
|
| + ++it) {
|
| Request* req = *it;
|
| if (req->was_canceled())
|
| continue;
|
| DCHECK_EQ(this, req->job());
|
| - LogCancelRequest(req->source_net_log(), req->request_net_log(),
|
| - req->info());
|
| + LogCancelRequest(
|
| + req->source_net_log(), req->request_net_log(), req->info());
|
| }
|
| }
|
|
|
| @@ -1281,11 +1287,10 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH,
|
| net_log_.source().ToEventParametersCallback());
|
|
|
| - net_log_.AddEvent(
|
| - NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_ATTACH,
|
| - base::Bind(&NetLogJobAttachCallback,
|
| - req->request_net_log().source(),
|
| - priority()));
|
| + net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_ATTACH,
|
| + base::Bind(&NetLogJobAttachCallback,
|
| + req->request_net_log().source(),
|
| + priority()));
|
|
|
| // TODO(szym): Check if this is still needed.
|
| if (!req->info().is_speculative()) {
|
| @@ -1307,8 +1312,8 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
|
|
| // Don't remove it from |requests_| just mark it canceled.
|
| req->MarkAsCanceled();
|
| - LogCancelRequest(req->source_net_log(), req->request_net_log(),
|
| - req->info());
|
| + LogCancelRequest(
|
| + req->source_net_log(), req->request_net_log(), req->info());
|
|
|
| priority_tracker_.Remove(req->priority());
|
| net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_DETACH,
|
| @@ -1360,9 +1365,8 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| bool ServeFromHosts() {
|
| DCHECK_GT(num_active_requests(), 0u);
|
| AddressList addr_list;
|
| - if (resolver_->ServeFromHosts(key(),
|
| - requests_.front()->info(),
|
| - &addr_list)) {
|
| + if (resolver_->ServeFromHosts(
|
| + key(), requests_.front()->info(), &addr_list)) {
|
| // This will destroy the Job.
|
| CompleteRequests(
|
| HostCache::Entry(OK, MakeAddressListForRequest(addr_list)),
|
| @@ -1372,17 +1376,11 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| return false;
|
| }
|
|
|
| - const Key key() const {
|
| - return key_;
|
| - }
|
| + const Key key() const { return key_; }
|
|
|
| - bool is_queued() const {
|
| - return !handle_.is_null();
|
| - }
|
| + bool is_queued() const { return !handle_.is_null(); }
|
|
|
| - bool is_running() const {
|
| - return is_dns_running() || is_proc_running();
|
| - }
|
| + bool is_running() const { return is_dns_running() || is_proc_running(); }
|
|
|
| private:
|
| void KillDnsTask() {
|
| @@ -1445,14 +1443,15 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| base::TimeDelta queue_time_after_change = now - priority_change_time_;
|
|
|
| if (had_dns_config_) {
|
| - DNS_HISTOGRAM_BY_PRIORITY("AsyncDNS.JobQueueTime", priority(),
|
| - queue_time);
|
| - DNS_HISTOGRAM_BY_PRIORITY("AsyncDNS.JobQueueTimeAfterChange", priority(),
|
| + DNS_HISTOGRAM_BY_PRIORITY(
|
| + "AsyncDNS.JobQueueTime", priority(), queue_time);
|
| + DNS_HISTOGRAM_BY_PRIORITY("AsyncDNS.JobQueueTimeAfterChange",
|
| + priority(),
|
| queue_time_after_change);
|
| } else {
|
| DNS_HISTOGRAM_BY_PRIORITY("DNS.JobQueueTime", priority(), queue_time);
|
| - DNS_HISTOGRAM_BY_PRIORITY("DNS.JobQueueTimeAfterChange", priority(),
|
| - queue_time_after_change);
|
| + DNS_HISTOGRAM_BY_PRIORITY(
|
| + "DNS.JobQueueTimeAfterChange", priority(), queue_time_after_change);
|
| }
|
|
|
| bool system_only =
|
| @@ -1473,12 +1472,12 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| // tighter limits.
|
| void StartProcTask() {
|
| DCHECK(!is_dns_running());
|
| - proc_task_ = new ProcTask(
|
| - key_,
|
| - resolver_->proc_params_,
|
| - base::Bind(&Job::OnProcTaskComplete, base::Unretained(this),
|
| - base::TimeTicks::Now()),
|
| - net_log_);
|
| + proc_task_ = new ProcTask(key_,
|
| + resolver_->proc_params_,
|
| + base::Bind(&Job::OnProcTaskComplete,
|
| + base::Unretained(this),
|
| + base::TimeTicks::Now()),
|
| + net_log_);
|
|
|
| if (had_non_speculative_request_)
|
| proc_task_->set_had_non_speculative_request();
|
| @@ -1493,8 +1492,7 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| const AddressList& addr_list) {
|
| DCHECK(is_proc_running());
|
|
|
| - if (!resolver_->resolved_known_ipv6_hostname_ &&
|
| - net_error == OK &&
|
| + if (!resolver_->resolved_known_ipv6_hostname_ && net_error == OK &&
|
| key_.address_family == ADDRESS_FAMILY_UNSPECIFIED) {
|
| if (key_.hostname == "www.google.com") {
|
| resolver_->resolved_known_ipv6_hostname_ = true;
|
| @@ -1536,14 +1534,13 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
|
|
| // Don't store the |ttl| in cache since it's not obtained from the server.
|
| CompleteRequests(
|
| - HostCache::Entry(net_error, MakeAddressListForRequest(addr_list)),
|
| - ttl);
|
| + HostCache::Entry(net_error, MakeAddressListForRequest(addr_list)), ttl);
|
| }
|
|
|
| void StartDnsTask() {
|
| DCHECK(resolver_->HaveDnsConfig());
|
| - dns_task_.reset(new DnsTask(resolver_->dns_client_.get(), key_, this,
|
| - net_log_));
|
| + dns_task_.reset(
|
| + new DnsTask(resolver_->dns_client_.get(), key_, this, net_log_));
|
|
|
| dns_task_->StartFirstTransaction();
|
| // Schedule a second transaction, if needed.
|
| @@ -1583,7 +1580,6 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| }
|
| }
|
|
|
| -
|
| // HostResolverImpl::DnsTask::Delegate implementation:
|
|
|
| virtual void OnDnsTaskComplete(base::TimeTicks start_time,
|
| @@ -1599,7 +1595,7 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| }
|
| DNS_HISTOGRAM("AsyncDNS.ResolveSuccess", duration);
|
| // Log DNS lookups based on |address_family|.
|
| - switch(key_.address_family) {
|
| + switch (key_.address_family) {
|
| case ADDRESS_FAMILY_IPV4:
|
| DNS_HISTOGRAM("AsyncDNS.ResolveSuccess_FAMILY_IPV4", duration);
|
| break;
|
| @@ -1638,8 +1634,7 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| }
|
|
|
| // Performs Job's last rites. Completes all Requests. Deletes this.
|
| - void CompleteRequests(const HostCache::Entry& entry,
|
| - base::TimeDelta ttl) {
|
| + void CompleteRequests(const HostCache::Entry& entry, base::TimeDelta ttl) {
|
| CHECK(resolver_.get());
|
|
|
| // This job must be removed from resolver's |jobs_| now to make room for a
|
| @@ -1691,7 +1686,8 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
|
|
| // Complete all of the requests that were attached to the job.
|
| for (RequestsList::const_iterator it = requests_.begin();
|
| - it != requests_.end(); ++it) {
|
| + it != requests_.end();
|
| + ++it) {
|
| Request* req = *it;
|
|
|
| if (req->was_canceled())
|
| @@ -1699,11 +1695,14 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
|
|
| DCHECK_EQ(this, req->job());
|
| // Update the net log and notify registered observers.
|
| - LogFinishRequest(req->source_net_log(), req->request_net_log(),
|
| - req->info(), entry.error);
|
| + LogFinishRequest(req->source_net_log(),
|
| + req->request_net_log(),
|
| + req->info(),
|
| + entry.error);
|
| if (did_complete) {
|
| // Record effective total time from creation to completion.
|
| - RecordTotalTime(had_dns_config_, req->info().is_speculative(),
|
| + RecordTotalTime(had_dns_config_,
|
| + req->info().is_speculative(),
|
| base::TimeTicks::Now() - req->request_time());
|
| }
|
| req->OnComplete(entry.error, entry.addrlist);
|
| @@ -1726,17 +1725,11 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
|
| }
|
|
|
| // Number of non-canceled requests in |requests_|.
|
| - size_t num_active_requests() const {
|
| - return priority_tracker_.total_count();
|
| - }
|
| + size_t num_active_requests() const { return priority_tracker_.total_count(); }
|
|
|
| - bool is_dns_running() const {
|
| - return dns_task_.get() != NULL;
|
| - }
|
| + bool is_dns_running() const { return dns_task_.get() != NULL; }
|
|
|
| - bool is_proc_running() const {
|
| - return proc_task_.get() != NULL;
|
| - }
|
| + bool is_proc_running() const { return proc_task_.get() != NULL; }
|
|
|
| base::WeakPtr<HostResolverImpl> resolver_;
|
|
|
| @@ -1785,7 +1778,8 @@ HostResolverImpl::ProcTaskParams::ProcTaskParams(
|
| retry_factor(2) {
|
| }
|
|
|
| -HostResolverImpl::ProcTaskParams::~ProcTaskParams() {}
|
| +HostResolverImpl::ProcTaskParams::~ProcTaskParams() {
|
| +}
|
|
|
| HostResolverImpl::HostResolverImpl(
|
| scoped_ptr<HostCache> cache,
|
| @@ -1807,7 +1801,6 @@ HostResolverImpl::HostResolverImpl(
|
| resolved_known_ipv6_hostname_(false),
|
| additional_resolver_flags_(0),
|
| fallback_to_proctask_(true) {
|
| -
|
| DCHECK_GE(dispatcher_.num_priorities(), static_cast<size_t>(NUM_PRIORITIES));
|
|
|
| // Maximum of 4 retry attempts for host resolution.
|
| @@ -1873,8 +1866,8 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
|
| return ERR_NAME_NOT_RESOLVED;
|
|
|
| // Make a log item for the request.
|
| - BoundNetLog request_net_log = BoundNetLog::Make(net_log_,
|
| - NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST);
|
| + BoundNetLog request_net_log =
|
| + BoundNetLog::Make(net_log_, NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST);
|
|
|
| LogStartRequest(source_net_log, request_net_log, info);
|
|
|
| @@ -1959,8 +1952,8 @@ int HostResolverImpl::ResolveFromCache(const RequestInfo& info,
|
| DCHECK(addresses);
|
|
|
| // Make a log item for the request.
|
| - BoundNetLog request_net_log = BoundNetLog::Make(net_log_,
|
| - NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST);
|
| + BoundNetLog request_net_log =
|
| + BoundNetLog::Make(net_log_, NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST);
|
|
|
| // Update the net log and notify registered observers.
|
| LogStartRequest(source_net_log, request_net_log, info);
|
| @@ -2031,11 +2024,12 @@ bool HostResolverImpl::ResolveAsIP(const Key& key,
|
| return false;
|
|
|
| DCHECK_EQ(key.host_resolver_flags &
|
| - ~(HOST_RESOLVER_CANONNAME | HOST_RESOLVER_LOOPBACK_ONLY |
|
| - HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6),
|
| - 0) << " Unhandled flag";
|
| - bool ipv6_disabled = (default_address_family_ == ADDRESS_FAMILY_IPV4) &&
|
| - !probe_ipv6_support_;
|
| + ~(HOST_RESOLVER_CANONNAME | HOST_RESOLVER_LOOPBACK_ONLY |
|
| + HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6),
|
| + 0)
|
| + << " Unhandled flag";
|
| + bool ipv6_disabled =
|
| + (default_address_family_ == ADDRESS_FAMILY_IPV4) && !probe_ipv6_support_;
|
| *net_error = OK;
|
| if ((ip_number.size() == kIPv6AddressSize) && ipv6_disabled) {
|
| *net_error = ERR_NAME_NOT_RESOLVED;
|
| @@ -2056,8 +2050,8 @@ bool HostResolverImpl::ServeFromCache(const Key& key,
|
| if (!info.allow_cached_response() || !cache_.get())
|
| return false;
|
|
|
| - const HostCache::Entry* cache_entry = cache_->Lookup(
|
| - key, base::TimeTicks::Now());
|
| + const HostCache::Entry* cache_entry =
|
| + cache_->Lookup(key, base::TimeTicks::Now());
|
| if (!cache_entry)
|
| return false;
|
|
|
| @@ -2090,16 +2084,16 @@ bool HostResolverImpl::ServeFromHosts(const Key& key,
|
| // necessary.
|
| if (key.address_family == ADDRESS_FAMILY_IPV6 ||
|
| key.address_family == ADDRESS_FAMILY_UNSPECIFIED) {
|
| - DnsHosts::const_iterator it = hosts.find(
|
| - DnsHostsKey(hostname, ADDRESS_FAMILY_IPV6));
|
| + DnsHosts::const_iterator it =
|
| + hosts.find(DnsHostsKey(hostname, ADDRESS_FAMILY_IPV6));
|
| if (it != hosts.end())
|
| addresses->push_back(IPEndPoint(it->second, info.port()));
|
| }
|
|
|
| if (key.address_family == ADDRESS_FAMILY_IPV4 ||
|
| key.address_family == ADDRESS_FAMILY_UNSPECIFIED) {
|
| - DnsHosts::const_iterator it = hosts.find(
|
| - DnsHostsKey(hostname, ADDRESS_FAMILY_IPV4));
|
| + DnsHosts::const_iterator it =
|
| + hosts.find(DnsHostsKey(hostname, ADDRESS_FAMILY_IPV4));
|
| if (it != hosts.end())
|
| addresses->push_back(IPEndPoint(it->second, info.port()));
|
| }
|
| @@ -2107,7 +2101,7 @@ bool HostResolverImpl::ServeFromHosts(const Key& key,
|
| // If got only loopback addresses and the family was restricted, resolve
|
| // again, without restrictions. See SystemHostResolverCall for rationale.
|
| if ((key.host_resolver_flags &
|
| - HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6) &&
|
| + HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6) &&
|
| IsAllIPv4Loopback(*addresses)) {
|
| Key new_key(key);
|
| new_key.address_family = ADDRESS_FAMILY_UNSPECIFIED;
|
| @@ -2141,7 +2135,8 @@ void HostResolverImpl::SetHaveOnlyLoopbackAddresses(bool result) {
|
| }
|
|
|
| HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest(
|
| - const RequestInfo& info, const BoundNetLog& net_log) const {
|
| + const RequestInfo& info,
|
| + const BoundNetLog& net_log) const {
|
| HostResolverFlags effective_flags =
|
| info.host_resolver_flags() | additional_resolver_flags_;
|
| AddressFamily effective_address_family = info.address_family();
|
| @@ -2150,9 +2145,9 @@ HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest(
|
| if (probe_ipv6_support_ && !use_local_ipv6_) {
|
| base::TimeTicks start_time = base::TimeTicks::Now();
|
| // Google DNS address.
|
| - const uint8 kIPv6Address[] =
|
| - { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00,
|
| - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 };
|
| + const uint8 kIPv6Address[] = {0x20, 0x01, 0x48, 0x60, 0x48, 0x60,
|
| + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
| + 0x00, 0x00, 0x88, 0x88};
|
| IPAddressNumber address(kIPv6Address,
|
| kIPv6Address + arraysize(kIPv6Address));
|
| BoundNetLog probe_net_log = BoundNetLog::Make(
|
| @@ -2167,10 +2162,12 @@ HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest(
|
| UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration",
|
| base::TimeTicks::Now() - start_time);
|
| if (rv6) {
|
| - UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch",
|
| + UMA_HISTOGRAM_BOOLEAN(
|
| + "Net.IPv6ConnectSuccessMatch",
|
| default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED);
|
| } else {
|
| - UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectFailureMatch",
|
| + UMA_HISTOGRAM_BOOLEAN(
|
| + "Net.IPv6ConnectFailureMatch",
|
| default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED);
|
|
|
| effective_address_family = ADDRESS_FAMILY_IPV4;
|
| @@ -2188,7 +2185,7 @@ void HostResolverImpl::AbortAllInProgressJobs() {
|
| // In Abort, a Request callback could spawn new Jobs with matching keys, so
|
| // first collect and remove all running jobs from |jobs_|.
|
| ScopedVector<Job> jobs_to_abort;
|
| - for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ) {
|
| + for (JobMap::iterator it = jobs_.begin(); it != jobs_.end();) {
|
| Job* job = it->second;
|
| if (job->is_running()) {
|
| jobs_to_abort.push_back(job);
|
| @@ -2269,9 +2266,8 @@ void HostResolverImpl::OnDNSChanged() {
|
| NetworkChangeNotifier::GetDnsConfig(&dns_config);
|
|
|
| if (net_log_) {
|
| - net_log_->AddGlobalEntry(
|
| - NetLog::TYPE_DNS_CONFIG_CHANGED,
|
| - base::Bind(&NetLogDnsConfigCallback, &dns_config));
|
| + net_log_->AddGlobalEntry(NetLog::TYPE_DNS_CONFIG_CHANGED,
|
| + base::Bind(&NetLogDnsConfigCallback, &dns_config));
|
| }
|
|
|
| // TODO(szym): Remove once http://crbug.com/137914 is resolved.
|
|
|