network_activity_monitor.h 1.1 KB

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