These are a set of CLs merged from the wv cdm repo to the android repo. * Enable Cast for Android Things build. Author: Thoren Paulson <thoren@google.com> [ Merge of http://go/wvgerrit/29941 ] Added a path to make_cast_libwvlevel3 for Android Things. Added the new system id to the preprocessor guards in android_keybox.cpp. Guarded the references to stderr in page_allocator.cpp because for some reason they don't get resolved when we link against the resulting library. BUG: 63443584 * Resolve memory leaks in use of OpenSSL. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/32700 ] Use of EVP_CIPHER_CTX requires a call to EVP_CIPHER_CTX_cleanup(). * Memory leak in OpenSSL RSA key handling. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/32621 ] This fixes a range of tests. --gtest_filter="CdmDecrypt*" runs five tests and still loses 5 objects totalling 1320 bytes (down from 6200 bytes). * Unit test and mock OEMCrypto memory leaks. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/32640 ] More memory leak cleanup. All remaining leaks are due to calls to CRYPTO_malloc() without the matching free (i.e., calls into openssl). * Clean up memory leaks in tests. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/32600 ] This is the first pass at cleaning up memory leaks. These leaks were affecting a lot of tests, making it hard to identify more serious leaks. Switch to unique_ptr<> pointers for CdmEngine in generic_crypto_unittest tests for FileSystem object in mock OEMCrypto's CryptoEngine object. * Fix broken tests - linux-only & address sanitizer failures. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/32460 ] Fix broken test: WvCdmEnginePreProvTestStaging.ServiceCertificateInitialNoneTest Fix failures found by address sanitizer: DeviceFilesUsageInfoTest.RetrieveByProviderSessionToken DeviceFilesUsageInfoTest.UpdateUsageInfo NOTE: address sanitizer cannot handle EXPECT_CALL macros containing a call with a Contains matcher as an argument, e.g.: EXPECT_CALL(file, Write(Contains(certificate, wrapped_private_key, 0), Gt(certificate.size() + wrapped_private_key.size()))) The address sanitizer reports a crash, issues a report, and stops. A temporary fix is to replace the "Contains()" argument with "_". * Usage license handling corrections Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/28540 ] Validate that offline licenses that do not contain a provider session token are not handled by the TEE. BUG: 38490468 Test: WV Unit/integration tests, GtsMediaTestCases, WvCdmRequestLicenseTest.ReleaseRetryL3OfflineKeySessionUsageDisabledTest * UsageTableEntry::CopyOldUsageEntry memcpy read out of range. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/32220 ] The function copies the pst from a variable length input vector into a 256 byte character array. But the length argument was a fixed value - MAC_KEY_SIZE. Depending on the actual PST length this can lead to memcpy reading out of bounds or the PST getting truncated. BUG: 71650075 Test: Not currently passing. Will be addressed in a subsequent commit in the chain. Change-Id: I81a4593d7d04d0ef6069ce48d0601b6fbdd85de9
64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
// Copyright 2017 Google Inc. All Rights Reserved.
|
|
//
|
|
// This file contains implementations for the BaseEventMetric.
|
|
|
|
#include "event_metric.h"
|
|
|
|
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& field_names_values,
|
|
double value) {
|
|
AutoLock lock(internal_lock_);
|
|
|
|
Distribution* distribution;
|
|
|
|
if (value_map_.find(field_names_values) == value_map_.end()) {
|
|
distribution = new Distribution();
|
|
value_map_[field_names_values] = distribution;
|
|
} else {
|
|
distribution = value_map_[field_names_values];
|
|
}
|
|
|
|
distribution->Record(value);
|
|
}
|
|
|
|
void BaseEventMetric::Serialize(MetricSerializer* serializer) {
|
|
AutoLock lock(internal_lock_);
|
|
|
|
for (std::map<std::string, Distribution*>::iterator it
|
|
= value_map_.begin(); it != value_map_.end(); it++) {
|
|
serializer->SetInt64(
|
|
metric_name_ + "/count" + it->first,
|
|
it->second->Count());
|
|
serializer->SetDouble(
|
|
metric_name_ + "/mean" + it->first,
|
|
it->second->Mean());
|
|
// Only publish additional information if there was more than one sample.
|
|
if (it->second->Count() > 1) {
|
|
serializer->SetDouble(
|
|
metric_name_ + "/variance" + it->first,
|
|
it->second->Variance());
|
|
serializer->SetDouble(
|
|
metric_name_ + "/min" + it->first,
|
|
it->second->Min());
|
|
serializer->SetDouble(
|
|
metric_name_ + "/max" + it->first,
|
|
it->second->Max());
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace metrics
|
|
} // namespace wvcdm
|
|
|