Index: talk/app/webrtc/fakemetricsobserver.cc |
diff --git a/talk/app/webrtc/fakemetricsobserver.cc b/talk/app/webrtc/fakemetricsobserver.cc |
index 9c300ccd60e2ed0913286c9257a260d2630eaafa..4a100a079e58f163466b5eed97c1c91209f10adc 100644 |
--- a/talk/app/webrtc/fakemetricsobserver.cc |
+++ b/talk/app/webrtc/fakemetricsobserver.cc |
@@ -37,10 +37,7 @@ FakeMetricsObserver::FakeMetricsObserver() { |
void FakeMetricsObserver::Reset() { |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
counters_.clear(); |
- memset(int_histogram_samples_, 0, sizeof(int_histogram_samples_)); |
- for (std::string& type : string_histogram_samples_) { |
- type.clear(); |
- } |
+ memset(histogram_samples_, 0, sizeof(histogram_samples_)); |
} |
void FakeMetricsObserver::IncrementEnumCounter( |
@@ -52,43 +49,31 @@ void FakeMetricsObserver::IncrementEnumCounter( |
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, |
int value) { |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
- RTC_DCHECK_EQ(int_histogram_samples_[type], 0); |
- int_histogram_samples_[type] = value; |
-} |
- |
-void FakeMetricsObserver::AddHistogramSample(PeerConnectionMetricsName type, |
- const std::string& value) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
- string_histogram_samples_[type].assign(value); |
+ RTC_DCHECK_EQ(histogram_samples_[type], 0); |
+ histogram_samples_[type] = value; |
} |
int FakeMetricsObserver::GetEnumCounter(PeerConnectionEnumCounterType type, |
int counter) const { |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
- RTC_CHECK(counters_.size() > static_cast<size_t>(type) && |
- counters_[type].size() > static_cast<size_t>(counter)); |
- return counters_[type][counter]; |
-} |
- |
-int FakeMetricsObserver::GetIntHistogramSample( |
- PeerConnectionMetricsName type) const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
- return int_histogram_samples_[type]; |
+ RTC_CHECK(counters_.size() > static_cast<size_t>(type)); |
+ const auto& it = counters_[type].find(counter); |
+ if (it == counters_[type].end()) { |
+ return 0; |
+ } |
+ return it->second; |
} |
-const std::string& FakeMetricsObserver::GetStringHistogramSample( |
+int FakeMetricsObserver::GetHistogramSample( |
PeerConnectionMetricsName type) const { |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
- return string_histogram_samples_[type]; |
+ return histogram_samples_[type]; |
} |
} // namespace webrtc |