Add a metric decorator around cdm engine

[ Merge from http://go/wvgerrit/69105 ]

This adds a metric collecting decorator class around cdm engine. This
implementation uses a templated decorator. The decorator enables:

1) Wrapping the CDM Engine methods to capture timing and error
information.
2) Allows use of a mock CDM Engine for testing.

Test: Unit tests. GPlay manual testing and GTS tests.
BUG: http://b/64724336
Change-Id: I5e4a0f552974fab1939bc7ab02719a1f5849cf3f
This commit is contained in:
Adam Stone
2019-01-15 17:25:43 -08:00
parent 1cc4f71975
commit 46eecb6b80
14 changed files with 954 additions and 110 deletions

View File

@@ -26,6 +26,7 @@
namespace wvcdm {
class CdmClientPropertySet;
class CdmEngineFactory;
class CdmSession;
class CryptoEngine;
class UsagePropertySet;
@@ -37,7 +38,6 @@ typedef std::map<CdmKeySetId,
class CdmEngine {
public:
CdmEngine(FileSystem* file_system, const std::string& spoid = EMPTY_SPOID);
virtual ~CdmEngine();
// Session related methods
@@ -316,10 +316,37 @@ class CdmEngine {
// dead lock.
virtual void OnTimerEvent();
virtual metrics::EngineMetrics* GetMetrics() { return &metrics_; }
// Fills the |engine_metrics| parameter with the current snapshot of metrics
// data. Returns true if the metrics data is populated, false otherwise.
// |engine_metrics| is owned by the caller and must not be null.
// The CdmEngine implementation is a placeholder. Just return false.
virtual bool GetMetricsSnapshot(
__attribute__((unused)) drm_metrics::WvCdmMetrics *metrics) {
return false;
}
virtual CdmResponseType ValidateServiceCertificate(const std::string& cert);
// Setter and getter for the |app_package_name| identifier for this instance
// of the CdmEngine. This is used to identify the package name.
virtual void SetAppPackageName(const std::string& app_package_name) {
app_package_name_ = app_package_name;
}
virtual const std::string& GetAppPackageName() {
return app_package_name_;
}
protected:
friend class CdmEngineFactory;
friend class WvCdmEnginePreProvTest;
friend class WvCdmTestBase;
friend class WvGenericOperationsTest;
friend class TestLicenseHolder;
CdmEngine(FileSystem* file_system,
std::shared_ptr<metrics::EngineMetrics> metrics,
const std::string& spoid = EMPTY_SPOID);
private:
// private methods
CdmResponseType OpenSession(
@@ -348,7 +375,8 @@ class CdmEngine {
* ensure that all data has been properly recorded in the group before
* it is published.
*/
metrics::EngineMetrics metrics_;
std::shared_ptr<metrics::EngineMetrics> metrics_;
std::string app_package_name_;
CdmSessionMap session_map_;
CdmReleaseKeySetMap release_key_sets_;