blob: 866e6b7ae46f76840baed8f42fe753b82a5435a6 [file] [log] [blame]
tbansal59a1ddc2015-09-14 17:35:011// 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
16namespace net {
17
18namespace android {
19
20namespace 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.
27NET_EXPORT bool GetTotalTxBytes(int64_t* bytes);
28
tbansal410041832015-09-28 21:19:1729// 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.
34NET_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.
41NET_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.
48NET_EXPORT bool GetCurrentUidRxBytes(int64_t* bytes);
49
tbansal59a1ddc2015-09-14 17:35:0150} // namespace traffic_stats
51
52} // namespace android
53
54} // namespace net
55
56#endif // NET_ANDROID_TRAFFIC_STATS_H_