xref: /aosp_15_r20/external/cronet/net/base/network_activity_monitor.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2014 The Chromium Authors
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 <cstdint>
9 
10 #include "net/base/net_export.h"
11 
12 namespace net::activity_monitor {
13 
14 // These functions are used to track bytes received from the network across all
15 // sockets. They are thread-safe.
16 //
17 // There are a few caveats:
18 //  * Bytes received includes only bytes actually received from the network, and
19 //    does not include any bytes read from the the cache.
20 //  * Network activity not initiated directly using chromium sockets won't be
21 //    reflected here (for instance DNS queries issued by getaddrinfo()).
22 //
23 // Free functions are used instead of a singleton, to avoid memory barriers
24 // associated with singleton initialization.
25 void NET_EXPORT_PRIVATE IncrementBytesReceived(uint64_t bytes_received);
26 uint64_t NET_EXPORT_PRIVATE GetBytesReceived();
27 void NET_EXPORT_PRIVATE ResetBytesReceivedForTesting();
28 
29 }  // namespace net::activity_monitor
30 
31 #endif  // NET_BASE_NETWORK_ACTIVITY_MONITOR_H_
32