Fixes metrics collection during CdmEngine close.

This fixes a problem where a CdmEngine instance (and its sessions) could
be closed before its metrics could be collected. The change allows the
wv_content_decryption_module to extract metrics from instances about to
be closed. These are held until reported to the caller.

Test: Manually verified that collection is now occurring correctly. Also
added unit test: wv_cdm_metric_test.

This is a merge from wvgerrit/29069

Change-Id: If82bfd5cae3b72b9d14ab4741424a7ae7cc0a3a6
This commit is contained in:
Adam Stone
2017-06-16 14:00:30 -07:00
parent efad3eea21
commit 457aceb859
11 changed files with 220 additions and 34 deletions

View File

@@ -11,6 +11,7 @@
#include "cdm_identifier.h"
#include "file_store.h"
#include "lock.h"
#include "metrics.pb.h"
#include "timer.h"
#include "wv_cdm_types.h"
@@ -125,7 +126,8 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
// Validate a passed-in service certificate
virtual bool IsValidServiceCertificate(const std::string& certificate);
// Retrieve the serialized metrics from the CDM.
// Retrieve the serialized metrics from CdmEngine and CdmSession instances
// that have been closed.
virtual void GetSerializedMetrics(std::string* serialized_metrics);
private:
@@ -142,6 +144,10 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
// Finds the CdmEngine instance for the given session id, returning NULL if
// not found.
CdmEngine* GetCdmForSessionId(const std::string& session_id);
// Closes CdmEngine instances that don't have any open sessions. Also stores
// metrics data for closed CdmEngine instances.
// Callers must acquire the cdms_lock_ before calling this method.
void CloseCdmsWithoutSessions();
uint32_t GenerateSessionSharingId();
@@ -162,6 +168,9 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
// This contains weak pointers to the CDM instances contained in |cdms_|.
std::map<std::string, CdmEngine*> cdm_by_session_id_;
// The metrics for cdm engines and sessions that have been closed.
drm_metrics::MetricsGroup metrics_;
CORE_DISALLOW_COPY_AND_ASSIGN(WvContentDecryptionModule);
};