blob: 351685813aad73b9fac99d53e33408d90c6d1e66 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2012 The Chromium Authors
[email protected]7556ea22011-12-08 19:29:152// 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
avi65168052015-12-01 19:27:077#include <stdint.h>
danakj22f90e72016-04-16 01:55:408
avi65168052015-12-01 19:27:079#include <limits>
dchengc7eeda422015-12-26 03:56:4810#include <utility>
avi65168052015-12-01 19:27:0711
Avi Drissman41c4a412023-01-11 22:45:3712#include "base/functional/bind.h"
[email protected]120d38d2012-12-14 01:42:3213#include "base/rand_util.h"
dalykc2adf182019-09-02 14:31:2214#include "net/dns/dns_config.h"
Eric Orth98c2feb2020-08-20 18:51:2515#include "net/log/net_log.h"
[email protected]7556ea22011-12-08 19:29:1516
17namespace net {
18
19DnsSession::DnsSession(const DnsConfig& config,
[email protected]7556ea22011-12-08 19:29:1520 const RandIntCallback& rand_int_callback,
21 NetLog* net_log)
22 : config_(config),
Anna Malovaf817b39b62020-03-02 18:38:0023 rand_callback_(base::BindRepeating(rand_int_callback,
24 0,
25 std::numeric_limits<uint16_t>::max())),
Eric Orthf7ebdde2021-01-08 22:48:1426 net_log_(net_log) {}
[email protected]120d38d2012-12-14 01:42:3227
dalykc2adf182019-09-02 14:31:2228DnsSession::~DnsSession() = default;
ttuttlecf1158bf2016-03-18 16:37:4429
avi65168052015-12-01 19:27:0730uint16_t DnsSession::NextQueryId() const {
31 return static_cast<uint16_t>(rand_callback_.Run());
pkasting6b68a162014-12-01 22:10:2932}
[email protected]7556ea22011-12-08 19:29:1533
Eric Orth7dc18e92020-02-13 20:27:5634void DnsSession::InvalidateWeakPtrsForTesting() {
35 weak_ptr_factory_.InvalidateWeakPtrs();
36}
37
[email protected]7556ea22011-12-08 19:29:1538} // namespace net