| OLD | NEW |
| (Empty) | |
| 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 #include "net/nqe/event_creator.h" |
| 6 |
| 7 #include <memory> |
| 8 #include <utility> |
| 9 |
| 10 #include "base/bind.h" |
| 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/values.h" |
| 13 #include "net/log/net_log_capture_mode.h" |
| 14 #include "net/log/net_log_with_source.h" |
| 15 |
| 16 namespace net { |
| 17 |
| 18 namespace nqe { |
| 19 |
| 20 namespace internal { |
| 21 |
| 22 namespace { |
| 23 |
| 24 std::unique_ptr<base::Value> EffectiveConnectionTypeChangedNetLogCallback( |
| 25 base::TimeDelta http_rtt, |
| 26 base::TimeDelta transport_rtt, |
| 27 int32_t downstream_throughput_kbps, |
| 28 EffectiveConnectionType effective_connection_type, |
| 29 NetLogCaptureMode capture_mode) { |
| 30 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 31 dict->SetInteger("http_rtt_ms", http_rtt.InMilliseconds()); |
| 32 dict->SetInteger("transport_rtt_ms", transport_rtt.InMilliseconds()); |
| 33 dict->SetInteger("downstream_throughput_kbps", downstream_throughput_kbps); |
| 34 dict->SetString("effective_connection_type", |
| 35 GetNameForEffectiveConnectionType(effective_connection_type)); |
| 36 return std::move(dict); |
| 37 } |
| 38 |
| 39 } // namespace |
| 40 |
| 41 void AddEffectiveConnectionTypeChangedEventToNetLog( |
| 42 const NetLogWithSource& net_log, |
| 43 base::TimeDelta http_rtt, |
| 44 base::TimeDelta transport_rtt, |
| 45 int32_t downstream_throughput_kbps, |
| 46 EffectiveConnectionType effective_connection_type) { |
| 47 net_log.AddEvent( |
| 48 NetLogEventType::NETWORK_QUALITY_CHANGED, |
| 49 base::Bind(&EffectiveConnectionTypeChangedNetLogCallback, http_rtt, |
| 50 transport_rtt, downstream_throughput_kbps, |
| 51 effective_connection_type)); |
| 52 } |
| 53 |
| 54 } // namespace internal |
| 55 |
| 56 } // namespace nqe |
| 57 |
| 58 } // namespace net |
| OLD | NEW |