#include "components/assist_ranker/ranker_model_loader_impl.h"
#include <utility>
#include <memory>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/files/important_file_writer.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_base.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "components/assist_ranker/proto/ranker_model.pb.h"
#include "components/assist_ranker/ranker_url_fetcher.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace assist_ranker {
namespace {
constexpr int kMinRetryDelayMins = …;
const char kModelStatusHistogram[] = …;
std::string LoadFromFile(const base::FilePath& model_path) { … }
void SaveToFile(const GURL& model_url,
const base::FilePath& model_path,
const std::string& model_data,
const std::string& uma_prefix) { … }
}
RankerModelLoaderImpl::RankerModelLoaderImpl(
ValidateModelCallback validate_model_cb,
OnModelAvailableCallback on_model_available_cb,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
base::FilePath model_path,
GURL model_url,
std::string uma_prefix)
: … { … }
RankerModelLoaderImpl::~RankerModelLoaderImpl() { … }
void RankerModelLoaderImpl::NotifyOfRankerActivity() { … }
void RankerModelLoaderImpl::StartLoadFromFile() { … }
void RankerModelLoaderImpl::OnFileLoaded(const std::string& data) { … }
void RankerModelLoaderImpl::StartLoadFromURL() { … }
void RankerModelLoaderImpl::OnURLFetched(bool success,
const std::string& data) { … }
std::unique_ptr<RankerModel> RankerModelLoaderImpl::CreateAndValidateModel(
const std::string& data) { … }
RankerModelStatus RankerModelLoaderImpl::ReportModelStatus(
RankerModelStatus model_status) { … }
}