dns_session.cc 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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
  3. // found in the LICENSE file.
  4. #include "net/dns/dns_session.h"
  5. #include <stdint.h>
  6. #include <limits>
  7. #include <utility>
  8. #include "base/bind.h"
  9. #include "base/rand_util.h"
  10. #include "net/dns/dns_config.h"
  11. #include "net/log/net_log.h"
  12. namespace net {
  13. DnsSession::DnsSession(const DnsConfig& config,
  14. const RandIntCallback& rand_int_callback,
  15. NetLog* net_log)
  16. : config_(config),
  17. rand_callback_(base::BindRepeating(rand_int_callback,
  18. 0,
  19. std::numeric_limits<uint16_t>::max())),
  20. net_log_(net_log) {}
  21. DnsSession::~DnsSession() = default;
  22. uint16_t DnsSession::NextQueryId() const {
  23. return static_cast<uint16_t>(rand_callback_.Run());
  24. }
  25. void DnsSession::InvalidateWeakPtrsForTesting() {
  26. weak_ptr_factory_.InvalidateWeakPtrs();
  27. }
  28. } // namespace net