1 // Copyright 2017 The Chromium Authors 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 10 #include "base/sequence_checker.h" 11 #include "net/base/net_export.h" 12 #include "net/log/net_log_with_source.h" 13 #include "net/nqe/effective_connection_type.h" 14 #include "net/nqe/network_quality.h" 15 16 namespace net { 17 18 class NetLogWithSource; 19 20 namespace nqe::internal { 21 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); 26 27 EventCreator(const EventCreator&) = delete; 28 EventCreator& operator=(const EventCreator&) = delete; 29 30 ~EventCreator(); 31 32 // May add network quality changed event to the net-internals log if there 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. 35 // |effective_connection_type| is the current effective connection type. 36 // |network_quality| is the current network quality. 37 void MaybeAddNetworkQualityChangedEventToNetLog( 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. 45 EffectiveConnectionType past_effective_connection_type_ = 46 EFFECTIVE_CONNECTION_TYPE_UNKNOWN; 47 48 // The network quality when the net log event was last added. 49 NetworkQuality past_network_quality_; 50 51 SEQUENCE_CHECKER(sequence_checker_); 52 }; 53 54 } // namespace nqe::internal 55 56 } // namespace net 57 58 #endif // NET_NQE_EVENT_CREATOR_H_ 59