This change is the complete Widevine metrics system. It will measure and record runtime information about what is happening in the CDM - such as errors and throughput. Bug: 33745339 Bug: 26027857 Change-Id: Ic9a82074f1e2b72c72d751b235f8ae361232787d
57 lines
1.1 KiB
C++
57 lines
1.1 KiB
C++
// Copyright 2016 Google Inc. All Rights Reserved.
|
|
|
|
#ifndef WVCDM_METRICS_METRICS_FRONT_END_H_
|
|
#define WVCDM_METRICS_METRICS_FRONT_END_H_
|
|
|
|
#include <map>
|
|
|
|
#include "report.h"
|
|
#include "timer_metric.h" /* needed for the macro */
|
|
|
|
namespace wvcdm {
|
|
namespace metrics {
|
|
|
|
class MetricsFrontEnd {
|
|
|
|
public:
|
|
|
|
MetricsFrontEnd(Report* root);
|
|
|
|
MetricNotification* CreateSubscriber();
|
|
|
|
static MetricsFrontEnd& Instance();
|
|
static void OverrideInstance(MetricsFrontEnd* instance);
|
|
|
|
private:
|
|
|
|
static MetricsFrontEnd* instance_;
|
|
|
|
Report* root_;
|
|
|
|
/* Disallow copy and assign. */
|
|
MetricsFrontEnd(const MetricsFrontEnd&);
|
|
void operator=(const MetricsFrontEnd&);
|
|
};
|
|
|
|
} // namespace metrics
|
|
} // namespace wvcdm
|
|
|
|
#define MFE wvcdm::metrics::MetricsFrontEnd::Instance()
|
|
|
|
#define M_RECORD(GROUP, METRIC, ...) \
|
|
if ( GROUP ) { \
|
|
( GROUP ) -> METRIC . Record( __VA_ARGS__ ); \
|
|
}
|
|
|
|
#define M_TIME(CALL, GROUP, METRIC, ...) \
|
|
if ( GROUP ) { \
|
|
wvcdm::metrics::TimerMetric timer; \
|
|
timer.Start(); \
|
|
CALL; \
|
|
( GROUP ) -> METRIC . Record(timer.AsUs(), ##__VA_ARGS__ ); \
|
|
} else { \
|
|
CALL; \
|
|
}
|
|
|
|
#endif
|