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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014 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 #ifndef NET_BASE_NETWORK_ACTIVITY_MONITOR_H_
6 #define NET_BASE_NETWORK_ACTIVITY_MONITOR_H_
7
8 #include "base/basictypes.h"
9 #include "base/synchronization/lock.h"
10 #include "net/base/net_export.h"
11
12 namespace net {
13
14 namespace test {
15
16 class NetworkActivityMonitorPeer;
17
18 } // namespace test
19
20 // NetworkActivityMonitor tracks network activity across all sockets and
21 // provides cumulative statistics about bytes written to and read from
22 // 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.
23 class NET_EXPORT_PRIVATE NetworkActivityMonitor {
24 public:
25 // Returns the singleton instance of the monitor.
26 static NetworkActivityMonitor* GetInstance();
27
28 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.
29 void AddBytesWritten(uint64 bytes_written);
30
31 uint64 GetBytesRead();
32 uint64 GetBytesWritten();
33
34 private:
35 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!
36
37 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
38 ~NetworkActivityMonitor();
39
40 // Protects bytes_read_.
41 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.
42 uint64 bytes_read_;
43
44 // Protects bytes_written_.
45 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.
46 uint64 bytes_written_;
47
48 DISALLOW_COPY_AND_ASSIGN(NetworkActivityMonitor);
49 };
50
51 } // namespace net
52
53 #endif // NET_BASE_NETWORK_ACTIVITY_MONITOR_H_
OLDNEW
« 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