Avi Drissman | 6459548 | 2022-09-14 20:52:29 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "net/dns/dns_session.h" | ||||
6 | |||||
avi | 6516805 | 2015-12-01 19:27:07 | [diff] [blame] | 7 | #include <stdint.h> |
danakj | 22f90e7 | 2016-04-16 01:55:40 | [diff] [blame] | 8 | |
avi | 6516805 | 2015-12-01 19:27:07 | [diff] [blame] | 9 | #include <limits> |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 10 | #include <utility> |
avi | 6516805 | 2015-12-01 19:27:07 | [diff] [blame] | 11 | |
Avi Drissman | 41c4a41 | 2023-01-11 22:45:37 | [diff] [blame^] | 12 | #include "base/functional/bind.h" |
[email protected] | 120d38d | 2012-12-14 01:42:32 | [diff] [blame] | 13 | #include "base/rand_util.h" |
dalyk | c2adf18 | 2019-09-02 14:31:22 | [diff] [blame] | 14 | #include "net/dns/dns_config.h" |
Eric Orth | 98c2feb | 2020-08-20 18:51:25 | [diff] [blame] | 15 | #include "net/log/net_log.h" |
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 16 | |
17 | namespace net { | ||||
18 | |||||
19 | DnsSession::DnsSession(const DnsConfig& config, | ||||
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 20 | const RandIntCallback& rand_int_callback, |
21 | NetLog* net_log) | ||||
22 | : config_(config), | ||||
Anna Malova | f817b39b6 | 2020-03-02 18:38:00 | [diff] [blame] | 23 | rand_callback_(base::BindRepeating(rand_int_callback, |
24 | 0, | ||||
25 | std::numeric_limits<uint16_t>::max())), | ||||
Eric Orth | f7ebdde | 2021-01-08 22:48:14 | [diff] [blame] | 26 | net_log_(net_log) {} |
[email protected] | 120d38d | 2012-12-14 01:42:32 | [diff] [blame] | 27 | |
dalyk | c2adf18 | 2019-09-02 14:31:22 | [diff] [blame] | 28 | DnsSession::~DnsSession() = default; |
ttuttle | cf1158bf | 2016-03-18 16:37:44 | [diff] [blame] | 29 | |
avi | 6516805 | 2015-12-01 19:27:07 | [diff] [blame] | 30 | uint16_t DnsSession::NextQueryId() const { |
31 | return static_cast<uint16_t>(rand_callback_.Run()); | ||||
pkasting | 6b68a16 | 2014-12-01 22:10:29 | [diff] [blame] | 32 | } |
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 33 | |
Eric Orth | 7dc18e9 | 2020-02-13 20:27:56 | [diff] [blame] | 34 | void DnsSession::InvalidateWeakPtrsForTesting() { |
35 | weak_ptr_factory_.InvalidateWeakPtrs(); | ||||
36 | } | ||||
37 | |||||
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 38 | } // namespace net |