chromium/components/optimization_guide/core/optimization_guide_switches.cc

// Copyright 2019 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/optimization_guide_switches.h"

#include <optional>

#include "base/base64.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "build/build_config.h"
#include "components/optimization_guide/proto/hints.pb.h"
#include "google_apis/google_api_keys.h"

namespace optimization_guide {
namespace switches {

// Overrides the Hints Protobuf that would come from the component updater. If
// the value of this switch is invalid, regular hint processing is used.
// The value of this switch should be a base64 encoding of a binary
// Configuration message, found in optimization_guide's hints.proto. Providing a
// valid value to this switch causes Chrome startup to block on hints parsing.
const char kHintsProtoOverride[] =;

// Overrides scheduling and time delays for fetching hints and causes a hints
// fetch immediately on start up using the provided comma separate lists of
// hosts.
const char kFetchHintsOverride[] =;

// Overrides the hints fetch scheduling and delay, causing a hints fetch
// immediately on start up using the TopHostProvider. This is meant for testing.
const char kFetchHintsOverrideTimer[] =;

// Overrides the Optimization Guide Service URL that the HintsFetcher will
// request remote hints from.
const char kOptimizationGuideServiceGetHintsURL[] =;

// Overrides the Optimization Guide Service URL that the PredictionModelFetcher
// will request remote models and host features from.
const char kOptimizationGuideServiceGetModelsURL[] =;

// Overrides the Optimization Guide model execution URL.
const char kOptimizationGuideServiceModelExecutionURL[] =;

// Overrides the Optimization Guide Service API Key for remote requests to be
// made.
const char kOptimizationGuideServiceAPIKey[] =;

// Purges the store containing fetched and component hints on startup, so that
// it's guaranteed to be using fresh data.
const char kPurgeHintsStore[] =;

// Purges the store containing prediction medels and host model features on
// startup, so that it's guaranteed to be using fresh data.
const char kPurgeModelAndFeaturesStore[] =;

const char kDisableFetchingHintsAtNavigationStartForTesting[] =;

const char kDisableCheckingUserPermissionsForTesting[] =;

const char kDisableModelDownloadVerificationForTesting[] =;

const char kDebugLoggingEnabled[] =;

// Disables the fetching of models and overrides the file path and metadata to
// be used for the session to use what's passed via command-line instead of what
// is already stored.
//
// We expect that the string be a comma-separated string of model overrides with
// each model override be: OPTIMIZATION_TARGET_STRING:file_path or
// OPTIMIZATION_TARGET_STRING:file_path:base64_encoded_any_proto_model_metadata.
//
// It is possible this only works on Desktop since file paths are less easily
// accessible on Android, but may work.
const char kModelOverride[] =;

// Overrides the on-device model file paths for on-device model execution.
const char kOnDeviceModelExecutionOverride[] =;

// Overrides the on-device model adaptation file paths for on-device model
// execution.
const char kOnDeviceModelAdaptationsOverride[] =;

// Enables the on-device model to run validation at startup after a delay. A
// text file can be provided used as input for the validation job and an output
// file path can be provided to write the response to.
const char kOnDeviceValidationRequestOverride[] =;
const char kOnDeviceValidationWriteToFile[] =;

// Triggers validation of the model. Used for manual testing.
const char kModelValidate[] =;

// Triggers validation of the server-side AI model execution. Used for
// integration testing.
const char kModelExecutionValidate[] =;

// Overrides the model quality service URL.
const char kModelQualityServiceURL[] =;

// Overrides the ModelQuality Service API Key for remote requests to be made.
const char kModelQualityServiceAPIKey[] =;

// Enables model quality logs regardless of other client-side settings, as long
// as the client is a dogfood client.
const char kEnableModelQualityDogfoodLogging[] =;

const char kGetFreeDiskSpaceWithUserVisiblePriorityTask[] =;

// Allows sending an language code to the backend.
const char kOptimizationGuideLanguageOverride[] =;

std::string GetModelQualityServiceAPIKey() {}

bool IsHintComponentProcessingDisabled() {}

bool ShouldPurgeOptimizationGuideStoreOnStartup() {}

bool ShouldPurgeModelAndFeaturesStoreOnStartup() {}

bool IsDebugLogsEnabled() {}

// Parses a list of hosts to have hints fetched for. This overrides scheduling
// of the first hints fetch and forces it to occur immediately. If no hosts are
// provided, nullopt is returned.
std::optional<std::vector<std::string>>
ParseHintsFetchOverrideFromCommandLine() {}

bool ShouldOverrideFetchHintsTimer() {}

std::unique_ptr<optimization_guide::proto::Configuration>
ParseComponentConfigFromCommandLine() {}

bool DisableFetchingHintsAtNavigationStartForTesting() {}

bool ShouldOverrideCheckingUserPermissionsToFetchHintsForTesting() {}

bool ShouldSkipModelDownloadVerificationForTesting() {}

bool IsModelOverridePresent() {}

bool ShouldValidateModel() {}

bool ShouldValidateModelExecution() {}

std::optional<std::string> GetModelOverride() {}

std::optional<std::string> GetOnDeviceModelExecutionOverride() {}

std::optional<std::string> GetOnDeviceModelAdaptationsOverride() {}

std::optional<base::FilePath> GetOnDeviceValidationRequestOverride() {}

std::optional<base::FilePath> GetOnDeviceValidationWriteToFile() {}

bool ShouldGetFreeDiskSpaceWithUserVisiblePriorityTask() {}

}  // namespace switches
}  // namespace optimization_guide