Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1374)

Unified Diff: net/nqe/event_creator.cc

Issue 2593243003: Add network quality change events to net log (Closed)
Patch Set: ps Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/nqe/event_creator.cc
diff --git a/net/nqe/event_creator.cc b/net/nqe/event_creator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5b74ab7ec432e1de78033d535479ce5ea31b776e
--- /dev/null
+++ b/net/nqe/event_creator.cc
@@ -0,0 +1,57 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/nqe/event_creator.h"
+
+#include "base/bind.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/values.h"
+#include "net/log/net_log_with_source.h"
+
+namespace net {
+
+namespace nqe {
+
+namespace internal {
+
+namespace {
+
+std::unique_ptr<base::Value> EffectiveConnectionTypeChangedNetLogCallback(
RyanSturm 2017/01/10 16:22:37 #include <memory>
tbansal1 2017/01/10 18:27:52 Done.
+ base::TimeDelta http_rtt,
+ base::TimeDelta transport_rtt,
+ int32_t downstream_throughput_kbps,
+ EffectiveConnectionType effective_connection_type,
+ NetLogCaptureMode capture_mode) {
RyanSturm 2017/01/10 16:22:37 #include "net/log/net_log_capture_mode.h" since it
tbansal1 2017/01/10 18:27:52 Done.
+ std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ dict->SetString("http_rtt",
+ base::IntToString(http_rtt.InMilliseconds()) + " msec");
+ dict->SetString("transport_rtt",
+ base::IntToString(transport_rtt.InMilliseconds()) + " msec");
+ dict->SetString("downstream_throughput",
+ base::IntToString(downstream_throughput_kbps) + " kbps");
+ dict->SetString("effective_connection_type",
+ GetNameForEffectiveConnectionType(effective_connection_type));
+ return std::move(dict);
RyanSturm 2017/01/10 16:22:37 maybe #include <utility>
tbansal1 2017/01/10 18:27:52 Done.
+}
+
+} // namespace
+
+void AddEffectiveConnectionTypeChangedEventToNetLog(
+ const NetLogWithSource& net_log,
+ base::TimeDelta http_rtt,
+ base::TimeDelta transport_rtt,
+ int32_t downstream_throughput_kbps,
+ EffectiveConnectionType effective_connection_type) {
+ net_log.AddEvent(
+ NetLogEventType::NETWORK_QUALITY_CHANGED,
+ base::Bind(&EffectiveConnectionTypeChangedNetLogCallback, http_rtt,
+ transport_rtt, downstream_throughput_kbps,
+ effective_connection_type));
+}
+
+} // namespace internal
+
+} // namespace nqe
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698