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

Unified Diff: net/base/network_activity_monitor.h

Issue 726673002: Add a new NetworkActivityMonitor to track network activity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NET_EXPORT_PRIVATE Created 6 years, 1 month 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 | « no previous file | net/base/network_activity_monitor.cc » ('j') | net/base/network_activity_monitor.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/network_activity_monitor.h
diff --git a/net/base/network_activity_monitor.h b/net/base/network_activity_monitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..71ef323174182afb1b75798ead613106cb9d68bd
--- /dev/null
+++ b/net/base/network_activity_monitor.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2014 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 NET_BASE_NETWORK_ACTIVITY_MONITOR_H_
+#define NET_BASE_NETWORK_ACTIVITY_MONITOR_H_
+
+#include "base/basictypes.h"
+#include "base/synchronization/lock.h"
+#include "net/base/net_export.h"
+
+namespace net {
+
+namespace test {
+
+class NetworkActivityMonitorPeer;
+
+} // namespace test
+
+// NetworkActivityMonitor tracks network activity across all sockets and
+// provides cumulative statistics about bytes written to and read from
+// the network. It uses locks to ensure thread-safety.
eroman 2014/11/13 22:18:39 I would also emphasize the caveats of what this is
Ryan Hamilton 2014/11/13 23:38:17 Done.
+class NET_EXPORT_PRIVATE NetworkActivityMonitor {
+ public:
+ // Returns the singleton instance of the monitor.
+ static NetworkActivityMonitor* GetInstance();
+
+ void AddBytesRead(uint64 bytes_read);
eroman 2014/11/13 22:18:39 [optional] Consider "Increment" instead of Add
Ryan Hamilton 2014/11/13 23:38:17 Done.
+ void AddBytesWritten(uint64 bytes_written);
+
+ uint64 GetBytesRead();
+ uint64 GetBytesWritten();
+
+ private:
+ friend class test::NetworkActivityMonitorPeer;
eroman 2014/11/13 22:18:39 What about using a friend_test macro? Or at a mini
Ryan Hamilton 2014/11/13 23:38:18 Doesn't the test:: prefix do that? Personally, I'm
eroman 2014/11/14 00:06:15 Ah, I hadn't noticed the test:: prefix!
+
+ NetworkActivityMonitor();
eroman 2014/11/13 22:18:39 Another interesting API for future consideration w
Ryan Hamilton 2014/11/13 23:38:17 Oo! Interesting. That's a good idea. Done. (Though
+ ~NetworkActivityMonitor();
+
+ // Protects bytes_read_.
+ mutable base::Lock bytes_read_lock_;
eroman 2014/11/13 22:18:39 Why is this mutable? Presumably you meant to make
Ryan Hamilton 2014/11/13 23:38:18 Whoops, yes. Done.
+ uint64 bytes_read_;
+
+ // Protects bytes_written_.
+ mutable base::Lock bytes_written_lock_;
eroman 2014/11/13 22:18:39 A single lock to protect all members should suffic
Ryan Hamilton 2014/11/13 23:38:17 Done.
+ uint64 bytes_written_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkActivityMonitor);
+};
+
+} // namespace net
+
+#endif // NET_BASE_NETWORK_ACTIVITY_MONITOR_H_
« no previous file with comments | « no previous file | net/base/network_activity_monitor.cc » ('j') | net/base/network_activity_monitor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698