Refactored metrics to support pull model.
MetricsGroup split into 3 groups, session, engine, and crypto. MetricsFrontEnd and Report removed. This is a merge from wvgerrit/28420 Bug: 36217927 Test: Added unit tests to cover modified code. Change-Id: I2f39f99ce88cc2229d6d1aa9459c67c5b86ccef4
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
#include "clock.h"
|
||||
#include "file_store.h"
|
||||
#include "log.h"
|
||||
#include "metrics_front_end.h"
|
||||
#include "properties.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
@@ -25,9 +24,10 @@ const size_t kKeySetIdLength = 14;
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
CdmSession::CdmSession(FileSystem* file_system) :
|
||||
CdmSession::CdmSession(FileSystem* file_system,
|
||||
metrics::SessionMetrics* metrics) :
|
||||
metrics_(metrics),
|
||||
initialized_(false),
|
||||
crypto_session_(new CryptoSession(&metrics_)),
|
||||
file_handle_(new DeviceFiles(file_system)),
|
||||
license_received_(false),
|
||||
is_offline_(false),
|
||||
@@ -44,6 +44,9 @@ CdmSession::CdmSession(FileSystem* file_system) :
|
||||
usage_entry_number_(0),
|
||||
mock_license_parser_in_use_(false),
|
||||
mock_policy_engine_in_use_(false) {
|
||||
// If metrics was not provided, then use a NULL CryptoMetrics instance, too.
|
||||
crypto_metrics_ = metrics_ == NULL ? NULL : metrics_->GetCryptoMetrics();
|
||||
crypto_session_.reset(new CryptoSession(crypto_metrics_));
|
||||
life_span_.Start();
|
||||
}
|
||||
|
||||
@@ -54,7 +57,10 @@ CdmSession::~CdmSession() {
|
||||
}
|
||||
Properties::RemoveSessionPropertySet(session_id_);
|
||||
|
||||
M_RECORD(&metrics_, cdm_session_life_span_, life_span_.AsMs());
|
||||
if (metrics_) {
|
||||
M_RECORD(metrics_, cdm_session_life_span_, life_span_.AsMs());
|
||||
metrics_->SetCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::Init(
|
||||
@@ -78,16 +84,15 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
}
|
||||
CdmResponseType sts;
|
||||
M_TIME(
|
||||
sts = crypto_session_->Open(
|
||||
requested_security_level_),
|
||||
&metrics_,
|
||||
sts = crypto_session_->Open(requested_security_level_),
|
||||
crypto_metrics_,
|
||||
crypto_session_open_,
|
||||
sts,
|
||||
requested_security_level_);
|
||||
if (NO_ERROR != sts) return sts;
|
||||
M_TIME(
|
||||
security_level_ = crypto_session_->GetSecurityLevel(),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_get_security_level_,
|
||||
security_level_);
|
||||
if (!file_handle_->Init(security_level_)) {
|
||||
@@ -121,7 +126,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
M_TIME(
|
||||
get_client_token_sts = crypto_session_->GetClientToken(
|
||||
&client_token),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_get_token_,
|
||||
get_client_token_sts);
|
||||
if (!get_client_token_sts) {
|
||||
@@ -138,7 +143,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
M_TIME(
|
||||
load_cert_sts = crypto_session_->LoadCertificatePrivateKey(
|
||||
wrapped_key),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_load_certificate_private_key_,
|
||||
load_cert_sts);
|
||||
if(!load_cert_sts) {
|
||||
@@ -157,6 +162,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
|
||||
session_id_ =
|
||||
Properties::AlwaysUseKeySetIds() ? key_set_id_ : GenerateSessionId();
|
||||
metrics_->SetSessionId(session_id_);
|
||||
|
||||
if (session_id_.empty()) {
|
||||
LOGE("CdmSession::Init: empty session ID");
|
||||
@@ -454,7 +460,8 @@ CdmResponseType CdmSession::AddKey(const CdmKeyResponse& key_response) {
|
||||
if (sts != KEY_ADDED) {
|
||||
CdmResponseType sts =
|
||||
usage_table_header_->DeleteEntry(usage_entry_number_,
|
||||
file_handle_.get(), &metrics_);
|
||||
file_handle_.get(),
|
||||
crypto_metrics_);
|
||||
if (sts != NO_ERROR) {
|
||||
LOGW("CdmSession::AddKey: Delete usage entry failed = %d", sts);
|
||||
}
|
||||
@@ -687,10 +694,10 @@ CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
||||
// it, so close and reopen session.
|
||||
CdmResponseType sts;
|
||||
crypto_session_->Close();
|
||||
crypto_session_.reset(new CryptoSession(&metrics_));
|
||||
crypto_session_.reset(new CryptoSession(crypto_metrics_));
|
||||
M_TIME(
|
||||
sts = crypto_session_->Open(requested_security_level_),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_open_,
|
||||
sts,
|
||||
requested_security_level_);
|
||||
@@ -711,7 +718,7 @@ CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
||||
|
||||
return usage_table_header_->DeleteEntry(usage_entry_number,
|
||||
file_handle_.get(),
|
||||
&metrics_);
|
||||
crypto_metrics_);
|
||||
}
|
||||
|
||||
bool CdmSession::IsKeyLoaded(const KeyId& key_id) {
|
||||
@@ -861,7 +868,7 @@ CdmResponseType CdmSession::DeleteMultipleUsageInformation(
|
||||
M_TIME(
|
||||
sts = crypto_session_->DeleteMultipleUsageInformation(
|
||||
provider_session_tokens),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_delete_multiple_usage_information_,
|
||||
sts);
|
||||
return sts;
|
||||
@@ -871,7 +878,7 @@ CdmResponseType CdmSession::UpdateUsageTableInformation() {
|
||||
CdmResponseType sts;
|
||||
M_TIME(
|
||||
sts = crypto_session_->UpdateUsageInformation(),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_update_usage_information_,
|
||||
sts);
|
||||
return sts;
|
||||
@@ -917,7 +924,7 @@ CdmResponseType CdmSession::GenericEncrypt(const std::string& in_buffer,
|
||||
iv,
|
||||
algorithm,
|
||||
out_buffer),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_generic_encrypt_,
|
||||
sts,
|
||||
metrics::Pow2Bucket(in_buffer.size()),
|
||||
@@ -942,7 +949,7 @@ CdmResponseType CdmSession::GenericDecrypt(const std::string& in_buffer,
|
||||
iv,
|
||||
algorithm,
|
||||
out_buffer),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_generic_decrypt_,
|
||||
sts,
|
||||
metrics::Pow2Bucket(in_buffer.size()),
|
||||
@@ -965,7 +972,7 @@ CdmResponseType CdmSession::GenericSign(const std::string& message,
|
||||
key_id,
|
||||
algorithm,
|
||||
signature),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_generic_sign_,
|
||||
sts,
|
||||
metrics::Pow2Bucket(message.size()),
|
||||
@@ -984,7 +991,7 @@ CdmResponseType CdmSession::GenericVerify(const std::string& message,
|
||||
key_id,
|
||||
algorithm,
|
||||
signature),
|
||||
&metrics_,
|
||||
crypto_metrics_,
|
||||
crypto_session_generic_verify_,
|
||||
sts,
|
||||
metrics::Pow2Bucket(message.size()),
|
||||
|
||||
Reference in New Issue
Block a user