Files
android/libwvdrmengine/cdm/metrics/include/metric_serialization.h
Adam Stone a34e279d0f 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
2017-06-19 19:37:37 -07:00

47 lines
1.8 KiB
C++

// Copyright 2017 Google Inc. All Rights Reserved.
//
// This file contains the declarations for the Metric class and related
// types.
#ifndef WVCDM_METRICS_METRIC_SERIALIZATION_H_
#define WVCDM_METRICS_METRIC_SERIALIZATION_H_
namespace wvcdm {
namespace metrics {
// The MetricSerializer is implemented by the code that instantiates
// MetricSerializable instances. The caller provides this MetricSerializer
// instance to MetricSerializable::Serialize. In turn, Serialize will make a
// call to Set* for each value to be Serialized. The MetricSerialiable
// implementation may set zero or more values on the MetricSerializer.
class MetricSerializer {
public:
virtual ~MetricSerializer() {};
// The metric_id is the metric name, plus the metric part name, and the
// metric field name/value string. E.g.
// name: "drm/cdm/decrypt/duration"
// part: "mean"
// field name/value string: "{error_code:0&buffer_size:1024}"
// becomes: "drm/cdm/decrypt/duration/mean/{error_code:0&buffer_size:1024}".
virtual void SetString(const std::string& metric_id,
const std::string& value) = 0;
virtual void SetInt32(const std::string& metric_id, int32_t value) = 0;
virtual void SetInt64(const std::string& metric_id, int64_t value) = 0;
virtual void SetDouble(const std::string& metric_id, double value) = 0;
};
// This abstract class merely provides the definition for serializing the value
// of the metric.
class MetricSerializable {
public:
virtual ~MetricSerializable() { }
// Serialize metric values to the MetricSerializer. |serializer| must
// not be null and is owned by the caller.
virtual void Serialize(MetricSerializer* serializer) = 0;
};
} // namespace metrics
} // namespace wvcdm
#endif // WVCDM_METRICS_METRIC_SERIALIZATION_H_