1 // Copyright 2015 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_ANDROID_TRAFFIC_STATS_H_ 6 #define NET_ANDROID_TRAFFIC_STATS_H_ 7 8 // This file provides functions that interact with TrafficStats APIs that are 9 // provided on Android. 10 11 #include <jni.h> 12 #include <stdint.h> 13 14 #include "net/base/net_export.h" 15 16 namespace net::android::traffic_stats { 17 18 // Returns true if the number of bytes transmitted since device boot is 19 // available and sets |*bytes| to that value. Counts packets across all network 20 // interfaces, and always increases monotonically since device boot. 21 // Statistics are measured at the network layer, so they include both TCP and 22 // UDP usage. |bytes| must not be nullptr. 23 NET_EXPORT bool GetTotalTxBytes(int64_t* bytes); 24 25 // Returns true if the number of bytes received since device boot is 26 // available and sets |*bytes| to that value. Counts packets across all network 27 // interfaces, and always increases monotonically since device boot. 28 // Statistics are measured at the network layer, so they include both TCP and 29 // UDP usage. |bytes| must not be nullptr. 30 NET_EXPORT bool GetTotalRxBytes(int64_t* bytes); 31 32 // Returns true if the number of bytes attributed to caller's UID since device 33 // boot are available and sets |*bytes| to that value. Counts packets across 34 // all network interfaces, and always increases monotonically since device 35 // boot. Statistics are measured at the network layer, so they include both TCP 36 // and UDP usage. |bytes| must not be nullptr. 37 NET_EXPORT bool GetCurrentUidTxBytes(int64_t* bytes); 38 39 // Returns true if the number of bytes attributed to caller's UID since device 40 // boot are available and sets |*bytes| to that value. Counts packets across 41 // all network interfaces, and always increases monotonically since device 42 // boot. Statistics are measured at the network layer, so they include both TCP 43 // and UDP usage. |bytes| must not be nullptr. 44 NET_EXPORT bool GetCurrentUidRxBytes(int64_t* bytes); 45 46 } // namespace net::android::traffic_stats 47 48 #endif // NET_ANDROID_TRAFFIC_STATS_H_ 49