socket_watcher_factory.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2016 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/nqe/socket_watcher_factory.h"
  5. #include "base/time/time.h"
  6. #include "net/nqe/socket_watcher.h"
  7. namespace net::nqe::internal {
  8. SocketWatcherFactory::SocketWatcherFactory(
  9. scoped_refptr<base::SingleThreadTaskRunner> task_runner,
  10. base::TimeDelta min_notification_interval,
  11. OnUpdatedRTTAvailableCallback updated_rtt_observation_callback,
  12. ShouldNotifyRTTCallback should_notify_rtt_callback,
  13. const base::TickClock* tick_clock)
  14. : task_runner_(std::move(task_runner)),
  15. min_notification_interval_(min_notification_interval),
  16. updated_rtt_observation_callback_(updated_rtt_observation_callback),
  17. should_notify_rtt_callback_(should_notify_rtt_callback),
  18. tick_clock_(tick_clock) {
  19. DCHECK(tick_clock_);
  20. }
  21. SocketWatcherFactory::~SocketWatcherFactory() = default;
  22. std::unique_ptr<SocketPerformanceWatcher>
  23. SocketWatcherFactory::CreateSocketPerformanceWatcher(
  24. const Protocol protocol,
  25. const AddressList& address_list) {
  26. return std::make_unique<SocketWatcher>(
  27. protocol, address_list, min_notification_interval_,
  28. allow_rtt_private_address_, task_runner_,
  29. updated_rtt_observation_callback_, should_notify_rtt_callback_,
  30. tick_clock_);
  31. }
  32. void SocketWatcherFactory::SetTickClockForTesting(
  33. const base::TickClock* tick_clock) {
  34. tick_clock_ = tick_clock;
  35. }
  36. } // namespace net::nqe::internal