48
48
#include " net/dns/dns_response.h"
49
49
#include " net/dns/dns_server_iterator.h"
50
50
#include " net/dns/dns_session.h"
51
+ #include " net/dns/dns_socket_pool.h"
51
52
#include " net/dns/dns_udp_tracker.h"
52
53
#include " net/dns/dns_util.h"
53
54
#include " net/dns/public/dns_over_https_server_config.h"
@@ -187,12 +188,12 @@ class DnsAttempt {
187
188
class DnsUDPAttempt : public DnsAttempt {
188
189
public:
189
190
DnsUDPAttempt (size_t server_index,
190
- std::unique_ptr<DnsSession::SocketLease> socket_lease ,
191
+ std::unique_ptr<DatagramClientSocket> socket ,
191
192
std::unique_ptr<DnsQuery> query,
192
193
DnsUdpTracker* udp_tracker)
193
194
: DnsAttempt(server_index),
194
195
next_state_ (STATE_NONE),
195
- socket_lease_ (std::move(socket_lease )),
196
+ socket_ (std::move(socket )),
196
197
query_(std::move(query)),
197
198
udp_tracker_(udp_tracker) {}
198
199
@@ -205,7 +206,7 @@ class DnsUDPAttempt : public DnsAttempt {
205
206
next_state_ = STATE_SEND_QUERY;
206
207
207
208
IPEndPoint local_address;
208
- if (socket_lease_-> socket () ->GetLocalAddress (&local_address) == OK)
209
+ if (socket_ ->GetLocalAddress (&local_address) == OK)
209
210
udp_tracker_->RecordQuery (local_address.port (), query_->id ());
210
211
211
212
return DoLoop (OK);
@@ -219,7 +220,7 @@ class DnsUDPAttempt : public DnsAttempt {
219
220
}
220
221
221
222
const NetLogWithSource& GetSocketNetLog () const override {
222
- return socket_lease_-> socket () ->NetLog ();
223
+ return socket_ ->NetLog ();
223
224
}
224
225
225
226
private:
@@ -231,8 +232,6 @@ class DnsUDPAttempt : public DnsAttempt {
231
232
STATE_NONE,
232
233
};
233
234
234
- DatagramClientSocket* socket () { return socket_lease_->socket (); }
235
-
236
235
int DoLoop (int result) {
237
236
CHECK_NE (STATE_NONE, next_state_);
238
237
int rv = result;
@@ -270,7 +269,7 @@ class DnsUDPAttempt : public DnsAttempt {
270
269
271
270
int DoSendQuery () {
272
271
next_state_ = STATE_SEND_QUERY_COMPLETE;
273
- return socket () ->Write (
272
+ return socket_ ->Write (
274
273
query_->io_buffer (), query_->io_buffer ()->size (),
275
274
base::BindOnce (&DnsUDPAttempt::OnIOComplete, base::Unretained (this )),
276
275
kTrafficAnnotation );
@@ -292,7 +291,7 @@ class DnsUDPAttempt : public DnsAttempt {
292
291
int DoReadResponse () {
293
292
next_state_ = STATE_READ_RESPONSE_COMPLETE;
294
293
response_ = std::make_unique<DnsResponse>();
295
- return socket () ->Read (
294
+ return socket_ ->Read (
296
295
response_->io_buffer (), response_->io_buffer_size (),
297
296
base::BindOnce (&DnsUDPAttempt::OnIOComplete, base::Unretained (this )));
298
297
}
@@ -328,7 +327,7 @@ class DnsUDPAttempt : public DnsAttempt {
328
327
State next_state_;
329
328
base::TimeTicks start_time_;
330
329
331
- std::unique_ptr<DnsSession::SocketLease> socket_lease_ ;
330
+ std::unique_ptr<DatagramClientSocket> socket_ ;
332
331
std::unique_ptr<DnsQuery> query_;
333
332
334
333
// Should be owned by the DnsSession, to which the transaction should own a
@@ -1258,13 +1257,13 @@ class DnsTransactionImpl : public DnsTransaction,
1258
1257
DCHECK (!secure_);
1259
1258
size_t attempt_number = attempts_.size ();
1260
1259
1261
- std::unique_ptr<DnsSession::SocketLease> lease =
1262
- session_->AllocateSocket (server_index, net_log_. source () );
1260
+ std::unique_ptr<DatagramClientSocket> socket =
1261
+ session_->socket_pool ()-> CreateConnectedUdpSocket (server_index );
1263
1262
1264
- bool got_socket = !!lease .get ();
1263
+ bool got_socket = !!socket .get ();
1265
1264
1266
1265
DnsUDPAttempt* attempt =
1267
- new DnsUDPAttempt (server_index, std::move (lease ), std::move (query),
1266
+ new DnsUDPAttempt (server_index, std::move (socket ), std::move (query),
1268
1267
session_->udp_tracker ());
1269
1268
1270
1269
attempts_.push_back (base::WrapUnique (attempt));
@@ -1339,7 +1338,8 @@ class DnsTransactionImpl : public DnsTransaction,
1339
1338
DCHECK (!secure_);
1340
1339
1341
1340
std::unique_ptr<StreamSocket> socket (
1342
- session_->CreateTCPSocket (server_index, net_log_.source ()));
1341
+ session_->socket_pool ()->CreateTcpSocket (server_index,
1342
+ net_log_.source ()));
1343
1343
1344
1344
unsigned attempt_number = attempts_.size ();
1345
1345
0 commit comments