Updated copyright notice and cleaned up includes.
[ Merge of http://go/wvgerrit/137810 ] Bug: 204946540 Test: Metric unit tests Change-Id: I78f839fafd27604a2bb78c04d587c40919c5372d
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
// Copyright 2018 Google Inc. All Rights Reserved.
|
||||
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// This file contains the declarations for the EventMetric class and related
|
||||
// types.
|
||||
#ifndef WVCDM_METRICS_ATTRIBUTE_HANDLER_H_
|
||||
#define WVCDM_METRICS_ATTRIBUTE_HANDLER_H_
|
||||
#include <string>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "field_tuples.h"
|
||||
#include "log.h"
|
||||
#include "pow2bucket.h"
|
||||
#include "value_metric.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// This method is used to set the value of a single proto field.
|
||||
// Specializations handle setting each value.
|
||||
template <int I, typename F>
|
||||
@@ -47,7 +44,6 @@ class AttributeHandler {
|
||||
return serialized_attributes;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
#endif // WVCDM_METRICS_ATTRIBUTE_HANDLER_H_
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// This file contains the declarations for the Metric class and related
|
||||
// types.
|
||||
#ifndef WVCDM_METRICS_COUNTER_METRIC_H_
|
||||
#define WVCDM_METRICS_COUNTER_METRIC_H_
|
||||
|
||||
#include <cstdarg>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "attribute_handler.h"
|
||||
#include "field_tuples.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
class CounterMetricTest;
|
||||
|
||||
// This base class provides the common defintion used by all templated
|
||||
@@ -144,8 +144,6 @@ inline void CounterMetric<I1, F1, I2, F2, I3, F3, I4, F4>::ToProto(
|
||||
new_counter->set_count(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_COUNTER_METRIC_H_
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// This file contains the definition of a Distribution class which computes
|
||||
// the distribution values of a series of samples.
|
||||
@@ -10,7 +12,6 @@
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// The Distribution class holds statistics about a series of values that the
|
||||
// client provides via the Record method. A caller will call Record once for
|
||||
// each of the values in a series. The Distribution instance will calculate the
|
||||
@@ -46,8 +47,6 @@ class Distribution {
|
||||
float mean_;
|
||||
double sum_squared_deviation_;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_DISTRIBUTION_H_
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// This file contains the declarations for the EventMetric class and related
|
||||
// types.
|
||||
#ifndef WVCDM_METRICS_EVENT_METRIC_H_
|
||||
#define WVCDM_METRICS_EVENT_METRIC_H_
|
||||
|
||||
#include <cstdarg>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "attribute_handler.h"
|
||||
#include "distribution.h"
|
||||
#include "field_tuples.h"
|
||||
#include "log.h"
|
||||
#include "pow2bucket.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
class EventMetricTest;
|
||||
|
||||
// This base class provides the common defintion used by all templated
|
||||
@@ -166,8 +164,6 @@ inline void EventMetric<I1, F1, I2, F2, I3, F3, I4, F4>::ToProto(
|
||||
SetDistributionValues(*it->second, new_metric);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_EVENT_METRIC_H_
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// This file contains the helper classes and methods for using field tuples
|
||||
// used by metrics classes to record variations of a single metric.
|
||||
#ifndef WVCDM_METRICS_FIELD_TUPLES_H_
|
||||
#define WVCDM_METRICS_FIELD_TUPLES_H_
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
namespace util {
|
||||
|
||||
// TODO(blueeyes): Change to use C++ 11 support for variadic template args.
|
||||
// The C++ 03 pattern is no longer needed since we require C++11. b/68766426.
|
||||
|
||||
@@ -23,9 +22,7 @@ struct Unused {
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_FIELD_TUPLES_H_
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
// Copyright 2016 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// This file contains definitions for metrics being collected throughout the
|
||||
// CDM.
|
||||
|
||||
#ifndef WVCDM_METRICS_METRICS_GROUP_H_
|
||||
#define WVCDM_METRICS_METRICS_GROUP_H_
|
||||
|
||||
#ifndef WVCDM_METRICS_METRICS_COLLECTIONS_H_
|
||||
#define WVCDM_METRICS_METRICS_COLLECTIONS_H_
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "counter_metric.h"
|
||||
@@ -58,9 +61,7 @@
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
namespace {
|
||||
|
||||
// Short name definitions to ease AttributeHandler definitions.
|
||||
// Internal namespace to help simplify declarations.
|
||||
const int kErrorCodeFieldNumber =
|
||||
@@ -88,8 +89,7 @@ const int kKeyRequestTypeFieldNumber =
|
||||
::drm_metrics::Attributes::kKeyRequestTypeFieldNumber;
|
||||
const int kLicenseTypeFieldNumber =
|
||||
::drm_metrics::Attributes::kLicenseTypeFieldNumber;
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
|
||||
// The maximum number of completed sessions that can be stored. More than this
|
||||
// will cause some metrics to be discarded.
|
||||
@@ -292,7 +292,7 @@ class CryptoMetrics {
|
||||
oemcrypto_load_provisioning_;
|
||||
ValueMetric<uint32_t> oemcrypto_minor_api_version_;
|
||||
ValueMetric<uint32_t> oemcrypto_maximum_usage_table_header_size_;
|
||||
};
|
||||
}; // class CryptoMetrics
|
||||
|
||||
// This class contains session-scoped metrics. All properties and
|
||||
// statistics related to operations within a single session are
|
||||
@@ -350,7 +350,7 @@ class SessionMetrics {
|
||||
CdmSessionId session_id_;
|
||||
bool completed_;
|
||||
CryptoMetrics crypto_metrics_;
|
||||
};
|
||||
}; // class SessionMetrics
|
||||
|
||||
// This class contains metrics for the OEMCrypto Dynamic Adapter. They are
|
||||
// separated from other metrics because they need to be encapsulated in a
|
||||
@@ -389,7 +389,7 @@ class OemCryptoDynamicAdapterMetrics {
|
||||
previous_oemcrypto_initialization_failure_;
|
||||
ValueMetric<uint32_t> oemcrypto_l1_api_version_;
|
||||
ValueMetric<uint32_t> oemcrypto_l1_min_api_version_;
|
||||
};
|
||||
}; // class OemCryptoDynamicAdapterMetrics
|
||||
|
||||
// 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
|
||||
@@ -494,9 +494,7 @@ class EngineMetrics {
|
||||
|
||||
void SerializeEngineMetrics(
|
||||
drm_metrics::WvCdmMetrics::EngineMetrics* engine_metrics) const;
|
||||
};
|
||||
|
||||
}; // class EngineMetrics
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_METRICS_GROUP_H_
|
||||
#endif // WVCDM_METRICS_METRICS_COLLECTIONS_H_
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright 2018 Google Inc. All Rights Reserved.
|
||||
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// This file contains the declaration of the Pow2Bucket class which
|
||||
// is a convenient way to bucketize sampled values into powers of 2.
|
||||
#ifndef WVCDM_METRICS_POW2BUCKET_H_
|
||||
#define WVCDM_METRICS_POW2BUCKET_H_
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// This class converts the size_t value into the highest power of two
|
||||
// below the value. E.g. for 7, the value is 4. For 11, the value is 8.
|
||||
// This class is intended to simplify the use of EventMetric Fields that may
|
||||
@@ -43,8 +43,6 @@ class Pow2Bucket {
|
||||
|
||||
size_t value_;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_POW2BUCKET_H_
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
#ifndef WVCDM_METRICS_TIMER_METRIC_H_
|
||||
#define WVCDM_METRICS_TIMER_METRIC_H_
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
class TimerMetric {
|
||||
public:
|
||||
// Constructs a new TimerMetric.
|
||||
@@ -28,7 +29,6 @@ class TimerMetric {
|
||||
std::chrono::time_point<std::chrono::steady_clock> start_;
|
||||
bool is_started_;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
#endif
|
||||
#endif // WVCDM_METRICS_TIMER_METRIC_H_
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// This file contains the declarations for the Metric class and related
|
||||
// types.
|
||||
#ifndef WVCDM_METRICS_VALUE_METRIC_H_
|
||||
#define WVCDM_METRICS_VALUE_METRIC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
@@ -13,14 +15,11 @@
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// Internal namespace for helper methods.
|
||||
namespace impl {
|
||||
|
||||
// Helper function for setting a value in the proto.
|
||||
template <typename T>
|
||||
void SetValue(drm_metrics::ValueMetric* value_proto, const T& value);
|
||||
|
||||
} // namespace impl
|
||||
|
||||
// The ValueMetric class supports storing a single, overwritable value or an
|
||||
@@ -118,9 +117,7 @@ class ValueMetric {
|
||||
* in const methods.
|
||||
*/
|
||||
mutable std::mutex internal_lock_;
|
||||
};
|
||||
|
||||
}; // class ValueMetric
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_VALUE_METRIC_H_
|
||||
|
||||
Reference in New Issue
Block a user