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

Unified Diff: blimp/net/blimp_connection_statistics.h

Issue 2019463002: Reland: Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed an ownership issue Created 4 years, 7 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: blimp/net/blimp_connection_statistics.h
diff --git a/blimp/net/blimp_connection_statistics.h b/blimp/net/blimp_connection_statistics.h
new file mode 100644
index 0000000000000000000000000000000000000000..fefd96ddcd8439d0172d16394c47580f18ce6592
--- /dev/null
+++ b/blimp/net/blimp_connection_statistics.h
@@ -0,0 +1,49 @@
+// Copyright 2016 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.
+
+#ifndef BLIMP_NET_BLIMP_CONNECTION_STATISTICS_H_
+#define BLIMP_NET_BLIMP_CONNECTION_STATISTICS_H_
+
+#include <map>
+#include "base/macros.h"
+#include "base/metrics/sparse_histogram.h"
+#include "blimp/net/blimp_net_export.h"
+
+namespace blimp {
+
+// Collects network traffic statistics. Maintains a counter for number of
+// completed commits, bytes sent and received over network and notifies its
+// observers on the main thread.
+// This class is supposed to live an entire session, created and destroyed along
+// it. This class is thread-safe.
Wez 2016/06/07 00:30:13 I can't find anything in SparseHistogram that actu
+class BLIMP_NET_EXPORT BlimpConnectionStatistics {
+ public:
+ enum EventType {
+ BYTES_SENT = 0,
+ BYTES_RECEIVED = 1,
+ COMMIT = 2,
+ };
+
+ BlimpConnectionStatistics();
+
+ ~BlimpConnectionStatistics();
+
+ // Accumulates values for a metric.
+ void Add(EventType type, int data);
+
+ // Returns value for a metric.
+ int Get(EventType type);
+
+ private:
+ // A histogram to hold the metrics. It will have one sample for each type of
+ // metric which will be accumulated on each subsequent call. Histograms are
+ // intentionally leaked at the process termination.
Kevin M 2016/05/26 23:15:30 ??? Why do we leak them? Is there another task th
Wez 2016/06/07 00:30:12 Did this ever get answered?
+ base::HistogramBase* histogram_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlimpConnectionStatistics);
+};
+
+} // namespace blimp
+
+#endif // BLIMP_NET_BLIMP_CONNECTION_STATISTICS_H_

Powered by Google App Engine
This is Rietveld 408576698