Files
android/libwvdrmengine/cdm/metrics/src/event_metric.cpp
Adam Stone b19f0d106f 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
2018-03-22 16:36:18 -07:00

38 lines
841 B
C++

// Copyright 2017 Google Inc. All Rights Reserved.
//
// This file contains implementations for the BaseEventMetric.
#include "event_metric.h"
using ::google::protobuf::RepeatedPtrField;
namespace wvcdm {
namespace metrics {
BaseEventMetric::~BaseEventMetric() {
AutoLock lock(internal_lock_);
for (std::map<std::string, Distribution *>::iterator it = value_map_.begin();
it != value_map_.end(); it++) {
delete it->second;
}
}
void BaseEventMetric::Record(const std::string &key, double value) {
AutoLock lock(internal_lock_);
Distribution *distribution;
if (value_map_.find(key) == value_map_.end()) {
distribution = new Distribution();
value_map_[key] = distribution;
} else {
distribution = value_map_[key];
}
distribution->Record(value);
}
} // namespace metrics
} // namespace wvcdm