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