tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 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 | |
| 5 | #ifndef NET_NQE_EVENT_CREATOR_H_ |
| 6 | #define NET_NQE_EVENT_CREATOR_H_ |
| 7 | |
| 8 | #include <stdint.h> |
| 9 | |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 10 | #include "base/macros.h" |
Tarun Bansal | c71cf62 | 2018-10-16 16:24:44 | [diff] [blame] | 11 | #include "base/sequence_checker.h" |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 12 | #include "net/base/net_export.h" |
| 13 | #include "net/log/net_log_with_source.h" |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 14 | #include "net/nqe/effective_connection_type.h" |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 15 | #include "net/nqe/network_quality.h" |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 16 | |
| 17 | namespace net { |
| 18 | |
| 19 | class NetLogWithSource; |
| 20 | |
| 21 | namespace nqe { |
| 22 | |
| 23 | namespace internal { |
| 24 | |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 25 | // Class that adds net log events for network quality estimator. |
| 26 | class NET_EXPORT_PRIVATE EventCreator { |
| 27 | public: |
| 28 | explicit EventCreator(NetLogWithSource net_log); |
Peter Boström | 293b134 | 2021-09-22 17:31:43 | [diff] [blame^] | 29 | |
| 30 | EventCreator(const EventCreator&) = delete; |
| 31 | EventCreator& operator=(const EventCreator&) = delete; |
| 32 | |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 33 | ~EventCreator(); |
| 34 | |
| 35 | // May add network quality changed event to the net-internals log if there |
tbansal | f38471f | 2017-03-04 01:07:04 | [diff] [blame] | 36 | // is a change in the effective connection type, or if there is a meaningful |
| 37 | // change in the values of HTTP RTT, transport RTT or bandwidth. |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 38 | // |effective_connection_type| is the current effective connection type. |
| 39 | // |network_quality| is the current network quality. |
tbansal | f38471f | 2017-03-04 01:07:04 | [diff] [blame] | 40 | void MaybeAddNetworkQualityChangedEventToNetLog( |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 41 | EffectiveConnectionType effective_connection_type, |
| 42 | const NetworkQuality& network_quality); |
| 43 | |
| 44 | private: |
| 45 | NetLogWithSource net_log_; |
| 46 | |
| 47 | // The effective connection type when the net log event was last added. |
| 48 | EffectiveConnectionType past_effective_connection_type_; |
| 49 | |
| 50 | // The network quality when the net log event was last added. |
| 51 | NetworkQuality past_network_quality_; |
| 52 | |
Tarun Bansal | c71cf62 | 2018-10-16 16:24:44 | [diff] [blame] | 53 | SEQUENCE_CHECKER(sequence_checker_); |
tbansal | 781262f | 2017-01-26 14:21:21 | [diff] [blame] | 54 | }; |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 55 | |
| 56 | } // namespace internal |
| 57 | |
| 58 | } // namespace nqe |
| 59 | |
| 60 | } // namespace net |
| 61 | |
| 62 | #endif // NET_NQE_EVENT_CREATOR_H_ |