Avi Drissman | 6459548 | 2022-09-14 20:52:29 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 2 | // 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 Bansal | c71cf62 | 2018-10-16 16:24:44 | [diff] [blame] | 10 | #include "base/sequence_checker.h" |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 11 | #include "net/base/net_export.h" |
| 12 | #include "net/log/net_log_with_source.h" |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 13 | #include "net/nqe/effective_connection_type.h" |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 14 | #include "net/nqe/network_quality.h" |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 15 | |
| 16 | namespace net { |
| 17 | |
| 18 | class NetLogWithSource; |
| 19 | |
Tsuyoshi Horo | 4f516be | 2022-06-14 11:53:13 | [diff] [blame] | 20 | namespace nqe::internal { |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 21 | |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 22 | // Class that adds net log events for network quality estimator. |
| 23 | class NET_EXPORT_PRIVATE EventCreator { |
| 24 | public: |
| 25 | explicit EventCreator(NetLogWithSource net_log); |
Peter Boström | 293b134 | 2021-09-22 17:31:43 | [diff] [blame] | 26 | |
| 27 | EventCreator(const EventCreator&) = delete; |
| 28 | EventCreator& operator=(const EventCreator&) = delete; |
| 29 | |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 30 | ~EventCreator(); |
| 31 | |
| 32 | // May add network quality changed event to the net-internals log if there |
tbansal | f38471f | 2017-03-04 01:07:04 | [diff] [blame] | 33 | // 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. |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 35 | // |effective_connection_type| is the current effective connection type. |
| 36 | // |network_quality| is the current network quality. |
tbansal | f38471f | 2017-03-04 01:07:04 | [diff] [blame] | 37 | void MaybeAddNetworkQualityChangedEventToNetLog( |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 38 | 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 Horo | 2fa6b8de | 2022-06-09 01:40:20 | [diff] [blame] | 45 | EffectiveConnectionType past_effective_connection_type_ = |
| 46 | EFFECTIVE_CONNECTION_TYPE_UNKNOWN; |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 47 | |
| 48 | // The network quality when the net log event was last added. |
| 49 | NetworkQuality past_network_quality_; |
| 50 | |
Tarun Bansal | c71cf62 | 2018-10-16 16:24:44 | [diff] [blame] | 51 | SEQUENCE_CHECKER(sequence_checker_); |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 52 | }; |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 53 | |
Tsuyoshi Horo | 4f516be | 2022-06-14 11:53:13 | [diff] [blame] | 54 | } // namespace nqe::internal |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 55 | |
| 56 | } // namespace net |
| 57 | |
| 58 | #endif // NET_NQE_EVENT_CREATOR_H_ |