| 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->SetString("http_rtt", |
| 32 base::IntToString(http_rtt.InMilliseconds()) + " msec"); |
| 33 dict->SetString("transport_rtt", |
| 34 base::IntToString(transport_rtt.InMilliseconds()) + " msec"); |
| 35 dict->SetString("downstream_throughput", |
| 36 base::IntToString(downstream_throughput_kbps) + " kbps"); |
| 37 dict->SetString("effective_connection_type", |
| 38 GetNameForEffectiveConnectionType(effective_connection_type)); |
| 39 return std::move(dict); |
| 40 } |
| 41 |
| 42 } // namespace |
| 43 |
| 44 void AddEffectiveConnectionTypeChangedEventToNetLog( |
| 45 const NetLogWithSource& net_log, |
| 46 base::TimeDelta http_rtt, |
| 47 base::TimeDelta transport_rtt, |
| 48 int32_t downstream_throughput_kbps, |
| 49 EffectiveConnectionType effective_connection_type) { |
| 50 net_log.AddEvent( |
| 51 NetLogEventType::NETWORK_QUALITY_CHANGED, |
| 52 base::Bind(&EffectiveConnectionTypeChangedNetLogCallback, http_rtt, |
| 53 transport_rtt, downstream_throughput_kbps, |
| 54 effective_connection_type)); |
| 55 } |
| 56 |
| 57 } // namespace internal |
| 58 |
| 59 } // namespace nqe |
| 60 |
| 61 } // namespace net |
| OLD | NEW |