* Add media_session_usage custom attribute, add attribute to daily query metrics * Add `TestEventRelayObserver`, update media session metric tests * Use more specific values for media session attribute * Address PR feedback
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
// Copyright (c) 2022 The Brave Authors. All rights reserved.
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
// you can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
#ifndef BRAVE_COMPONENTS_P3A_UTILS_BUCKET_H_
|
|
#define BRAVE_COMPONENTS_P3A_UTILS_BUCKET_H_
|
|
|
|
#include <algorithm>
|
|
|
|
#include "base/check.h"
|
|
#include "base/check_op.h"
|
|
#include "base/metrics/histogram_functions.h"
|
|
|
|
namespace p3a_utils {
|
|
|
|
template <std::size_t N>
|
|
int BucketIndex(const int (&buckets)[N], int value) {
|
|
DCHECK_GE(value, 0);
|
|
return std::lower_bound(buckets, std::end(buckets), value) - buckets;
|
|
}
|
|
|
|
template <std::size_t N>
|
|
void RecordToHistogramBucket(const char* histogram_name,
|
|
const int (&buckets)[N],
|
|
int value) {
|
|
DCHECK(histogram_name);
|
|
base::UmaHistogramExactLinear(histogram_name, BucketIndex(buckets, value),
|
|
std::size(buckets) + 1);
|
|
}
|
|
|
|
} // namespace p3a_utils
|
|
|
|
#endif // BRAVE_COMPONENTS_P3A_UTILS_BUCKET_H_
|