1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44

media / filters / hls_stats_reporter.cc [blame]

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/filters/hls_stats_reporter.h"

#include "base/metrics/histogram_functions.h"

namespace media::hls {

HlsStatsReporter::~HlsStatsReporter() = default;

void HlsStatsReporter::SetWouldTaintOrigin(bool tainted) {
  // The first time the tainted origin flag is set, report it.
  if (!would_taint_origin_.value_or(true) && tainted) {
    base::UmaHistogramBoolean("Media.HLS.CrossOriginContent", true);
  }
  would_taint_origin_ = would_taint_origin_.value_or(false) | tainted;
}

void HlsStatsReporter::OnAdaptation(AdaptationReason reason) {
  base::UmaHistogramEnumeration("Media.HLS.Adaptation", reason);
}

void HlsStatsReporter::SetIsLiveContent(bool live_content) {
  // Log only once, after it has been set. Multiple renditions may not know it
  // has already been logged.
  if (!is_live_content_.has_value()) {
    is_live_content_ = live_content;
    base::UmaHistogramBoolean("Media.HLS.LiveContent", *is_live_content_);
  }
}

void HlsStatsReporter::SetIsMultivariantPlaylist(bool is_multivariant) {
  // Log only once, after it has been set. Multiple renditions may not know it
  // has already been logged.
  if (!is_multivariant_.has_value()) {
    is_multivariant_ = is_multivariant;
    base::UmaHistogramBoolean("Media.HLS.MultivariantPlaylist",
                              *is_multivariant_);
  }
}

}  // namespace media::hls