Files
android/libwvdrmengine/cdm/metrics/src/counter_metric.cpp
Adam Stone 466ec4e632 Create two new metric types to simplify metrics.
This is part one of a mult-part change to revise some metrics. Several
metrics are currently EventMetric type when they should be a simpler
type.

Test: Added unit tests for the new types. Also, re-ran existing tests.
Verified playback works with Google Play, and re-ran Widevine GTS tests.

Bug: 36220619
Change-Id: I2ec8fc355f66ad4834dd722aacd22541fb9c94ad
2017-08-24 12:19:17 -07:00

34 lines
928 B
C++

// Copyright 2017 Google Inc. All Rights Reserved.
//
// This file contains implementations for the BaseCounterMetric, the base class
// for CounterMetric.
#include "counter_metric.h"
namespace wvcdm {
namespace metrics {
void BaseCounterMetric::Increment(const std::string& field_names_values,
int64_t value) {
AutoLock lock(internal_lock_);
if (value_map_.find(field_names_values) == value_map_.end()) {
value_map_[field_names_values] = 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);
}
}
} // namespace metrics
} // namespace wvcdm