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

Side by Side Diff: content/browser/renderer_host/p2p/socket_dispatcher_host.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
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 "content/browser/renderer_host/p2p/socket_dispatcher_host.h" 5 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "content/browser/bad_message.h" 11 #include "content/browser/bad_message.h"
12 #include "content/browser/renderer_host/p2p/socket_host.h" 12 #include "content/browser/renderer_host/p2p/socket_host.h"
13 #include "content/common/p2p_messages.h" 13 #include "content/common/p2p_messages.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/resource_context.h" 15 #include "content/public/browser/resource_context.h"
16 #include "net/base/address_list.h" 16 #include "net/base/address_list.h"
17 #include "net/base/completion_callback.h" 17 #include "net/base/completion_callback.h"
18 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
19 #include "net/base/network_interfaces.h" 19 #include "net/base/network_interfaces.h"
20 #include "net/base/sys_addrinfo.h" 20 #include "net/base/sys_addrinfo.h"
21 #include "net/dns/single_request_host_resolver.h" 21 #include "net/dns/host_resolver.h"
22 #include "net/log/net_log.h" 22 #include "net/log/net_log.h"
23 #include "net/socket/client_socket_factory.h" 23 #include "net/socket/client_socket_factory.h"
24 #include "net/udp/datagram_client_socket.h" 24 #include "net/udp/datagram_client_socket.h"
25 #include "net/url_request/url_request_context_getter.h" 25 #include "net/url_request/url_request_context_getter.h"
26 26
27 using content::BrowserMessageFilter; 27 using content::BrowserMessageFilter;
28 using content::BrowserThread; 28 using content::BrowserThread;
29 29
30 namespace content { 30 namespace content {
31 31
(...skipping 30 matching lines...) Expand all
62 done_callback_.Run(address_list); 62 done_callback_.Run(address_list);
63 return; 63 return;
64 } 64 }
65 65
66 // Add period at the end to make sure that we only resolve 66 // Add period at the end to make sure that we only resolve
67 // fully-qualified names. 67 // fully-qualified names.
68 if (host_name_.back() != '.') 68 if (host_name_.back() != '.')
69 host_name_ += '.'; 69 host_name_ += '.';
70 70
71 net::HostResolver::RequestInfo info(net::HostPortPair(host_name_, 0)); 71 net::HostResolver::RequestInfo info(net::HostPortPair(host_name_, 0));
72 int result = resolver_.Resolve( 72 int result = resolver_->Resolve(
73 info, 73 info, net::DEFAULT_PRIORITY, &addresses_,
74 net::DEFAULT_PRIORITY,
75 &addresses_,
76 base::Bind(&P2PSocketDispatcherHost::DnsRequest::OnDone, 74 base::Bind(&P2PSocketDispatcherHost::DnsRequest::OnDone,
77 base::Unretained(this)), 75 base::Unretained(this)),
78 net::BoundNetLog()); 76 &request_, net::BoundNetLog());
79 if (result != net::ERR_IO_PENDING) 77 if (result != net::ERR_IO_PENDING)
80 OnDone(result); 78 OnDone(result);
81 } 79 }
82 80
83 int32_t request_id() { return request_id_; } 81 int32_t request_id() { return request_id_; }
84 82
85 private: 83 private:
86 void OnDone(int result) { 84 void OnDone(int result) {
87 net::IPAddressList list; 85 net::IPAddressList list;
88 if (result != net::OK) { 86 if (result != net::OK) {
89 LOG(ERROR) << "Failed to resolve address for " << host_name_ 87 LOG(ERROR) << "Failed to resolve address for " << host_name_
90 << ", errorcode: " << result; 88 << ", errorcode: " << result;
91 done_callback_.Run(list); 89 done_callback_.Run(list);
92 return; 90 return;
93 } 91 }
94 92
95 DCHECK(!addresses_.empty()); 93 DCHECK(!addresses_.empty());
96 for (net::AddressList::iterator iter = addresses_.begin(); 94 for (net::AddressList::iterator iter = addresses_.begin();
97 iter != addresses_.end(); ++iter) { 95 iter != addresses_.end(); ++iter) {
98 list.push_back(iter->address()); 96 list.push_back(iter->address());
99 } 97 }
100 done_callback_.Run(list); 98 done_callback_.Run(list);
101 } 99 }
102 100
103 int32_t request_id_; 101 int32_t request_id_;
104 net::AddressList addresses_; 102 net::AddressList addresses_;
105 103
106 std::string host_name_; 104 std::string host_name_;
107 net::SingleRequestHostResolver resolver_; 105 net::HostResolver* resolver_;
106 std::unique_ptr<net::HostResolver::Request> request_;
108 107
109 DoneCallback done_callback_; 108 DoneCallback done_callback_;
110 }; 109 };
111 110
112 P2PSocketDispatcherHost::P2PSocketDispatcherHost( 111 P2PSocketDispatcherHost::P2PSocketDispatcherHost(
113 content::ResourceContext* resource_context, 112 content::ResourceContext* resource_context,
114 net::URLRequestContextGetter* url_context) 113 net::URLRequestContextGetter* url_context)
115 : BrowserMessageFilter(P2PMsgStart), 114 : BrowserMessageFilter(P2PMsgStart),
116 resource_context_(resource_context), 115 resource_context_(resource_context),
117 url_context_(url_context), 116 url_context_(url_context),
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 413
415 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_) 414 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_)
416 packet_callback_.Reset(); 415 packet_callback_.Reset();
417 416
418 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) 417 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it)
419 it->second->StopRtpDump(incoming, outgoing); 418 it->second->StopRtpDump(incoming, outgoing);
420 } 419 }
421 } 420 }
422 421
423 } // namespace content 422 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_hints_impl.cc ('k') | content/browser/renderer_host/pepper/pepper_lookup_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698