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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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/disk_cache/simple/simple_version_upgrade_unittest.cc ('k') | net/dns/mdns_client_impl.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>
11 #endif 11 #endif
12 12
13 #include <cmath> 13 #include <cmath>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/bind_helpers.h" 19 #include "base/bind_helpers.h"
20 #include "base/callback.h" 20 #include "base/callback.h"
21 #include "base/compiler_specific.h" 21 #include "base/compiler_specific.h"
22 #include "base/debug/debugger.h" 22 #include "base/debug/debugger.h"
23 #include "base/debug/stack_trace.h" 23 #include "base/debug/stack_trace.h"
24 #include "base/message_loop/message_loop_proxy.h"
25 #include "base/metrics/field_trial.h" 24 #include "base/metrics/field_trial.h"
26 #include "base/metrics/histogram_macros.h" 25 #include "base/metrics/histogram_macros.h"
27 #include "base/metrics/sparse_histogram.h" 26 #include "base/metrics/sparse_histogram.h"
28 #include "base/profiler/scoped_tracker.h" 27 #include "base/profiler/scoped_tracker.h"
29 #include "base/stl_util.h" 28 #include "base/stl_util.h"
30 #include "base/strings/string_util.h" 29 #include "base/strings/string_util.h"
31 #include "base/strings/utf_string_conversions.h" 30 #include "base/strings/utf_string_conversions.h"
31 #include "base/thread_task_runner_handle.h"
32 #include "base/threading/worker_pool.h" 32 #include "base/threading/worker_pool.h"
33 #include "base/time/time.h" 33 #include "base/time/time.h"
34 #include "base/values.h" 34 #include "base/values.h"
35 #include "net/base/address_family.h" 35 #include "net/base/address_family.h"
36 #include "net/base/address_list.h" 36 #include "net/base/address_list.h"
37 #include "net/base/dns_reloader.h" 37 #include "net/base/dns_reloader.h"
38 #include "net/base/dns_util.h" 38 #include "net/base/dns_util.h"
39 #include "net/base/host_port_pair.h" 39 #include "net/base/host_port_pair.h"
40 #include "net/base/ip_endpoint.h" 40 #include "net/base/ip_endpoint.h"
41 #include "net/base/net_errors.h" 41 #include "net/base/net_errors.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 bool ConfigureAsyncDnsNoFallbackFieldTrial() { 273 bool ConfigureAsyncDnsNoFallbackFieldTrial() {
274 const bool kDefault = false; 274 const bool kDefault = false;
275 275
276 // Configure the AsyncDns field trial as follows: 276 // Configure the AsyncDns field trial as follows:
277 // groups AsyncDnsNoFallbackA and AsyncDnsNoFallbackB: return true, 277 // groups AsyncDnsNoFallbackA and AsyncDnsNoFallbackB: return true,
278 // groups AsyncDnsA and AsyncDnsB: return false, 278 // groups AsyncDnsA and AsyncDnsB: return false,
279 // groups SystemDnsA and SystemDnsB: return false, 279 // groups SystemDnsA and SystemDnsB: return false,
280 // otherwise (trial absent): return default. 280 // otherwise (trial absent): return default.
281 std::string group_name = base::FieldTrialList::FindFullName("AsyncDns"); 281 std::string group_name = base::FieldTrialList::FindFullName("AsyncDns");
282 if (!group_name.empty()) 282 if (!group_name.empty()) {
283 return StartsWithASCII(group_name, "AsyncDnsNoFallback", false); 283 return base::StartsWith(group_name, "AsyncDnsNoFallback",
284 base::CompareCase::INSENSITIVE_ASCII);
285 }
284 return kDefault; 286 return kDefault;
285 } 287 }
286 288
287 //----------------------------------------------------------------------------- 289 //-----------------------------------------------------------------------------
288 290
289 AddressList EnsurePortOnAddressList(const AddressList& list, uint16 port) { 291 AddressList EnsurePortOnAddressList(const AddressList& list, uint16 port) {
290 if (list.empty() || list.front().port() == port) 292 if (list.empty() || list.front().port() == port)
291 return list; 293 return list;
292 return AddressList::CopyWithPort(list, port); 294 return AddressList::CopyWithPort(list, port);
293 } 295 }
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 typedef base::Callback<void(int net_error, 587 typedef base::Callback<void(int net_error,
586 const AddressList& addr_list)> Callback; 588 const AddressList& addr_list)> Callback;
587 589
588 ProcTask(const Key& key, 590 ProcTask(const Key& key,
589 const ProcTaskParams& params, 591 const ProcTaskParams& params,
590 const Callback& callback, 592 const Callback& callback,
591 const BoundNetLog& job_net_log) 593 const BoundNetLog& job_net_log)
592 : key_(key), 594 : key_(key),
593 params_(params), 595 params_(params),
594 callback_(callback), 596 callback_(callback),
595 origin_loop_(base::MessageLoopProxy::current()), 597 origin_loop_(base::ThreadTaskRunnerHandle::Get()),
596 attempt_number_(0), 598 attempt_number_(0),
597 completed_attempt_number_(0), 599 completed_attempt_number_(0),
598 completed_attempt_error_(ERR_UNEXPECTED), 600 completed_attempt_error_(ERR_UNEXPECTED),
599 had_non_speculative_request_(false), 601 had_non_speculative_request_(false),
600 net_log_(job_net_log) { 602 net_log_(job_net_log) {
601 if (!params_.resolver_proc.get()) 603 if (!params_.resolver_proc.get())
602 params_.resolver_proc = HostResolverProc::GetDefault(); 604 params_.resolver_proc = HostResolverProc::GetDefault();
603 // If default is unset, use the system proc. 605 // If default is unset, use the system proc.
604 if (!params_.resolver_proc.get()) 606 if (!params_.resolver_proc.get())
605 params_.resolver_proc = new SystemHostResolverProc(); 607 params_.resolver_proc = new SystemHostResolverProc();
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 // Holds an owning reference to the HostResolverProc that we are going to use. 918 // Holds an owning reference to the HostResolverProc that we are going to use.
917 // This may not be the current resolver procedure by the time we call 919 // This may not be the current resolver procedure by the time we call
918 // ResolveAddrInfo, but that's OK... we'll use it anyways, and the owning 920 // ResolveAddrInfo, but that's OK... we'll use it anyways, and the owning
919 // reference ensures that it remains valid until we are done. 921 // reference ensures that it remains valid until we are done.
920 ProcTaskParams params_; 922 ProcTaskParams params_;
921 923
922 // The listener to the results of this ProcTask. 924 // The listener to the results of this ProcTask.
923 Callback callback_; 925 Callback callback_;
924 926
925 // Used to post ourselves onto the origin thread. 927 // Used to post ourselves onto the origin thread.
926 scoped_refptr<base::MessageLoopProxy> origin_loop_; 928 scoped_refptr<base::SingleThreadTaskRunner> origin_loop_;
927 929
928 // Keeps track of the number of attempts we have made so far to resolve the 930 // Keeps track of the number of attempts we have made so far to resolve the
929 // host. Whenever we start an attempt to resolve the host, we increase this 931 // host. Whenever we start an attempt to resolve the host, we increase this
930 // number. 932 // number.
931 uint32 attempt_number_; 933 uint32 attempt_number_;
932 934
933 // The index of the attempt which finished first (or 0 if the job is still in 935 // The index of the attempt which finished first (or 0 if the job is still in
934 // progress). 936 // progress).
935 uint32 completed_attempt_number_; 937 uint32 completed_attempt_number_;
936 938
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 dns_client_->SetConfig(dns_config); 2420 dns_client_->SetConfig(dns_config);
2419 num_dns_failures_ = 0; 2421 num_dns_failures_ = 0;
2420 if (dns_client_->GetConfig()) 2422 if (dns_client_->GetConfig())
2421 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); 2423 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true);
2422 } 2424 }
2423 2425
2424 AbortDnsTasks(); 2426 AbortDnsTasks();
2425 } 2427 }
2426 2428
2427 } // namespace net 2429 } // namespace net
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_version_upgrade_unittest.cc ('k') | net/dns/mdns_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698