1 // Copyright 2012 The Chromium Authors 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 7 #include <stdint.h> 8 9 #include <limits> 10 #include <utility> 11 12 #include "base/functional/bind.h" 13 #include "base/rand_util.h" 14 #include "net/dns/dns_config.h" 15 #include "net/log/net_log.h" 16 17 namespace net { 18 DnsSession(const DnsConfig & config,const RandIntCallback & rand_int_callback,NetLog * net_log)19DnsSession::DnsSession(const DnsConfig& config, 20 const RandIntCallback& rand_int_callback, 21 NetLog* net_log) 22 : config_(config), 23 rand_callback_(base::BindRepeating(rand_int_callback, 24 0, 25 std::numeric_limits<uint16_t>::max())), 26 net_log_(net_log) {} 27 28 DnsSession::~DnsSession() = default; 29 NextQueryId() const30uint16_t DnsSession::NextQueryId() const { 31 return static_cast<uint16_t>(rand_callback_.Run()); 32 } 33 InvalidateWeakPtrsForTesting()34void DnsSession::InvalidateWeakPtrsForTesting() { 35 weak_ptr_factory_.InvalidateWeakPtrs(); 36 } 37 38 } // namespace net 39