Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: net/dns/host_resolver_impl.cc

Issue 1135373002: Updated NetLog::ParametersCallback & all related calbacks returning value as scoped_ptr<base::Value… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/host_resolver_impl.h ('k') | net/dns/mapped_host_resolver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/dns/host_resolver_impl.h" 5 #include "net/dns/host_resolver_impl.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <Winsock2.h> 8 #include <Winsock2.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <netdb.h> 10 #include <netdb.h>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 return false; 295 return false;
296 default: 296 default:
297 NOTREACHED(); 297 NOTREACHED();
298 return false; 298 return false;
299 } 299 }
300 } 300 }
301 return true; 301 return true;
302 } 302 }
303 303
304 // Creates NetLog parameters when the resolve failed. 304 // Creates NetLog parameters when the resolve failed.
305 base::Value* NetLogProcTaskFailedCallback( 305 scoped_ptr<base::Value> NetLogProcTaskFailedCallback(
306 uint32 attempt_number, 306 uint32 attempt_number,
307 int net_error, 307 int net_error,
308 int os_error, 308 int os_error,
309 NetLogCaptureMode /* capture_mode */) { 309 NetLogCaptureMode /* capture_mode */) {
310 base::DictionaryValue* dict = new base::DictionaryValue(); 310 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
311 if (attempt_number) 311 if (attempt_number)
312 dict->SetInteger("attempt_number", attempt_number); 312 dict->SetInteger("attempt_number", attempt_number);
313 313
314 dict->SetInteger("net_error", net_error); 314 dict->SetInteger("net_error", net_error);
315 315
316 if (os_error) { 316 if (os_error) {
317 dict->SetInteger("os_error", os_error); 317 dict->SetInteger("os_error", os_error);
318 #if defined(OS_POSIX) 318 #if defined(OS_POSIX)
319 dict->SetString("os_error_string", gai_strerror(os_error)); 319 dict->SetString("os_error_string", gai_strerror(os_error));
320 #elif defined(OS_WIN) 320 #elif defined(OS_WIN)
321 // Map the error code to a human-readable string. 321 // Map the error code to a human-readable string.
322 LPWSTR error_string = NULL; 322 LPWSTR error_string = NULL;
323 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 323 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
324 0, // Use the internal message table. 324 0, // Use the internal message table.
325 os_error, 325 os_error,
326 0, // Use default language. 326 0, // Use default language.
327 (LPWSTR)&error_string, 327 (LPWSTR)&error_string,
328 0, // Buffer size. 328 0, // Buffer size.
329 0); // Arguments (unused). 329 0); // Arguments (unused).
330 dict->SetString("os_error_string", base::WideToUTF8(error_string)); 330 dict->SetString("os_error_string", base::WideToUTF8(error_string));
331 LocalFree(error_string); 331 LocalFree(error_string);
332 #endif 332 #endif
333 } 333 }
334 334
335 return dict; 335 return dict.Pass();
336 } 336 }
337 337
338 // Creates NetLog parameters when the DnsTask failed. 338 // Creates NetLog parameters when the DnsTask failed.
339 base::Value* NetLogDnsTaskFailedCallback(int net_error, 339 scoped_ptr<base::Value> NetLogDnsTaskFailedCallback(
340 int dns_error, 340 int net_error,
341 NetLogCaptureMode /* capture_mode */) { 341 int dns_error,
342 base::DictionaryValue* dict = new base::DictionaryValue(); 342 NetLogCaptureMode /* capture_mode */) {
343 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
343 dict->SetInteger("net_error", net_error); 344 dict->SetInteger("net_error", net_error);
344 if (dns_error) 345 if (dns_error)
345 dict->SetInteger("dns_error", dns_error); 346 dict->SetInteger("dns_error", dns_error);
346 return dict; 347 return dict.Pass();
347 }; 348 };
348 349
349 // Creates NetLog parameters containing the information in a RequestInfo object, 350 // Creates NetLog parameters containing the information in a RequestInfo object,
350 // along with the associated NetLog::Source. 351 // along with the associated NetLog::Source.
351 base::Value* NetLogRequestInfoCallback(const HostResolver::RequestInfo* info, 352 scoped_ptr<base::Value> NetLogRequestInfoCallback(
352 NetLogCaptureMode /* capture_mode */) { 353 const HostResolver::RequestInfo* info,
353 base::DictionaryValue* dict = new base::DictionaryValue(); 354 NetLogCaptureMode /* capture_mode */) {
355 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
354 356
355 dict->SetString("host", info->host_port_pair().ToString()); 357 dict->SetString("host", info->host_port_pair().ToString());
356 dict->SetInteger("address_family", 358 dict->SetInteger("address_family",
357 static_cast<int>(info->address_family())); 359 static_cast<int>(info->address_family()));
358 dict->SetBoolean("allow_cached_response", info->allow_cached_response()); 360 dict->SetBoolean("allow_cached_response", info->allow_cached_response());
359 dict->SetBoolean("is_speculative", info->is_speculative()); 361 dict->SetBoolean("is_speculative", info->is_speculative());
360 return dict; 362 return dict.Pass();
361 } 363 }
362 364
363 // Creates NetLog parameters for the creation of a HostResolverImpl::Job. 365 // Creates NetLog parameters for the creation of a HostResolverImpl::Job.
364 base::Value* NetLogJobCreationCallback(const NetLog::Source& source, 366 scoped_ptr<base::Value> NetLogJobCreationCallback(
365 const std::string* host, 367 const NetLog::Source& source,
366 NetLogCaptureMode /* capture_mode */) { 368 const std::string* host,
367 base::DictionaryValue* dict = new base::DictionaryValue(); 369 NetLogCaptureMode /* capture_mode */) {
368 source.AddToEventParameters(dict); 370 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
371 source.AddToEventParameters(dict.release());
369 dict->SetString("host", *host); 372 dict->SetString("host", *host);
370 return dict; 373 return dict.Pass();
371 } 374 }
372 375
373 // Creates NetLog parameters for HOST_RESOLVER_IMPL_JOB_ATTACH/DETACH events. 376 // Creates NetLog parameters for HOST_RESOLVER_IMPL_JOB_ATTACH/DETACH events.
374 base::Value* NetLogJobAttachCallback(const NetLog::Source& source, 377 scoped_ptr<base::Value> NetLogJobAttachCallback(
375 RequestPriority priority, 378 const NetLog::Source& source,
376 NetLogCaptureMode /* capture_mode */) { 379 RequestPriority priority,
377 base::DictionaryValue* dict = new base::DictionaryValue(); 380 NetLogCaptureMode /* capture_mode */) {
378 source.AddToEventParameters(dict); 381 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
382 source.AddToEventParameters(dict.release());
379 dict->SetString("priority", RequestPriorityToString(priority)); 383 dict->SetString("priority", RequestPriorityToString(priority));
380 return dict; 384 return dict.Pass();
381 } 385 }
382 386
383 // Creates NetLog parameters for the DNS_CONFIG_CHANGED event. 387 // Creates NetLog parameters for the DNS_CONFIG_CHANGED event.
384 base::Value* NetLogDnsConfigCallback(const DnsConfig* config, 388 scoped_ptr<base::Value> NetLogDnsConfigCallback(
385 NetLogCaptureMode /* capture_mode */) { 389 const DnsConfig* config,
390 NetLogCaptureMode /* capture_mode */) {
386 return config->ToValue(); 391 return config->ToValue();
387 } 392 }
388 393
389 // The logging routines are defined here because some requests are resolved 394 // The logging routines are defined here because some requests are resolved
390 // without a Request object. 395 // without a Request object.
391 396
392 // Logs when a request has just been started. 397 // Logs when a request has just been started.
393 void LogStartRequest(const BoundNetLog& source_net_log, 398 void LogStartRequest(const BoundNetLog& source_net_log,
394 const HostResolver::RequestInfo& info) { 399 const HostResolver::RequestInfo& info) {
395 source_net_log.BeginEvent( 400 source_net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST,
396 NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, 401 base::Bind(NetLogRequestInfoCallback, &info));
397 base::Bind(&NetLogRequestInfoCallback, &info));
398 } 402 }
399 403
400 // Logs when a request has just completed (before its callback is run). 404 // Logs when a request has just completed (before its callback is run).
401 void LogFinishRequest(const BoundNetLog& source_net_log, 405 void LogFinishRequest(const BoundNetLog& source_net_log,
402 const HostResolver::RequestInfo& info, 406 const HostResolver::RequestInfo& info,
403 int net_error) { 407 int net_error) {
404 source_net_log.EndEventWithNetErrorCode( 408 source_net_log.EndEventWithNetErrorCode(
405 NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, net_error); 409 NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, net_error);
406 } 410 }
407 411
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 if (!was_retry_attempt) 734 if (!was_retry_attempt)
731 RecordPerformanceHistograms(start_time, error, os_error); 735 RecordPerformanceHistograms(start_time, error, os_error);
732 736
733 RecordAttemptHistograms(start_time, attempt_number, error, os_error); 737 RecordAttemptHistograms(start_time, attempt_number, error, os_error);
734 738
735 if (was_canceled()) 739 if (was_canceled())
736 return; 740 return;
737 741
738 NetLog::ParametersCallback net_log_callback; 742 NetLog::ParametersCallback net_log_callback;
739 if (error != OK) { 743 if (error != OK) {
740 net_log_callback = base::Bind(&NetLogProcTaskFailedCallback, 744 net_log_callback = base::Bind(NetLogProcTaskFailedCallback,
741 attempt_number, 745 attempt_number, error, os_error);
742 error,
743 os_error);
744 } else { 746 } else {
745 net_log_callback = NetLog::IntegerCallback("attempt_number", 747 net_log_callback = NetLog::IntegerCallback("attempt_number",
746 attempt_number); 748 attempt_number);
747 } 749 }
748 net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_ATTEMPT_FINISHED, 750 net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_ATTEMPT_FINISHED,
749 net_log_callback); 751 net_log_callback);
750 752
751 if (was_completed()) 753 if (was_completed())
752 return; 754 return;
753 755
754 // Copy the results from the first worker thread that resolves the host. 756 // Copy the results from the first worker thread that resolves the host.
755 results_ = results; 757 results_ = results;
756 completed_attempt_number_ = attempt_number; 758 completed_attempt_number_ = attempt_number;
757 completed_attempt_error_ = error; 759 completed_attempt_error_ = error;
758 760
759 if (was_retry_attempt) { 761 if (was_retry_attempt) {
760 // If retry attempt finishes before 1st attempt, then get stats on how 762 // If retry attempt finishes before 1st attempt, then get stats on how
761 // much time is saved by having spawned an extra attempt. 763 // much time is saved by having spawned an extra attempt.
762 retry_attempt_finished_time_ = base::TimeTicks::Now(); 764 retry_attempt_finished_time_ = base::TimeTicks::Now();
763 } 765 }
764 766
765 if (error != OK) { 767 if (error != OK) {
766 net_log_callback = base::Bind(&NetLogProcTaskFailedCallback, 768 net_log_callback =
767 0, error, os_error); 769 base::Bind(NetLogProcTaskFailedCallback, 0, error, os_error);
768 } else { 770 } else {
769 net_log_callback = results_.CreateNetLogCallback(); 771 net_log_callback = results_.CreateNetLogCallback();
770 } 772 }
771 net_log_.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_PROC_TASK, 773 net_log_.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_PROC_TASK,
772 net_log_callback); 774 net_log_callback);
773 775
774 callback_.Run(error, results_); 776 callback_.Run(error, results_);
775 } 777 }
776 778
777 void RecordPerformanceHistograms(const base::TimeTicks& start_time, 779 void RecordPerformanceHistograms(const base::TimeTicks& start_time,
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 return; 1162 return;
1161 } 1163 }
1162 1164
1163 OnSuccess(addr_list); 1165 OnSuccess(addr_list);
1164 } 1166 }
1165 1167
1166 void OnFailure(int net_error, DnsResponse::Result result) { 1168 void OnFailure(int net_error, DnsResponse::Result result) {
1167 DCHECK_NE(OK, net_error); 1169 DCHECK_NE(OK, net_error);
1168 net_log_.EndEvent( 1170 net_log_.EndEvent(
1169 NetLog::TYPE_HOST_RESOLVER_IMPL_DNS_TASK, 1171 NetLog::TYPE_HOST_RESOLVER_IMPL_DNS_TASK,
1170 base::Bind(&NetLogDnsTaskFailedCallback, net_error, result)); 1172 base::Bind(NetLogDnsTaskFailedCallback, net_error, result));
1171 delegate_->OnDnsTaskComplete(task_start_time_, net_error, AddressList(), 1173 delegate_->OnDnsTaskComplete(task_start_time_, net_error, AddressList(),
1172 base::TimeDelta()); 1174 base::TimeDelta());
1173 } 1175 }
1174 1176
1175 void OnSuccess(const AddressList& addr_list) { 1177 void OnSuccess(const AddressList& addr_list) {
1176 net_log_.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_DNS_TASK, 1178 net_log_.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_DNS_TASK,
1177 addr_list.CreateNetLogCallback()); 1179 addr_list.CreateNetLogCallback());
1178 delegate_->OnDnsTaskComplete(task_start_time_, OK, addr_list, ttl_); 1180 delegate_->OnDnsTaskComplete(task_start_time_, OK, addr_list, ttl_);
1179 } 1181 }
1180 1182
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 had_non_speculative_request_(false), 1220 had_non_speculative_request_(false),
1219 had_dns_config_(false), 1221 had_dns_config_(false),
1220 num_occupied_job_slots_(0), 1222 num_occupied_job_slots_(0),
1221 dns_task_error_(OK), 1223 dns_task_error_(OK),
1222 creation_time_(base::TimeTicks::Now()), 1224 creation_time_(base::TimeTicks::Now()),
1223 priority_change_time_(creation_time_), 1225 priority_change_time_(creation_time_),
1224 net_log_(BoundNetLog::Make(source_net_log.net_log(), 1226 net_log_(BoundNetLog::Make(source_net_log.net_log(),
1225 NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB)) { 1227 NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB)) {
1226 source_net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_CREATE_JOB); 1228 source_net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_CREATE_JOB);
1227 1229
1228 net_log_.BeginEvent( 1230 net_log_.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
1229 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, 1231 base::Bind(NetLogJobCreationCallback,
1230 base::Bind(&NetLogJobCreationCallback, 1232 source_net_log.source(), &key_.hostname));
1231 source_net_log.source(),
1232 &key_.hostname));
1233 } 1233 }
1234 1234
1235 ~Job() override { 1235 ~Job() override {
1236 if (is_running()) { 1236 if (is_running()) {
1237 // |resolver_| was destroyed with this Job still in flight. 1237 // |resolver_| was destroyed with this Job still in flight.
1238 // Clean-up, record in the log, but don't run any callbacks. 1238 // Clean-up, record in the log, but don't run any callbacks.
1239 if (is_proc_running()) { 1239 if (is_proc_running()) {
1240 proc_task_->Cancel(); 1240 proc_task_->Cancel();
1241 proc_task_ = NULL; 1241 proc_task_ = NULL;
1242 } 1242 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 DCHECK_EQ(key_.hostname, req->info().hostname()); 1291 DCHECK_EQ(key_.hostname, req->info().hostname());
1292 } 1292 }
1293 1293
1294 req->set_job(this); 1294 req->set_job(this);
1295 priority_tracker_.Add(req->priority()); 1295 priority_tracker_.Add(req->priority());
1296 1296
1297 req->source_net_log().AddEvent( 1297 req->source_net_log().AddEvent(
1298 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH, 1298 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH,
1299 net_log_.source().ToEventParametersCallback()); 1299 net_log_.source().ToEventParametersCallback());
1300 1300
1301 net_log_.AddEvent( 1301 net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_ATTACH,
1302 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_ATTACH, 1302 base::Bind(NetLogJobAttachCallback,
1303 base::Bind(&NetLogJobAttachCallback, 1303 req->source_net_log().source(), priority()));
1304 req->source_net_log().source(),
1305 priority()));
1306 1304
1307 // TODO(szym): Check if this is still needed. 1305 // TODO(szym): Check if this is still needed.
1308 if (!req->info().is_speculative()) { 1306 if (!req->info().is_speculative()) {
1309 had_non_speculative_request_ = true; 1307 had_non_speculative_request_ = true;
1310 if (proc_task_.get()) 1308 if (proc_task_.get())
1311 proc_task_->set_had_non_speculative_request(); 1309 proc_task_->set_had_non_speculative_request();
1312 } 1310 }
1313 1311
1314 requests_.push_back(req.release()); 1312 requests_.push_back(req.release());
1315 1313
1316 UpdatePriority(); 1314 UpdatePriority();
1317 } 1315 }
1318 1316
1319 // Marks |req| as cancelled. If it was the last active Request, also finishes 1317 // Marks |req| as cancelled. If it was the last active Request, also finishes
1320 // this Job, marking it as cancelled, and deletes it. 1318 // this Job, marking it as cancelled, and deletes it.
1321 void CancelRequest(Request* req) { 1319 void CancelRequest(Request* req) {
1322 DCHECK_EQ(key_.hostname, req->info().hostname()); 1320 DCHECK_EQ(key_.hostname, req->info().hostname());
1323 DCHECK(!req->was_canceled()); 1321 DCHECK(!req->was_canceled());
1324 1322
1325 // Don't remove it from |requests_| just mark it canceled. 1323 // Don't remove it from |requests_| just mark it canceled.
1326 req->MarkAsCanceled(); 1324 req->MarkAsCanceled();
1327 LogCancelRequest(req->source_net_log(), req->info()); 1325 LogCancelRequest(req->source_net_log(), req->info());
1328 1326
1329 priority_tracker_.Remove(req->priority()); 1327 priority_tracker_.Remove(req->priority());
1330 net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_DETACH, 1328 net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_DETACH,
1331 base::Bind(&NetLogJobAttachCallback, 1329 base::Bind(NetLogJobAttachCallback,
1332 req->source_net_log().source(), 1330 req->source_net_log().source(), priority()));
1333 priority()));
1334 1331
1335 if (num_active_requests() > 0) { 1332 if (num_active_requests() > 0) {
1336 UpdatePriority(); 1333 UpdatePriority();
1337 } else { 1334 } else {
1338 // If we were called from a Request's callback within CompleteRequests, 1335 // If we were called from a Request's callback within CompleteRequests,
1339 // that Request could not have been cancelled, so num_active_requests() 1336 // that Request could not have been cancelled, so num_active_requests()
1340 // could not be 0. Therefore, we are not in CompleteRequests(). 1337 // could not be 0. Therefore, we are not in CompleteRequests().
1341 CompleteRequestsWithError(OK /* cancelled */); 1338 CompleteRequestsWithError(OK /* cancelled */);
1342 } 1339 }
1343 } 1340 }
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 } else if (!enabled && dns_client_) { 2012 } else if (!enabled && dns_client_) {
2016 SetDnsClient(scoped_ptr<DnsClient>()); 2013 SetDnsClient(scoped_ptr<DnsClient>());
2017 } 2014 }
2018 #endif 2015 #endif
2019 } 2016 }
2020 2017
2021 HostCache* HostResolverImpl::GetHostCache() { 2018 HostCache* HostResolverImpl::GetHostCache() {
2022 return cache_.get(); 2019 return cache_.get();
2023 } 2020 }
2024 2021
2025 base::Value* HostResolverImpl::GetDnsConfigAsValue() const { 2022 scoped_ptr<base::Value> HostResolverImpl::GetDnsConfigAsValue() const {
2026 // Check if async DNS is disabled. 2023 // Check if async DNS is disabled.
2027 if (!dns_client_.get()) 2024 if (!dns_client_.get())
2028 return NULL; 2025 return NULL;
2029 2026
2030 // Check if async DNS is enabled, but we currently have no configuration 2027 // Check if async DNS is enabled, but we currently have no configuration
2031 // for it. 2028 // for it.
2032 const DnsConfig* dns_config = dns_client_->GetConfig(); 2029 const DnsConfig* dns_config = dns_client_->GetConfig();
2033 if (dns_config == NULL) 2030 if (dns_config == NULL) {
2034 return new base::DictionaryValue(); 2031 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
2032 return dict.Pass();
2033 }
2035 2034
2036 return dns_config->ToValue(); 2035 return dns_config->ToValue();
2037 } 2036 }
2038 2037
2039 bool HostResolverImpl::ResolveAsIP(const Key& key, 2038 bool HostResolverImpl::ResolveAsIP(const Key& key,
2040 const RequestInfo& info, 2039 const RequestInfo& info,
2041 const IPAddressNumber* ip_number, 2040 const IPAddressNumber* ip_number,
2042 int* net_error, 2041 int* net_error,
2043 AddressList* addresses) { 2042 AddressList* addresses) {
2044 DCHECK(addresses); 2043 DCHECK(addresses);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 2295
2297 void HostResolverImpl::OnDNSChanged() { 2296 void HostResolverImpl::OnDNSChanged() {
2298 UpdateDNSConfig(true); 2297 UpdateDNSConfig(true);
2299 } 2298 }
2300 2299
2301 void HostResolverImpl::UpdateDNSConfig(bool config_changed) { 2300 void HostResolverImpl::UpdateDNSConfig(bool config_changed) {
2302 DnsConfig dns_config; 2301 DnsConfig dns_config;
2303 NetworkChangeNotifier::GetDnsConfig(&dns_config); 2302 NetworkChangeNotifier::GetDnsConfig(&dns_config);
2304 2303
2305 if (net_log_) { 2304 if (net_log_) {
2306 net_log_->AddGlobalEntry( 2305 net_log_->AddGlobalEntry(NetLog::TYPE_DNS_CONFIG_CHANGED,
2307 NetLog::TYPE_DNS_CONFIG_CHANGED, 2306 base::Bind(NetLogDnsConfigCallback, &dns_config));
2308 base::Bind(&NetLogDnsConfigCallback, &dns_config));
2309 } 2307 }
2310 2308
2311 // TODO(szym): Remove once http://crbug.com/137914 is resolved. 2309 // TODO(szym): Remove once http://crbug.com/137914 is resolved.
2312 received_dns_config_ = dns_config.IsValid(); 2310 received_dns_config_ = dns_config.IsValid();
2313 // Conservatively assume local IPv6 is needed when DnsConfig is not valid. 2311 // Conservatively assume local IPv6 is needed when DnsConfig is not valid.
2314 use_local_ipv6_ = !dns_config.IsValid() || dns_config.use_local_ipv6; 2312 use_local_ipv6_ = !dns_config.IsValid() || dns_config.use_local_ipv6;
2315 2313
2316 num_dns_failures_ = 0; 2314 num_dns_failures_ = 0;
2317 2315
2318 // We want a new DnsSession in place, before we Abort running Jobs, so that 2316 // We want a new DnsSession in place, before we Abort running Jobs, so that
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 dns_client_->SetConfig(dns_config); 2390 dns_client_->SetConfig(dns_config);
2393 num_dns_failures_ = 0; 2391 num_dns_failures_ = 0;
2394 if (dns_client_->GetConfig()) 2392 if (dns_client_->GetConfig())
2395 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); 2393 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true);
2396 } 2394 }
2397 2395
2398 AbortDnsTasks(); 2396 AbortDnsTasks();
2399 } 2397 }
2400 2398
2401 } // namespace net 2399 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/host_resolver_impl.h ('k') | net/dns/mapped_host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698