Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(987)

Unified Diff: talk/app/webrtc/fakemetricsobserver.cc

Issue 1277263002: Add instrumentation to track the IceEndpointType. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: talk/app/webrtc/fakemetricsobserver.cc
diff --git a/talk/app/webrtc/fakemetricsobserver.cc b/talk/app/webrtc/fakemetricsobserver.cc
index 66e1c51f2a4035dd1ea011b78ae19ee2271ff692..86f4f310d55196b567b926ebe5c4e574cca24a1f 100644
--- a/talk/app/webrtc/fakemetricsobserver.cc
+++ b/talk/app/webrtc/fakemetricsobserver.cc
@@ -36,16 +36,26 @@ FakeMetricsObserver::FakeMetricsObserver() {
void FakeMetricsObserver::Reset() {
DCHECK(thread_checker_.CalledOnValidThread());
- memset(counters_, 0, sizeof(counters_));
+ counters_ = std::vector<std::vector<int>>();
memset(int_histogram_samples_, 0, sizeof(int_histogram_samples_));
for (std::string& type : string_histogram_samples_) {
type.clear();
}
}
-void FakeMetricsObserver::IncrementCounter(PeerConnectionMetricsCounter type) {
+void FakeMetricsObserver::IncrementEnumCounter(
+ PeerConnectionEnumCounterType type,
+ int counter,
+ int counter_max) {
DCHECK(thread_checker_.CalledOnValidThread());
- ++counters_[type];
+ if (counters_.size() <= static_cast<size_t>(type)) {
+ counters_.resize(type + 1);
+ }
+ auto& counters = counters_[type];
+ if (counters.size() < static_cast<size_t>(counter_max)) {
+ counters.resize(counter_max);
+ }
+ ++counters[counter];
}
void FakeMetricsObserver::AddHistogramSample(PeerConnectionMetricsName type,
@@ -61,9 +71,11 @@ void FakeMetricsObserver::AddHistogramSample(PeerConnectionMetricsName type,
string_histogram_samples_[type].assign(value);
}
-int FakeMetricsObserver::GetCounter(PeerConnectionMetricsCounter type) const {
+int FakeMetricsObserver::GetEnumCounter(PeerConnectionEnumCounterType type,
+ int counter) const {
DCHECK(thread_checker_.CalledOnValidThread());
- return counters_[type];
+ DCHECK(counters_.size() > type && counters_[type].size() > counter);
+ return counters_[type][counter];
}
int FakeMetricsObserver::GetIntHistogramSample(

Powered by Google App Engine
This is Rietveld 408576698