chromium/components/metrics/metrics_service_client.cc

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

#include "components/metrics/metrics_service_client.h"

#include <algorithm>
#include <string>

#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "components/metrics/metrics_features.h"
#include "components/metrics/metrics_switches.h"
#include "components/metrics/url_constants.h"
#include "metrics_service_client.h"

namespace metrics {

namespace {

// The number of initial/ongoing logs to persist in the queue before logs are
// dropped.
// Note: Both the count threshold and the bytes threshold (see
// `kLogBytesTrimThreshold` below) must be reached for logs to be
// dropped/trimmed.
//
// Note that each ongoing log may be pretty large, since "initial" logs must
// first be sent before any ongoing logs are transmitted. "Initial" logs will
// not be sent if a user is offline. As a result, the current ongoing log will
// accumulate until the "initial" log can be transmitted. We don't want to save
// too many of these mega-logs (this should be capped by
// kLogBytesTrimThreshold).
//
// A "standard shutdown" will create a small log, including just the data that
// was not yet been transmitted, and that is normal (to have exactly one
// ongoing log at startup).
//
// Refer to //components/metrics/unsent_log_store.h for more details on when
// logs are dropped.
const base::FeatureParam<int> kInitialLogCountTrimThreshold{};
const base::FeatureParam<int> kOngoingLogCountTrimThreshold{};

// The number bytes of the queue to be persisted before logs are dropped. This
// will be applied to both log queues (initial/ongoing). This ensures that a
// reasonable amount of history will be stored even if there is a long series of
// very small logs.
// Note: Both the count threshold (see `kInitialLogCountTrimThreshold` and
// `kOngoingLogCountTrimThreshold` above) and the bytes threshold must be
// reached for logs to be dropped/trimmed.
//
// Refer to //components/metrics/unsent_log_store.h for more details on when
// logs are dropped.
const base::FeatureParam<int> kLogBytesTrimThreshold{};

// If an initial/ongoing metrics log upload fails, and the transmission is over
// this byte count, then we will discard the log, and not try to retransmit it.
// We also don't persist the log to the prefs for transmission during the next
// chrome session if this limit is exceeded.
const base::FeatureParam<int> kMaxInitialLogSizeBytes{};
const base::FeatureParam<int> kMaxOngoingLogSizeBytes{};

// The minimum time in seconds between consecutive metrics report uploads.
constexpr int kMetricsUploadIntervalSecMinimum =;

}  // namespace

MetricsServiceClient::MetricsServiceClient() = default;

MetricsServiceClient::~MetricsServiceClient() = default;

ukm::UkmService* MetricsServiceClient::GetUkmService() {}

IdentifiabilityStudyState*
MetricsServiceClient::GetIdentifiabilityStudyState() {}

structured::StructuredMetricsService*
MetricsServiceClient::GetStructuredMetricsService() {}

bool MetricsServiceClient::ShouldUploadMetricsForUserId(uint64_t user_id) {}

GURL MetricsServiceClient::GetMetricsServerUrl() {}

GURL MetricsServiceClient::GetInsecureMetricsServerUrl() {}

base::TimeDelta MetricsServiceClient::GetUploadInterval() {}

bool MetricsServiceClient::ShouldStartUpFastForTesting() const {}

bool MetricsServiceClient::IsReportingPolicyManaged() {}

EnableMetricsDefault MetricsServiceClient::GetMetricsReportingDefaultState() {}

bool MetricsServiceClient::IsOnCellularConnection() {}

bool MetricsServiceClient::IsUkmAllowedForAllProfiles() {}

bool MetricsServiceClient::AreNotificationListenersEnabledOnAllProfiles() {}

std::string MetricsServiceClient::GetAppPackageNameIfLoggable() {}

std::string MetricsServiceClient::GetUploadSigningKey() {}

bool MetricsServiceClient::ShouldResetClientIdsOnClonedInstall() {}

base::CallbackListSubscription
MetricsServiceClient::AddOnClonedInstallDetectedCallback(
    base::OnceClosure callback) {}

MetricsLogStore::StorageLimits MetricsServiceClient::GetStorageLimits() const {}

void MetricsServiceClient::SetUpdateRunningServicesCallback(
    const base::RepeatingClosure& callback) {}

void MetricsServiceClient::UpdateRunningServices() {}

bool MetricsServiceClient::IsMetricsReportingForceEnabled() const {}

std::optional<bool> MetricsServiceClient::GetCurrentUserMetricsConsent() const {}

std::optional<std::string> MetricsServiceClient::GetCurrentUserId() const {}

}  // namespace metrics