blob: 3e92bace12225b354aa9bd8fed464bf2746aa2a9 [file] [log] [blame]
Henrik Kjellanderbd0ae452016-02-10 09:53:121/*
kjellander95ed4e62016-02-10 15:54:432 * Copyright 2014 The WebRTC project authors. All Rights Reserved.
Henrik Kjellanderbd0ae452016-02-10 09:53:123 *
kjellander95ed4e62016-02-10 15:54:434 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
Henrik Kjellanderbd0ae452016-02-10 09:53:129 */
10
11// This file contains enums related to IPv4/IPv6 metrics.
12
13#ifndef WEBRTC_API_UMAMETRICS_H_
14#define WEBRTC_API_UMAMETRICS_H_
15
skvladd65e27e2017-01-12 01:50:3016#include "webrtc/base/refcount.h"
17
Henrik Kjellanderbd0ae452016-02-10 09:53:1218namespace webrtc {
19
20// Used to specify which enum counter type we're incrementing in
21// MetricsObserverInterface::IncrementEnumCounter.
22enum PeerConnectionEnumCounterType {
23 kEnumCounterAddressFamily,
24 // For the next 2 counters, we track them separately based on the "first hop"
25 // protocol used by the local candidate. "First hop" means the local candidate
26 // type in the case of non-TURN candidates, and the protocol used to connect
27 // to the TURN server in the case of TURN candidates.
28 kEnumCounterIceCandidatePairTypeUdp,
29 kEnumCounterIceCandidatePairTypeTcp,
30
31 kEnumCounterAudioSrtpCipher,
32 kEnumCounterAudioSslCipher,
33 kEnumCounterVideoSrtpCipher,
34 kEnumCounterVideoSslCipher,
35 kEnumCounterDataSrtpCipher,
36 kEnumCounterDataSslCipher,
zhihuang6f7a7f62016-08-26 18:25:0537 kEnumCounterDtlsHandshakeError,
Honghai Zhangf702e1b2016-10-05 18:47:2238 kEnumCounterIceRegathering,
39 kEnumCounterIceRestart,
Henrik Kjellanderbd0ae452016-02-10 09:53:1240 kPeerConnectionEnumCounterMax
41};
42
43// Currently this contains information related to WebRTC network/transport
44// information.
45
46// The difference between PeerConnectionEnumCounter and
47// PeerConnectionMetricsName is that the "EnumCounter" is only counting the
48// occurrences of events, while "Name" has a value associated with it which is
49// used to form a histogram.
50
51// This enum is backed by Chromium's histograms.xml,
52// chromium/src/tools/metrics/histograms/histograms.xml
53// Existing values cannot be re-ordered and new enums must be added
54// before kBoundary.
55enum PeerConnectionAddressFamilyCounter {
56 kPeerConnection_IPv4,
57 kPeerConnection_IPv6,
58 kBestConnections_IPv4,
59 kBestConnections_IPv6,
60 kPeerConnectionAddressFamilyCounter_Max,
61};
62
63// TODO(guoweis): Keep previous name here until all references are renamed.
64#define kBoundary kPeerConnectionAddressFamilyCounter_Max
65
66// TODO(guoweis): Keep previous name here until all references are renamed.
67typedef PeerConnectionAddressFamilyCounter PeerConnectionUMAMetricsCounter;
68
69// This enum defines types for UMA samples, which will have a range.
70enum PeerConnectionMetricsName {
71 kNetworkInterfaces_IPv4, // Number of IPv4 interfaces.
72 kNetworkInterfaces_IPv6, // Number of IPv6 interfaces.
73 kTimeToConnect, // In milliseconds.
74 kLocalCandidates_IPv4, // Number of IPv4 local candidates.
75 kLocalCandidates_IPv6, // Number of IPv6 local candidates.
76 kPeerConnectionMetricsName_Max
77};
78
79// TODO(guoweis): Keep previous name here until all references are renamed.
80typedef PeerConnectionMetricsName PeerConnectionUMAMetricsName;
81
82// The IceCandidatePairType has the format of
83// <local_candidate_type>_<remote_candidate_type>. It is recorded based on the
84// type of candidate pair used when the PeerConnection first goes to a completed
85// state. When BUNDLE is enabled, only the first transport gets recorded.
86enum IceCandidatePairType {
87 // HostHost is deprecated. It was replaced with the set of types at the bottom
88 // to report private or public host IP address.
89 kIceCandidatePairHostHost,
90 kIceCandidatePairHostSrflx,
91 kIceCandidatePairHostRelay,
92 kIceCandidatePairHostPrflx,
93 kIceCandidatePairSrflxHost,
94 kIceCandidatePairSrflxSrflx,
95 kIceCandidatePairSrflxRelay,
96 kIceCandidatePairSrflxPrflx,
97 kIceCandidatePairRelayHost,
98 kIceCandidatePairRelaySrflx,
99 kIceCandidatePairRelayRelay,
100 kIceCandidatePairRelayPrflx,
101 kIceCandidatePairPrflxHost,
102 kIceCandidatePairPrflxSrflx,
103 kIceCandidatePairPrflxRelay,
104
105 // The following 4 types tell whether local and remote hosts have private or
106 // public IP addresses.
107 kIceCandidatePairHostPrivateHostPrivate,
108 kIceCandidatePairHostPrivateHostPublic,
109 kIceCandidatePairHostPublicHostPrivate,
110 kIceCandidatePairHostPublicHostPublic,
111 kIceCandidatePairMax
112};
113
skvladd65e27e2017-01-12 01:50:30114class MetricsObserverInterface : public rtc::RefCountInterface {
115 public:
116
117 // |type| is the type of the enum counter to be incremented. |counter|
118 // is the particular counter in that type. |counter_max| is the next sequence
119 // number after the highest counter.
120 virtual void IncrementEnumCounter(PeerConnectionEnumCounterType type,
121 int counter,
122 int counter_max) {}
123
124 // This is used to handle sparse counters like SSL cipher suites.
125 // TODO(guoweis): Remove the implementation once the dependency's interface
126 // definition is updated.
127 virtual void IncrementSparseEnumCounter(PeerConnectionEnumCounterType type,
128 int counter) {
129 IncrementEnumCounter(type, counter, 0 /* Ignored */);
130 }
131
132 virtual void AddHistogramSample(PeerConnectionMetricsName type,
133 int value) = 0;
134
135 protected:
136 virtual ~MetricsObserverInterface() {}
137};
138
139typedef MetricsObserverInterface UMAObserver;
140
Henrik Kjellanderbd0ae452016-02-10 09:53:12141} // namespace webrtc
142
143#endif // WEBRTC_API_UMAMETRICS_H_