#include "components/optimization_guide/core/model_execution/on_device_model_component.h"
#include <optional>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/sequence_checker.h"
#include "base/strings/strcat.h"
#include "base/time/time.h"
#include "base/types/cxx23_to_underlying.h"
#include "components/optimization_guide/core/model_execution/model_execution_features.h"
#include "components/optimization_guide/core/model_execution/model_execution_prefs.h"
#include "components/optimization_guide/core/model_execution/model_execution_util.h"
#include "components/optimization_guide/core/model_util.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_features.h"
#include "components/prefs/pref_service.h"
namespace optimization_guide {
namespace {
const std::optional<OnDeviceBaseModelSpec> ReadBaseModelSpecFromManifest(
const base::Value::Dict& manifest) { … }
base::WeakPtr<OnDeviceModelComponentStateManager>& GetInstance() { … }
bool WasAnyOnDeviceEligibleFeatureRecentlyUsed(const PrefService& local_state) { … }
bool IsDeviceCapable(const PrefService& local_state) { … }
void LogInstallCriteria(std::string_view event_name,
std::string_view criteria_name,
bool criteria_value) { … }
}
struct OnDeviceModelComponentStateManager::RegistrationCriteria { … };
namespace {
void LogInstallCriteria(
OnDeviceModelComponentStateManager::RegistrationCriteria& criteria,
std::string_view event_name) { … }
}
void OnDeviceModelComponentStateManager::UninstallComplete() { … }
OnDeviceModelStatus
OnDeviceModelComponentStateManager::GetOnDeviceModelStatus() { … }
void OnDeviceModelComponentStateManager::OnDeviceEligibleFeatureUsed(
ModelBasedCapabilityKey feature) { … }
void OnDeviceModelComponentStateManager::DevicePerformanceClassChanged(
OnDeviceModelPerformanceClass performance_class) { … }
void OnDeviceModelComponentStateManager::OnStartup() { … }
void OnDeviceModelComponentStateManager::InstallerRegistered() { … }
void OnDeviceModelComponentStateManager::BeginUpdateRegistration() { … }
void OnDeviceModelComponentStateManager::CompleteUpdateRegistration(
int64_t disk_space_free_bytes) { … }
OnDeviceModelComponentStateManager::RegistrationCriteria
OnDeviceModelComponentStateManager::GetRegistrationCriteria(
int64_t disk_space_free_bytes) { … }
OnDeviceModelComponentStateManager::OnDeviceModelComponentStateManager(
PrefService* local_state,
std::unique_ptr<Delegate> delegate)
: … { … }
OnDeviceModelComponentStateManager::~OnDeviceModelComponentStateManager() =
default;
const OnDeviceModelComponentState*
OnDeviceModelComponentStateManager::GetState() { … }
scoped_refptr<OnDeviceModelComponentStateManager>
OnDeviceModelComponentStateManager::CreateOrGet(
PrefService* local_state,
std::unique_ptr<Delegate> delegate) { … }
void OnDeviceModelComponentStateManager::AddObserver(Observer* observer) { … }
void OnDeviceModelComponentStateManager::RemoveObserver(Observer* observer) { … }
OnDeviceModelComponentStateManager*
OnDeviceModelComponentStateManager::GetInstanceForTesting() { … }
bool OnDeviceModelComponentStateManager::VerifyInstallation(
const base::FilePath& install_dir,
const base::Value::Dict& manifest) { … }
void OnDeviceModelComponentStateManager::SetReady(
const base::Version& version,
const base::FilePath& install_dir,
const base::Value::Dict& manifest) { … }
void OnDeviceModelComponentStateManager::NotifyStateChanged() { … }
OnDeviceModelComponentState::OnDeviceModelComponentState() = default;
OnDeviceModelComponentState::~OnDeviceModelComponentState() = default;
}