Kaido Kert | 25902c6 | 2024-06-17 17:10:28 -0700 | [diff] [blame^] | 1 | // Copyright 2014 The Chromium Authors |
Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 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 | |
Kaido Kert | 25902c6 | 2024-06-17 17:10:28 -0700 | [diff] [blame^] | 8 | #include <cstdint> |
| 9 | |
Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 10 | #include "net/base/net_export.h" |
Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 11 | |
Kaido Kert | 25902c6 | 2024-06-17 17:10:28 -0700 | [diff] [blame^] | 12 | namespace net::activity_monitor { |
Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 13 | |
Kaido Kert | 25902c6 | 2024-06-17 17:10:28 -0700 | [diff] [blame^] | 14 | // These functions are used to track bytes received from the network across all |
| 15 | // sockets. They are thread-safe. |
Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 16 | // |
| 17 | // There are a few caveats: |
Kaido Kert | 25902c6 | 2024-06-17 17:10:28 -0700 | [diff] [blame^] | 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(); |
Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 28 | |
Kaido Kert | 25902c6 | 2024-06-17 17:10:28 -0700 | [diff] [blame^] | 29 | } // namespace net::activity_monitor |
Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 30 | |
| 31 | #endif // NET_BASE_NETWORK_ACTIVITY_MONITOR_H_ |