Support GetPropertyByteArray for getting metrics.

Adds support for GetPropertyByteArray to return a serialized set of metrics
to the caller. This should be the last part of the widevine plugin
changes that fix the referenced bug.  More changes are coming on the
MediaDrm side.

This is a merge of wvgerrit/28422

I intend to submit 2048751, 2048750, and 2048509 together.

Bug: 36217927
Test: Added additional unit tests for affected code.
Change-Id: I2618c2be48d7d780127e35f237e2276efd080879
This commit is contained in:
Adam Stone
2017-03-30 11:31:51 -07:00
parent b851dd8cfd
commit a0da1f067b
9 changed files with 85 additions and 32 deletions

View File

@@ -22,10 +22,6 @@ AmiAdapter::~AmiAdapter() {
analytics_item_.selfrecord();
}
metrics::Report* AmiAdapter::NewReport() const {
return new AmiAdapter(analytics_item_.getSessionID());
}
void AmiAdapter::UpdateString(const std::string& metric_id,
const std::string& value) {
analytics_item_.setCString(metric_id.c_str(), value.c_str());

View File

@@ -7,7 +7,7 @@
#include "initialization_data.h"
#include "license.h"
#include "log.h"
#include "metrics_front_end.h"
#include "metrics.pb.h"
#include "properties.h"
#include "service_certificate.h"
#include "wv_cdm_constants.h"
@@ -21,22 +21,10 @@ namespace wvcdm {
Lock WvContentDecryptionModule::session_sharing_id_generation_lock_;
WvContentDecryptionModule::WvContentDecryptionModule() {
// TODO (b/36497276)
// replace call to new AmiAdapter() and remove ami_apdater.*
report_root_ = NULL; // new AmiAdapter();
front_end_ = new metrics::MetricsFrontEnd(report_root_);
metrics::MetricsFrontEnd::OverrideInstance(front_end_);
}
WvContentDecryptionModule::WvContentDecryptionModule() {}
WvContentDecryptionModule::~WvContentDecryptionModule() {
DisablePolicyTimer(true);
metrics::MetricsFrontEnd::OverrideInstance(NULL);
delete front_end_;
delete report_root_;
front_end_ = NULL;
report_root_ = NULL;
}
bool WvContentDecryptionModule::IsSupported(const std::string& init_data_type) {
@@ -406,6 +394,25 @@ bool WvContentDecryptionModule::IsValidServiceCertificate(
NO_ERROR;
}
void WvContentDecryptionModule::GetSerializedMetrics(
std::string* serialized_metrics) {
drm_metrics::MetricsGroup metric_group;
{
AutoLock auto_lock(cdms_lock_);
for (auto it = cdms_.begin(); it != cdms_.end(); it++) {
metrics::EngineMetrics* engine_metrics =
it->second.cdm_engine->GetMetrics();
if (engine_metrics) {
// Serialize the metrics from the engine and any completed sessions.
// Clear the metrics from any completed sessions.
engine_metrics->Serialize(
metric_group.add_metric_sub_group(), true, true);
}
}
}
metric_group.SerializeToString(serialized_metrics);
}
WvContentDecryptionModule::CdmInfo::CdmInfo()
: cdm_engine(new CdmEngine(&file_system)) {}