#include "chrome/browser/companion/visual_query/visual_query_suggestions_service.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_macros_local.h"
#include "base/task/sequenced_task_runner.h"
#include "components/optimization_guide/core/optimization_guide_model_provider.h"
#include "components/optimization_guide/core/optimization_guide_util.h"
#include "components/optimization_guide/proto/models.pb.h"
#include "mojo/public/mojom/base/proto_wrapper.mojom.h"
namespace companion::visual_query {
namespace {
base::File LoadModelFile(const base::FilePath& model_file_path) { … }
void CloseModelFile(base::File model_file) { … }
std::optional<mojo_base::ProtoWrapper> GetModelSpec(ModelMetadata& metadata) { … }
}
VisualQuerySuggestionsService::VisualQuerySuggestionsService(
optimization_guide::OptimizationGuideModelProvider* model_provider,
const scoped_refptr<base::SequencedTaskRunner>& background_task_runner)
: … { … }
VisualQuerySuggestionsService::~VisualQuerySuggestionsService() { … }
void VisualQuerySuggestionsService::BindModelReceiver(
mojo::PendingReceiver<mojom::VisualSuggestionsModelProvider> receiver) { … }
void VisualQuerySuggestionsService::Shutdown() { … }
void VisualQuerySuggestionsService::UnloadModelFile() { … }
void VisualQuerySuggestionsService::NotifyModelUpdatesAndClear() { … }
void VisualQuerySuggestionsService::OnModelFileLoaded(base::File model_file) { … }
void VisualQuerySuggestionsService::OnModelUpdated(
optimization_guide::proto::OptimizationTarget optimization_target,
base::optional_ref<const optimization_guide::ModelInfo> model_info) { … }
void VisualQuerySuggestionsService::RegisterModelUpdateCallback(
ModelUpdateCallback callback) { … }
void VisualQuerySuggestionsService::GetModelWithMetadata(
GetModelWithMetadataCallback callback) { … }
}