#include "components/translate/core/browser/translate_model_service.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/sequenced_task_runner.h"
#include "components/optimization_guide/core/optimization_guide_model_provider.h"
#include "components/optimization_guide/proto/models.pb.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
namespace {
base::File LoadModelFile(const base::FilePath& model_file_path) { … }
void CloseModelFile(base::File model_file) { … }
class ScopedModelLoadingResultRecorder { … };
constexpr int kMaxPendingRequestsAllowed = …;
}
namespace translate {
TranslateModelService::TranslateModelService(
optimization_guide::OptimizationGuideModelProvider* opt_guide,
const scoped_refptr<base::SequencedTaskRunner>& background_task_runner)
: … { … }
TranslateModelService::~TranslateModelService() { … }
void TranslateModelService::Shutdown() { … }
void TranslateModelService::UnloadModelFile() { … }
void TranslateModelService::NotifyModelUpdatesAndClear(
bool is_model_available) { … }
void TranslateModelService::OnModelUpdated(
optimization_guide::proto::OptimizationTarget optimization_target,
base::optional_ref<const optimization_guide::ModelInfo> model_info) { … }
void TranslateModelService::OnModelFileLoaded(base::File model_file) { … }
base::File TranslateModelService::GetLanguageDetectionModelFile() { … }
void TranslateModelService::NotifyOnModelFileAvailable(
NotifyModelAvailableCallback callback) { … }
}