Fixes reporting of dynamic adapter metrics.

The metrics from the dynamic adapter were not previously being reported.
This change allows them to be reported when all other DRM metrics are
reported.

Bug: 64566432

Test: Unit tests, GTS tests, and Play movies.
Change-Id: I916fb028146fdd04b4cf5bbb5c10ecdaffae6c95
This commit is contained in:
Adam Stone
2017-08-29 11:03:55 -07:00
parent e492811200
commit 4d6cfd414c
5 changed files with 148 additions and 61 deletions

View File

@@ -146,11 +146,6 @@ class CryptoMetrics {
ValueMetric<bool> oemcrypto_supports_usage_table_;
CounterMetric<OEMCryptoResult> oemcrypto_update_usage_table_;
EventMetric<OEMCryptoResult> oemcrypto_wrap_keybox_;
/* Internal OEMCrypto Metrics */
ValueMetric<OEMCryptoInitializationMode> oemcrypto_initialization_mode_;
ValueMetric<uint32_t> oemcrypto_l1_api_version_;
ValueMetric<uint32_t> oemcrypto_l1_min_api_version_;
};
// This class contains session-scoped metrics. All properties and
@@ -196,6 +191,45 @@ class SessionMetrics {
CryptoMetrics crypto_metrics_;
};
// This class contains metrics for the OEMCrypto Dynamic Adapter. They are
// separated from other metrics because they need to be encapsulated in a
// singleton object. This is because the dynamic adapter uses the OEMCrypto
// function signatures and contract and cannot be extended to inject
// dependencies.
//
// Operations for this metrics class are serialized since these particular
// metrics may be accessed by a separate thread during intialize even as
// the metric may be serialized.
class OemCryptoDynamicAdapterMetrics {
public:
explicit OemCryptoDynamicAdapterMetrics();
// Set methods for OEMCrypto metrics.
void SetInitializationMode(OEMCryptoInitializationMode mode);
void SetL1ApiVersion(uint32_t version);
void SetL1MinApiVersion(uint32_t version);
// Serialize the session metrics to the provided |metric_group|.
// |metric_group| is owned by the caller and must not be null.
void Serialize(drm_metrics::MetricsGroup* metric_group);
// Clears the existing metric values.
void Clear();
private:
Lock adapter_lock_;
ValueMetric<OEMCryptoInitializationMode> oemcrypto_initialization_mode_;
ValueMetric<uint32_t> oemcrypto_l1_api_version_;
ValueMetric<uint32_t> oemcrypto_l1_min_api_version_;
};
// This will fetch the singleton instance for dynamic adapter metrics.
// This method is safe only if we use C++ 11. In C++ 11, static function-local
// initialization is guaranteed to be threadsafe. We return the reference to
// avoid non-guaranteed destructor order problems. Effectively, the destructor
// is never run for the created instance.
OemCryptoDynamicAdapterMetrics& GetDynamicAdapterMetricsInstance();
// This class contains engine-scoped metrics. All properties and
// statistics related to operations within the engine, but outside
// the scope of a session are recorded here.