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

Unified Diff: blimp/net/blimp_connection_statistics.h

Issue 1962393004: Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added empty implementation for linux client 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
« no previous file with comments | « blimp/net/blimp_connection.cc ('k') | blimp/net/blimp_connection_statistics.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..497a982c71ccdb697ae48712122beb11328dd19a
--- /dev/null
+++ b/blimp/net/blimp_connection_statistics.h
@@ -0,0 +1,48 @@
+// 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.
+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.
+ std::unique_ptr<base::HistogramBase> histogram_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlimpConnectionStatistics);
+};
+
+} // namespace blimp
+
+#endif // BLIMP_NET_BLIMP_CONNECTION_STATISTICS_H_
« no previous file with comments | « blimp/net/blimp_connection.cc ('k') | blimp/net/blimp_connection_statistics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698