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:
Alex Dale
2021-11-03 17:28:00 -07:00
parent 21a021e800
commit 1b95db51f1
23 changed files with 112 additions and 163 deletions

View File

@@ -1,15 +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 implementations for the AttributeHandler.
#include "attribute_handler.h"
#include "OEMCryptoCENC.h"
#include "field_tuples.h"
#include "pow2bucket.h"
#include "wv_cdm_types.h"
namespace wvcdm {
namespace metrics {
//
// Specializations for setting attribute fields.
//
@@ -106,6 +109,5 @@ void SetAttributeField<drm_metrics::Attributes::kErrorCodeFieldNumber, int>(
const int& cdm_error, drm_metrics::Attributes* attributes) {
attributes->set_error_code(cdm_error);
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,15 +1,14 @@
// 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 implementations for the BaseCounterMetric, the base class
// for CounterMetric.
#include "counter_metric.h"
#include "wv_metrics.pb.h"
namespace wvcdm {
namespace metrics {
void BaseCounterMetric::Increment(const std::string& counter_key,
int64_t value) {
std::unique_lock<std::mutex> lock(internal_lock_);
@@ -20,6 +19,5 @@ void BaseCounterMetric::Increment(const std::string& counter_key,
value_map_[counter_key] = value_map_[counter_key] + value;
}
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -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 definitions for the Distribution class members.
@@ -8,7 +10,6 @@
namespace wvcdm {
namespace metrics {
Distribution::Distribution()
: count_(0ULL),
min_(FLT_MAX),
@@ -26,6 +27,5 @@ void Distribution::Record(float value) {
min_ = min_ < value ? min_ : value;
max_ = max_ > value ? max_ : value;
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,17 +1,14 @@
// 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 implementations for the BaseEventMetric.
#include "event_metric.h"
using ::google::protobuf::RepeatedPtrField;
namespace wvcdm {
namespace metrics {
BaseEventMetric::~BaseEventMetric() {
std::unique_lock<std::mutex> lock(internal_lock_);
for (std::map<std::string, Distribution*>::iterator it = value_map_.begin();
it != value_map_.end(); it++) {
delete it->second;
@@ -20,9 +17,7 @@ BaseEventMetric::~BaseEventMetric() {
void BaseEventMetric::Record(const std::string& key, double value) {
std::unique_lock<std::mutex> lock(internal_lock_);
Distribution* distribution;
if (value_map_.find(key) == value_map_.end()) {
distribution = new Distribution();
value_map_[key] = distribution;
@@ -32,6 +27,5 @@ void BaseEventMetric::Record(const std::string& key, double value) {
distribution->Record(value);
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,5 +1,6 @@
// 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.
#include "metrics_collections.h"
#include <algorithm>
@@ -7,13 +8,13 @@
#include "log.h"
#include "wv_metrics.pb.h"
namespace wvcdm {
namespace metrics {
using ::drm_metrics::Attributes;
using ::drm_metrics::WvCdmMetrics;
using ::google::protobuf::RepeatedPtrField;
using ::wvcdm::metrics::EventMetric;
namespace {
// Helper struct for comparing session ids.
struct CompareSessionIds {
const std::string& target_;
@@ -25,11 +26,7 @@ struct CompareSessionIds {
return metrics->GetSessionId() == target_;
}
};
} // anonymous namespace
namespace wvcdm {
namespace metrics {
} // namespace
void CryptoMetrics::Serialize(
WvCdmMetrics::CryptoMetrics* crypto_metrics) const {
@@ -458,6 +455,5 @@ void EngineMetrics::SerializeEngineMetrics(
crypto_metrics_.Serialize(engine_metrics->mutable_crypto_metrics());
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,8 +1,10 @@
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
#include "timer_metric.h"
namespace wvcdm {
namespace metrics {
void TimerMetric::Start() {
start_ = clock_.now();
is_started_ = true;
@@ -17,6 +19,5 @@ double TimerMetric::AsMs() const {
double TimerMetric::AsUs() const {
return (clock_.now() - start_) / std::chrono::microseconds(1);
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,11 +1,9 @@
// 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 specializations for helper methods for the
// ValueMetric class.
#include <stdint.h>
#include <string>
#include "value_metric.h"
#include "OEMCryptoCENC.h"
@@ -14,9 +12,7 @@
namespace wvcdm {
namespace metrics {
namespace impl {
template <>
void SetValue<int>(drm_metrics::ValueMetric* value_proto, const int& value) {
value_proto->set_int_value(value);
@@ -106,7 +102,6 @@ void SetValue<std::string>(drm_metrics::ValueMetric* value_proto,
const std::string& value) {
value_proto->set_string_value(value);
}
} // namespace impl
} // namespace metrics
} // namespace wvcdm

View File

@@ -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 a proto definition for serialization of metrics data.
//
@@ -15,10 +17,7 @@ option optimize_for = LITE_RUNTIME;
// want to count all of the operations with a give error code.
message Attributes {
// Reserved for compatibility with logging proto.
// TODO(blueeyes): The reserved keyword is not supported in the older version
// of protoc in the CE CDM third_party directory. Uncomment the reserved
// line when we upgrade. b/67016366.
// reserved 8, 10 to 13;
reserved 8, 10 to 13;
// The error code. See CdmResponseType in wv_cdm_types.h
optional int32 error_code = 1;