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

Side by Side Diff: net/tools/quic/synchronous_host_resolver.cc

Issue 2214693002: First step to remove SingleRequestHostResolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: single Created 4 years, 4 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/socket/websocket_transport_client_socket_pool.cc ('k') | no next file » | 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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/tools/quic/synchronous_host_resolver.h" 5 #include "net/tools/quic/synchronous_host_resolver.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/simple_thread.h" 13 #include "base/threading/simple_thread.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "net/base/host_port_pair.h" 15 #include "net/base/host_port_pair.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/dns/host_resolver_impl.h" 17 #include "net/dns/host_resolver_impl.h"
18 #include "net/dns/single_request_host_resolver.h"
19 18
20 namespace net { 19 namespace net {
21 20
22 21
23 namespace { 22 namespace {
24 23
25 class ResolverThread : public base::SimpleThread { 24 class ResolverThread : public base::SimpleThread {
26 public: 25 public:
27 ResolverThread(); 26 ResolverThread();
28 27
(...skipping 24 matching lines...) Expand all
53 52
54 ResolverThread::~ResolverThread() {} 53 ResolverThread::~ResolverThread() {}
55 54
56 void ResolverThread::Run() { 55 void ResolverThread::Run() {
57 base::MessageLoopForIO loop; 56 base::MessageLoopForIO loop;
58 57
59 net::NetLog net_log; 58 net::NetLog net_log;
60 net::HostResolver::Options options; 59 net::HostResolver::Options options;
61 options.max_concurrent_resolves = 6; 60 options.max_concurrent_resolves = 6;
62 options.max_retry_attempts = 3u; 61 options.max_retry_attempts = 3u;
63 std::unique_ptr<net::HostResolverImpl> resolver_impl( 62 std::unique_ptr<net::HostResolverImpl> resolver(
64 new net::HostResolverImpl(options, &net_log)); 63 new net::HostResolverImpl(options, &net_log));
65 SingleRequestHostResolver resolver(resolver_impl.get());
66 64
65 std::unique_ptr<net::HostResolver::Request> request;
67 HostPortPair host_port_pair(host_, 80); 66 HostPortPair host_port_pair(host_, 80);
68 rv_ = resolver.Resolve(HostResolver::RequestInfo(host_port_pair), 67 rv_ = resolver->Resolve(HostResolver::RequestInfo(host_port_pair),
69 DEFAULT_PRIORITY, addresses_, 68 DEFAULT_PRIORITY, addresses_,
70 base::Bind(&ResolverThread::OnResolutionComplete, 69 base::Bind(&ResolverThread::OnResolutionComplete,
71 weak_factory_.GetWeakPtr()), 70 weak_factory_.GetWeakPtr()),
72 BoundNetLog()); 71 &request, BoundNetLog());
73 72
74 if (rv_ != ERR_IO_PENDING) 73 if (rv_ != ERR_IO_PENDING)
75 return; 74 return;
76 75
77 // Run the mesage loop until OnResolutionComplete quits it. 76 // Run the mesage loop until OnResolutionComplete quits it.
78 base::RunLoop().Run(); 77 base::RunLoop().Run();
79 } 78 }
80 79
81 int ResolverThread::Resolve(const std::string& host, AddressList* addresses) { 80 int ResolverThread::Resolve(const std::string& host, AddressList* addresses) {
82 host_ = host; 81 host_ = host;
(...skipping 12 matching lines...) Expand all
95 } // namespace 94 } // namespace
96 95
97 // static 96 // static
98 int SynchronousHostResolver::Resolve(const std::string& host, 97 int SynchronousHostResolver::Resolve(const std::string& host,
99 AddressList* addresses) { 98 AddressList* addresses) {
100 ResolverThread resolver; 99 ResolverThread resolver;
101 return resolver.Resolve(host, addresses); 100 return resolver.Resolve(host, addresses);
102 } 101 }
103 102
104 } // namespace net 103 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/websocket_transport_client_socket_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698