#include "components/optimization_guide/core/optimization_guide_features.h"
#include <cstring>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/enum_set.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/rand_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/to_string.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
#include "components/optimization_guide/core/feature_registry/mqls_feature_registry.h"
#include "components/optimization_guide/core/insertion_ordered_set.h"
#include "components/optimization_guide/core/model_execution/feature_keys.h"
#include "components/optimization_guide/core/optimization_guide_constants.h"
#include "components/optimization_guide/core/optimization_guide_enums.h"
#include "components/optimization_guide/core/optimization_guide_switches.h"
#include "components/optimization_guide/machine_learning_tflite_buildflags.h"
#include "components/optimization_guide/proto/common_types.pb.h"
#include "components/variations/hashing.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/google_api_keys.h"
#include "net/base/url_util.h"
#include "ui/base/l10n/l10n_util.h"
namespace optimization_guide {
namespace features {
namespace {
constexpr auto enabled_by_default_mobile_only = …base::FEATURE_ENABLED_BY_DEFAULT;
#else
base::FEATURE_DISABLED_BY_DEFAULT;
#endif
}
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
base::TimeDelta PageTextExtractionOutstandingRequestsGracePeriod() { … }
bool ShouldBatchUpdateHintsForActiveTabsAndTopHosts() { … }
size_t MaxResultsForSRPFetch() { … }
size_t MaxHostsForOptimizationGuideServiceHintsFetch() { … }
size_t MaxUrlsForOptimizationGuideServiceHintsFetch() { … }
size_t MaxHostsForRecordingSuccessfullyCovered() { … }
base::TimeDelta StoredFetchedHintsFreshnessDuration() { … }
std::string GetOptimizationGuideServiceAPIKey() { … }
GURL GetOptimizationGuideServiceGetHintsURL() { … }
GURL GetOptimizationGuideServiceGetModelsURL() { … }
bool IsOptimizationTargetPredictionEnabled() { … }
bool IsOptimizationHintsEnabled() { … }
bool IsModelQualityLoggingEnabled() { … }
bool IsModelQualityLoggingEnabledForFeature(
const MqlsFeatureMetadata* metadata) { … }
bool IsRemoteFetchingEnabled() { … }
bool IsSRPFetchingEnabled() { … }
bool IsPushNotificationsEnabled() { … }
bool IsRemoteFetchingForAnonymousDataConsentEnabled() { … }
bool IsRemoteFetchingExplicitlyAllowedForPerformanceInfo() { … }
int MaxServerBloomFilterByteSize() { … }
base::TimeDelta GetHostHintsFetchRefreshDuration() { … }
base::TimeDelta GetActiveTabsFetchRefreshDuration() { … }
base::TimeDelta GetActiveTabsStalenessTolerance() { … }
size_t MaxConcurrentBatchUpdateFetches() { … }
size_t MaxConcurrentPageNavigationFetches() { … }
base::TimeDelta ActiveTabsHintsFetchRandomMinDelay() { … }
base::TimeDelta ActiveTabsHintsFetchRandomMaxDelay() { … }
base::TimeDelta StoredHostModelFeaturesFreshnessDuration() { … }
base::TimeDelta StoredModelsValidDuration() { … }
base::TimeDelta URLKeyedHintValidCacheDuration() { … }
size_t MaxHostsForOptimizationGuideServiceModelsFetch() { … }
size_t MaxHostModelFeaturesCacheSize() { … }
size_t MaxHostKeyedHintCacheSize() { … }
size_t MaxURLKeyedHintCacheSize() { … }
bool ShouldPersistHintsToDisk() { … }
RequestContextSet GetAllowedContextsForPersonalizedMetadata() { … }
bool ShouldOverrideOptimizationTargetDecisionForMetricsPurposes(
proto::OptimizationTarget optimization_target) { … }
base::TimeDelta PredictionModelFetchRandomMinDelay() { … }
base::TimeDelta PredictionModelFetchRandomMaxDelay() { … }
base::TimeDelta PredictionModelFetchRetryDelay() { … }
base::TimeDelta PredictionModelFetchStartupDelay() { … }
base::TimeDelta PredictionModelFetchInterval() { … }
base::TimeDelta PredictionModelNewRegistrationFetchRandomDelay() { … }
bool IsModelExecutionWatchdogEnabled() { … }
base::TimeDelta ModelExecutionWatchdogDefaultTimeout() { … }
bool IsModelDownloadingEnabled() { … }
bool IsUnrestrictedModelDownloadingEnabled() { … }
base::TimeDelta GetOnloadDelayForHintsFetching() { … }
bool ShouldMetadataValidationFetchHostKeyed() { … }
bool ShouldDeferStartupActiveTabsHintsFetch() { … }
std::optional<int> OverrideNumThreadsForOptTarget(
proto::OptimizationTarget opt_target) { … }
bool TFLiteXNNPACKDelegateEnabled() { … }
bool ShouldCheckFailedComponentVersionPref() { … }
std::map<proto::OptimizationTarget, std::set<int64_t>>
GetPredictionModelVersionsInKillSwitch() { … }
bool ShouldLoadOnDeviceModelExecutionConfigWithHigherPriority() { … }
base::TimeDelta GetOnDeviceModelIdleTimeout() { … }
bool GetOnDeviceModelSupportMultipleSessions() { … }
base::TimeDelta GetOnDeviceModelExecutionValidationStartupDelay() { … }
int GetOnDeviceModelMinTokensForContext() { … }
int GetOnDeviceModelMaxTokensForContext() { … }
int GetOnDeviceModelContextTokenChunkSize() { … }
int GetOnDeviceModelMaxTokensForExecute() { … }
int GetOnDeviceModelMaxTokensForOutput() { … }
int GetOnDeviceModelCrashCountBeforeDisable() { … }
int GetOnDeviceModelTimeoutCountBeforeDisable() { … }
base::TimeDelta GetOnDeviceStartupMetricDelay() { … }
base::TimeDelta GetOnDeviceModelTimeForInitialResponse() { … }
bool GetOnDeviceFallbackToServerOnDisconnect() { … }
bool IsPerformanceClassCompatibleWithOnDeviceModel(
OnDeviceModelPerformanceClass performance_class) { … }
bool CanLaunchOnDeviceModelService() { … }
bool IsOnDeviceExecutionEnabled() { … }
base::TimeDelta GetOnDeviceEligibleModelFeatureRecentUsePeriod() { … }
base::TimeDelta GetOnDeviceModelRetentionTime() { … }
bool IsFreeDiskSpaceSufficientForOnDeviceModelInstall(
int64_t free_disk_space_bytes) { … }
bool IsFreeDiskSpaceTooLowForOnDeviceModelInstall(
int64_t free_disk_space_bytes) { … }
bool GetOnDeviceModelRetractUnsafeContent() { … }
bool ShouldUseTextSafetyClassifierModel() { … }
uint32_t GetOnDeviceModelTextSafetyTokenInterval() { … }
double GetOnDeviceModelLanguageDetectionMinimumReliability() { … }
bool ShouldUseTextSafetyRemoteFallbackForEligibleFeatures() { … }
int GetOnDeviceModelNumRepeats() { … }
int GetOnDeviceModelMinRepeatChars() { … }
bool GetOnDeviceModelRetractRepeats() { … }
int GetOnDeviceModelDefaultTopK() { … }
int GetOnDeviceModelMaxTopK() { … }
double GetOnDeviceModelDefaultTemperature() { … }
std::vector<uint32_t> GetOnDeviceModelAllowedAdaptationRanks() { … }
bool IsOnDeviceModelValidationEnabled() { … }
bool ShouldOnDeviceModelBlockOnValidationFailure() { … }
bool ShouldOnDeviceModelClearValidationOnVersionChange() { … }
base::TimeDelta GetOnDeviceModelValidationDelay() { … }
int GetOnDeviceModelValidationAttemptCount() { … }
}
}