Fixes widevine metrics proto serialization

Changes to a much more efficient and more reusable protobuf format for
metrics.

Test: Widevine tests, Google Play and MediaDrm CTS test.
Bug: 73724218

Change-Id: I3299051d7a16bcd7758c8f272415ca40e10c1313
This commit is contained in:
Adam Stone
2018-02-20 19:12:02 -08:00
parent efc008c5a1
commit b19f0d106f
25 changed files with 1587 additions and 1867 deletions

View File

@@ -5,29 +5,21 @@
#include "counter_metric.h"
#include "metrics.pb.h"
namespace wvcdm {
namespace metrics {
void BaseCounterMetric::Increment(const std::string& field_names_values,
void BaseCounterMetric::Increment(const std::string &counter_key,
int64_t value) {
AutoLock lock(internal_lock_);
if (value_map_.find(field_names_values) == value_map_.end()) {
value_map_[field_names_values] = value;
if (value_map_.find(counter_key) == value_map_.end()) {
value_map_[counter_key] = value;
} else {
value_map_[field_names_values] = value_map_[field_names_values] + value;
}
}
void BaseCounterMetric::Serialize(MetricSerializer* serializer) {
AutoLock lock(internal_lock_);
for (std::map<std::string, int64_t>::iterator it
= value_map_.begin(); it != value_map_.end(); it++) {
serializer->SetInt64(metric_name_ + "/count" + it->first, it->second);
value_map_[counter_key] = value_map_[counter_key] + value;
}
}
} // namespace metrics
} // namespace wvcdm