#include "chrome/browser/optimization_guide/model_validator_keyed_service.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_macros_local.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "components/optimization_guide/core/model_execution/feature_keys.h"
#include "components/optimization_guide/core/model_execution/on_device_model_component.h"
#include "components/optimization_guide/core/model_execution/on_device_model_execution_proto_descriptors.h"
#include "components/optimization_guide/core/optimization_guide_constants.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/optimization_guide_switches.h"
#include "components/optimization_guide/core/optimization_guide_util.h"
#include "components/optimization_guide/machine_learning_tflite_buildflags.h"
#include "components/optimization_guide/proto/features/compose.pb.h"
#include "components/optimization_guide/proto/model_execution.pb.h"
#include "components/optimization_guide/proto/model_validation.pb.h"
#include "components/optimization_guide/proto/string_value.pb.h"
#if BUILDFLAG(BUILD_WITH_TFLITE_LIB)
#include "components/optimization_guide/core/model_validator.h"
#endif
namespace {
std::unique_ptr<optimization_guide::proto::ModelValidationInput>
ParseRequestFromFile(base::FilePath path) { … }
void WriteResponseToFile(
base::FilePath path,
optimization_guide::proto::ModelValidationOutput validation_output) { … }
}
namespace optimization_guide {
ModelValidatorKeyedService::ModelValidatorKeyedService(Profile* profile)
: … { … }
ModelValidatorKeyedService::~ModelValidatorKeyedService() = default;
void ModelValidatorKeyedService::OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event_details) { … }
void ModelValidatorKeyedService::StartModelExecutionValidation() { … }
void ModelValidatorKeyedService::StartOnDeviceModelExecutionValidation(
std::unique_ptr<optimization_guide::proto::ModelValidationInput> input) { … }
void ModelValidatorKeyedService::PerformOnDeviceModelExecutionValidation(
std::unique_ptr<optimization_guide::proto::ModelValidationInput> input) { … }
void ModelValidatorKeyedService::ExecuteModel(
std::unique_ptr<google::protobuf::MessageLite> request_metadata) { … }
void ModelValidatorKeyedService::OnDeviceModelExecuteResponse(
OptimizationGuideModelStreamingExecutionResult result) { … }
void ModelValidatorKeyedService::OnModelExecuteResponse(
OptimizationGuideModelExecutionResult result,
std::unique_ptr<ModelQualityLogEntry> log_entry) { … }
}