event_creator.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2017 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. #ifndef NET_NQE_EVENT_CREATOR_H_
  5. #define NET_NQE_EVENT_CREATOR_H_
  6. #include <stdint.h>
  7. #include "base/sequence_checker.h"
  8. #include "net/base/net_export.h"
  9. #include "net/log/net_log_with_source.h"
  10. #include "net/nqe/effective_connection_type.h"
  11. #include "net/nqe/network_quality.h"
  12. namespace net {
  13. class NetLogWithSource;
  14. namespace nqe::internal {
  15. // Class that adds net log events for network quality estimator.
  16. class NET_EXPORT_PRIVATE EventCreator {
  17. public:
  18. explicit EventCreator(NetLogWithSource net_log);
  19. EventCreator(const EventCreator&) = delete;
  20. EventCreator& operator=(const EventCreator&) = delete;
  21. ~EventCreator();
  22. // May add network quality changed event to the net-internals log if there
  23. // is a change in the effective connection type, or if there is a meaningful
  24. // change in the values of HTTP RTT, transport RTT or bandwidth.
  25. // |effective_connection_type| is the current effective connection type.
  26. // |network_quality| is the current network quality.
  27. void MaybeAddNetworkQualityChangedEventToNetLog(
  28. EffectiveConnectionType effective_connection_type,
  29. const NetworkQuality& network_quality);
  30. private:
  31. NetLogWithSource net_log_;
  32. // The effective connection type when the net log event was last added.
  33. EffectiveConnectionType past_effective_connection_type_ =
  34. EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
  35. // The network quality when the net log event was last added.
  36. NetworkQuality past_network_quality_;
  37. SEQUENCE_CHECKER(sequence_checker_);
  38. };
  39. } // namespace nqe::internal
  40. } // namespace net
  41. #endif // NET_NQE_EVENT_CREATOR_H_