blob: 57a5f31b5140f27f55fda85d4fa2cca1172cfee2 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2017 The Chromium Authors
tbansal97e38a22017-01-20 20:43:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef NET_NQE_EVENT_CREATOR_H_
6#define NET_NQE_EVENT_CREATOR_H_
7
8#include <stdint.h>
9
Tarun Bansalc71cf622018-10-16 16:24:4410#include "base/sequence_checker.h"
tbansal781262f2017-01-26 14:21:2111#include "net/base/net_export.h"
12#include "net/log/net_log_with_source.h"
tbansal97e38a22017-01-20 20:43:0213#include "net/nqe/effective_connection_type.h"
tbansal781262f2017-01-26 14:21:2114#include "net/nqe/network_quality.h"
tbansal97e38a22017-01-20 20:43:0215
16namespace net {
17
18class NetLogWithSource;
19
Tsuyoshi Horo4f516be2022-06-14 11:53:1320namespace nqe::internal {
tbansal97e38a22017-01-20 20:43:0221
tbansal781262f2017-01-26 14:21:2122// Class that adds net log events for network quality estimator.
23class NET_EXPORT_PRIVATE EventCreator {
24 public:
25 explicit EventCreator(NetLogWithSource net_log);
Peter Boström293b1342021-09-22 17:31:4326
27 EventCreator(const EventCreator&) = delete;
28 EventCreator& operator=(const EventCreator&) = delete;
29
tbansal781262f2017-01-26 14:21:2130 ~EventCreator();
31
32 // May add network quality changed event to the net-internals log if there
tbansalf38471f2017-03-04 01:07:0433 // is a change in the effective connection type, or if there is a meaningful
34 // change in the values of HTTP RTT, transport RTT or bandwidth.
tbansal781262f2017-01-26 14:21:2135 // |effective_connection_type| is the current effective connection type.
36 // |network_quality| is the current network quality.
tbansalf38471f2017-03-04 01:07:0437 void MaybeAddNetworkQualityChangedEventToNetLog(
tbansal781262f2017-01-26 14:21:2138 EffectiveConnectionType effective_connection_type,
39 const NetworkQuality& network_quality);
40
41 private:
42 NetLogWithSource net_log_;
43
44 // The effective connection type when the net log event was last added.
Tsuyoshi Horo2fa6b8de2022-06-09 01:40:2045 EffectiveConnectionType past_effective_connection_type_ =
46 EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
tbansal781262f2017-01-26 14:21:2147
48 // The network quality when the net log event was last added.
49 NetworkQuality past_network_quality_;
50
Tarun Bansalc71cf622018-10-16 16:24:4451 SEQUENCE_CHECKER(sequence_checker_);
tbansal781262f2017-01-26 14:21:2152};
tbansal97e38a22017-01-20 20:43:0253
Tsuyoshi Horo4f516be2022-06-14 11:53:1354} // namespace nqe::internal
tbansal97e38a22017-01-20 20:43:0255
56} // namespace net
57
58#endif // NET_NQE_EVENT_CREATOR_H_