1 // Copyright 2015 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 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 { 17 18 namespace android { 19 20 namespace traffic_stats { 21 22 // Returns true if the number of bytes transmitted since device boot is 23 // available and sets |*bytes| to that value. Counts packets across all network 24 // interfaces, and always increases monotonically since device boot. 25 // Statistics are measured at the network layer, so they include both TCP and 26 // UDP usage. |bytes| must not be nullptr. 27 NET_EXPORT bool GetTotalTxBytes(int64_t* bytes); 28 29 // Returns true if the number of bytes received since device boot is 30 // available and sets |*bytes| to that value. Counts packets across all network 31 // interfaces, and always increases monotonically since device boot. 32 // Statistics are measured at the network layer, so they include both TCP and 33 // UDP usage. |bytes| must not be nullptr. 34 NET_EXPORT bool GetTotalRxBytes(int64_t* bytes); 35 36 // Returns true if the number of bytes attributed to caller's UID since device 37 // boot are available and sets |*bytes| to that value. Counts packets across 38 // all network interfaces, and always increases monotonically since device 39 // boot. Statistics are measured at the network layer, so they include both TCP 40 // and UDP usage. |bytes| must not be nullptr. 41 NET_EXPORT bool GetCurrentUidTxBytes(int64_t* bytes); 42 43 // Returns true if the number of bytes attributed to caller's UID since device 44 // boot are available and sets |*bytes| to that value. Counts packets across 45 // all network interfaces, and always increases monotonically since device 46 // boot. Statistics are measured at the network layer, so they include both TCP 47 // and UDP usage. |bytes| must not be nullptr. 48 NET_EXPORT bool GetCurrentUidRxBytes(int64_t* bytes); 49 50 } // namespace traffic_stats 51 52 } // namespace android 53 54 } // namespace net 55 56 #endif // NET_ANDROID_TRAFFIC_STATS_H_ 57