chromium/components/metrics/unsent_log_store.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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/metrics/unsent_log_store.h"

#include <cmath>
#include <memory>
#include <string>
#include <string_view>
#include <utility>

#include "base/base64.h"
#include "base/hash/sha1.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/timer/elapsed_timer.h"
#include "components/metrics/metrics_features.h"
#include "components/metrics/unsent_log_store_metrics.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "crypto/hmac.h"
#include "third_party/zlib/google/compression_utils.h"

namespace metrics {

namespace {

const char kLogHashKey[] =;
const char kLogSignatureKey[] =;
const char kLogTimestampKey[] =;
const char kLogDataKey[] =;
const char kLogUnsentCountKey[] =;
const char kLogSentCountKey[] =;
const char kLogPersistedSizeInKbKey[] =;
const char kLogUserIdKey[] =;
const char kLogSourceType[] =;

std::string EncodeToBase64(const std::string& to_convert) {}

std::string DecodeFromBase64(const std::string& to_convert) {}

// Used to write unsent logs to prefs.
class LogsPrefWriter {};

bool GetString(const base::Value::Dict& dict,
               std::string_view key,
               std::string& out) {}

}  // namespace

UnsentLogStore::LogInfo::LogInfo() = default;
UnsentLogStore::LogInfo::~LogInfo() = default;

void UnsentLogStore::LogInfo::Init(const std::string& log_data,
                                   const std::string& log_timestamp,
                                   const std::string& signing_key,
                                   const LogMetadata& optional_log_metadata) {}

void UnsentLogStore::LogInfo::Init(const std::string& log_data,
                                   const std::string& signing_key,
                                   const LogMetadata& optional_log_metadata) {}

UnsentLogStore::UnsentLogStore(std::unique_ptr<UnsentLogStoreMetrics> metrics,
                               PrefService* local_state,
                               const char* log_data_pref_name,
                               const char* metadata_pref_name,
                               UnsentLogStoreLimits log_store_limits,
                               const std::string& signing_key,
                               MetricsLogsEventManager* logs_event_manager)
    :{}

UnsentLogStore::~UnsentLogStore() = default;

bool UnsentLogStore::has_unsent_logs() const {}

// True if a log has been staged.
bool UnsentLogStore::has_staged_log() const {}

// Returns the compressed data of the element in the front of the list.
const std::string& UnsentLogStore::staged_log() const {}

// Returns the hash of element in the front of the list.
const std::string& UnsentLogStore::staged_log_hash() const {}

// Returns the signature of element in the front of the list.
const std::string& UnsentLogStore::staged_log_signature() const {}

// Returns the timestamp of the element in the front of the list.
const std::string& UnsentLogStore::staged_log_timestamp() const {}

// Returns the user id of the current staged log.
std::optional<uint64_t> UnsentLogStore::staged_log_user_id() const {}

const LogMetadata UnsentLogStore::staged_log_metadata() const {}

// static
bool UnsentLogStore::ComputeHMACForLog(const std::string& log_data,
                                       const std::string& signing_key,
                                       std::string* signature) {}

void UnsentLogStore::StageNextLog() {}

void UnsentLogStore::DiscardStagedLog(std::string_view reason) {}

void UnsentLogStore::MarkStagedLogAsSent() {}

void UnsentLogStore::TrimAndPersistUnsentLogs(bool overwrite_in_memory_store) {}

void UnsentLogStore::LoadPersistedUnsentLogs() {}

void UnsentLogStore::StoreLog(const std::string& log_data,
                              const LogMetadata& log_metadata,
                              MetricsLogsEventManager::CreateReason reason) {}

void UnsentLogStore::StoreLogInfo(
    std::unique_ptr<LogInfo> log_info,
    size_t uncompressed_log_size,
    MetricsLogsEventManager::CreateReason reason) {}

const std::string& UnsentLogStore::GetLogAtIndex(size_t index) {}

std::string UnsentLogStore::ReplaceLogAtIndex(size_t index,
                                              const std::string& new_log_data,
                                              const LogMetadata& log_metadata) {}

void UnsentLogStore::Purge() {}

void UnsentLogStore::SetLogsEventManager(
    MetricsLogsEventManager* logs_event_manager) {}

void UnsentLogStore::ReadLogsFromPrefList(const base::Value::List& list_value) {}

void UnsentLogStore::WriteToMetricsPref(
    base::HistogramBase::Count unsent_samples_count,
    base::HistogramBase::Count sent_samples_count,
    size_t unsent_persisted_size) const {}

void UnsentLogStore::RecordMetaDataMetrics() {}

void UnsentLogStore::NotifyLogCreated(
    const LogInfo& info,
    MetricsLogsEventManager::CreateReason reason) {}

void UnsentLogStore::NotifyLogsCreated(
    base::span<std::unique_ptr<LogInfo>> logs,
    MetricsLogsEventManager::CreateReason reason) {}

void UnsentLogStore::NotifyLogEvent(MetricsLogsEventManager::LogEvent event,
                                    std::string_view log_hash,
                                    std::string_view message) {}

void UnsentLogStore::NotifyLogsEvent(base::span<std::unique_ptr<LogInfo>> logs,
                                     MetricsLogsEventManager::LogEvent event,
                                     std::string_view message) {}

}  // namespace metrics