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

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

Issue 1380603005: Revert of Change WebRTC SslCipher to be exposed as number only. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « talk/app/webrtc/fakemetricsobserver.h ('k') | talk/app/webrtc/peerconnection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/fakemetricsobserver.cc
diff --git a/talk/app/webrtc/fakemetricsobserver.cc b/talk/app/webrtc/fakemetricsobserver.cc
index 4a100a079e58f163466b5eed97c1c91209f10adc..9c300ccd60e2ed0913286c9257a260d2630eaafa 100644
--- a/talk/app/webrtc/fakemetricsobserver.cc
+++ b/talk/app/webrtc/fakemetricsobserver.cc
@@ -37,7 +37,10 @@
void FakeMetricsObserver::Reset() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
counters_.clear();
- memset(histogram_samples_, 0, sizeof(histogram_samples_));
+ memset(int_histogram_samples_, 0, sizeof(int_histogram_samples_));
+ for (std::string& type : string_histogram_samples_) {
+ type.clear();
+ }
}
void FakeMetricsObserver::IncrementEnumCounter(
@@ -49,31 +52,43 @@
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(histogram_samples_[type], 0);
- histogram_samples_[type] = value;
+ 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);
}
int FakeMetricsObserver::GetEnumCounter(PeerConnectionEnumCounterType type,
int counter) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- 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;
+ RTC_CHECK(counters_.size() > static_cast<size_t>(type) &&
+ counters_[type].size() > static_cast<size_t>(counter));
+ return counters_[type][counter];
}
-int FakeMetricsObserver::GetHistogramSample(
+int FakeMetricsObserver::GetIntHistogramSample(
PeerConnectionMetricsName type) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- return histogram_samples_[type];
+ return int_histogram_samples_[type];
+}
+
+const std::string& FakeMetricsObserver::GetStringHistogramSample(
+ PeerConnectionMetricsName type) const {
+ RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ return string_histogram_samples_[type];
}
} // namespace webrtc
« no previous file with comments | « talk/app/webrtc/fakemetricsobserver.h ('k') | talk/app/webrtc/peerconnection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698