Henrik Kjellander | bd0ae45 | 2016-02-10 09:53:12 | [diff] [blame] | 1 | /* |
kjellander | 95ed4e6 | 2016-02-10 15:54:43 | [diff] [blame] | 2 | * Copyright 2014 The WebRTC project authors. All Rights Reserved. |
Henrik Kjellander | bd0ae45 | 2016-02-10 09:53:12 | [diff] [blame] | 3 | * |
kjellander | 95ed4e6 | 2016-02-10 15:54:43 | [diff] [blame] | 4 | * 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 Kjellander | bd0ae45 | 2016-02-10 09:53:12 | [diff] [blame] | 9 | */ |
| 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 | |
skvlad | d65e27e | 2017-01-12 01:50:30 | [diff] [blame] | 16 | #include "webrtc/base/refcount.h" |
| 17 | |
Henrik Kjellander | bd0ae45 | 2016-02-10 09:53:12 | [diff] [blame] | 18 | namespace webrtc { |
| 19 | |
| 20 | // Used to specify which enum counter type we're incrementing in |
| 21 | // MetricsObserverInterface::IncrementEnumCounter. |
| 22 | enum 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, |
zhihuang | 6f7a7f6 | 2016-08-26 18:25:05 | [diff] [blame] | 37 | kEnumCounterDtlsHandshakeError, |
Honghai Zhang | f702e1b | 2016-10-05 18:47:22 | [diff] [blame] | 38 | kEnumCounterIceRegathering, |
| 39 | kEnumCounterIceRestart, |
Henrik Kjellander | bd0ae45 | 2016-02-10 09:53:12 | [diff] [blame] | 40 | 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. |
| 55 | enum 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. |
| 67 | typedef PeerConnectionAddressFamilyCounter PeerConnectionUMAMetricsCounter; |
| 68 | |
| 69 | // This enum defines types for UMA samples, which will have a range. |
| 70 | enum 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. |
| 80 | typedef 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. |
| 86 | enum 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 | |
skvlad | d65e27e | 2017-01-12 01:50:30 | [diff] [blame] | 114 | class 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 | |
| 139 | typedef MetricsObserverInterface UMAObserver; |
| 140 | |
Henrik Kjellander | bd0ae45 | 2016-02-10 09:53:12 | [diff] [blame] | 141 | } // namespace webrtc |
| 142 | |
| 143 | #endif // WEBRTC_API_UMAMETRICS_H_ |