chromium/components/optimization_guide/core/model_util.cc

// Copyright 2021 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/optimization_guide/core/model_util.h"

#include "base/base64.h"
#include "base/containers/flat_set.h"
#include "base/files/file_util.h"
#include "base/hash/legacy_hash.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/optimization_guide/core/optimization_guide_switches.h"
#include "components/optimization_guide/proto/models.pb.h"
#include "net/base/url_util.h"
#include "url/url_canon.h"

namespace optimization_guide {

namespace {

// The ":" character is reserved in Windows as part of an absolute file path,
// e.g.: C:\model.tflite, so we use a different separtor.
#if BUILDFLAG(IS_WIN)
const char kModelOverrideSeparator[] = "|";
#else
const char kModelOverrideSeparator[] =;
#endif

}  // namespace

// These names are persisted to histograms, so don't change them.
std::string GetStringNameForOptimizationTarget(
    optimization_guide::proto::OptimizationTarget optimization_target) {}

std::optional<base::FilePath> StringToFilePath(const std::string& str_path) {}

std::string FilePathToString(const base::FilePath& file_path) {}

base::FilePath GetBaseFileNameForModels() {}

base::FilePath GetBaseFileNameForModelInfo() {}

std::string ModelOverrideSeparator() {}

std::optional<
    std::pair<std::string, std::optional<optimization_guide::proto::Any>>>
GetModelOverrideForOptimizationTarget(
    optimization_guide::proto::OptimizationTarget optimization_target) {}

bool CheckAllPathsExist(
    const std::vector<base::FilePath>& file_paths_to_check) {}

base::FilePath ConvertToRelativePath(const base::FilePath& parent,
                                     const base::FilePath& child) {}

std::string GetModelCacheKeyHash(proto::ModelCacheKey model_cache_key) {}

void RecordPredictionModelStoreModelRemovalVersionHistogram(
    proto::OptimizationTarget optimization_target,
    PredictionModelStoreModelRemovalReason model_removal_reason) {}

bool IsPredictionModelVersionInKillSwitch(
    const std::map<proto::OptimizationTarget, std::set<int64_t>>&
        killswitch_model_versions,
    proto::OptimizationTarget opt_target,
    int64_t model_version) {}

std::optional<proto::ModelInfo> ParseModelInfoFromFile(
    const base::FilePath& model_info_path) {}

}  // namespace optimization_guide