blob: 319e255b04888ea0561138a48a4df1d7cc0469cb [file] [log] [blame]
Kaido Kert25902c62024-06-17 17:10:28 -07001// Copyright 2014 The Chromium Authors
Andrew Top0d1858f2019-05-15 22:01:47 -07002// 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 Kert25902c62024-06-17 17:10:28 -07008#include <cstdint>
9
Andrew Top0d1858f2019-05-15 22:01:47 -070010#include "net/base/net_export.h"
Andrew Top0d1858f2019-05-15 22:01:47 -070011
Kaido Kert25902c62024-06-17 17:10:28 -070012namespace net::activity_monitor {
Andrew Top0d1858f2019-05-15 22:01:47 -070013
Kaido Kert25902c62024-06-17 17:10:28 -070014// These functions are used to track bytes received from the network across all
15// sockets. They are thread-safe.
Andrew Top0d1858f2019-05-15 22:01:47 -070016//
17// There are a few caveats:
Kaido Kert25902c62024-06-17 17:10:28 -070018// * 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.
25void NET_EXPORT_PRIVATE IncrementBytesReceived(uint64_t bytes_received);
26uint64_t NET_EXPORT_PRIVATE GetBytesReceived();
27void NET_EXPORT_PRIVATE ResetBytesReceivedForTesting();
Andrew Top0d1858f2019-05-15 22:01:47 -070028
Kaido Kert25902c62024-06-17 17:10:28 -070029} // namespace net::activity_monitor
Andrew Top0d1858f2019-05-15 22:01:47 -070030
31#endif // NET_BASE_NETWORK_ACTIVITY_MONITOR_H_