#include "services/on_device_model/public/cpp/test_support/fake_service.h"
#include "base/containers/span.h"
#include "base/files/memory_mapped_file.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
namespace on_device_model {
namespace {
std::string ReadFile(base::File& file) { … }
}
FakeOnDeviceServiceSettings::FakeOnDeviceServiceSettings() = default;
FakeOnDeviceServiceSettings::~FakeOnDeviceServiceSettings() = default;
FakeOnDeviceSession::FakeOnDeviceSession(
FakeOnDeviceServiceSettings* settings,
const std::string& adaptation_model_weight,
FakeOnDeviceModel* model)
: … { … }
FakeOnDeviceSession::~FakeOnDeviceSession() = default;
void FakeOnDeviceSession::AddContext(
mojom::InputOptionsPtr input,
mojo::PendingRemote<mojom::ContextClient> client) { … }
void FakeOnDeviceSession::Execute(
mojom::InputOptionsPtr input,
mojo::PendingRemote<mojom::StreamingResponder> response) { … }
void FakeOnDeviceSession::GetSizeInTokens(const std::string& text,
GetSizeInTokensCallback callback) { … }
void FakeOnDeviceSession::Score(const std::string& text,
ScoreCallback callback) { … }
void FakeOnDeviceSession::Clone(
mojo::PendingReceiver<on_device_model::mojom::Session> session) { … }
void FakeOnDeviceSession::ExecuteImpl(
mojom::InputOptionsPtr input,
mojo::PendingRemote<mojom::StreamingResponder> response) { … }
void FakeOnDeviceSession::AddContextInternal(
mojom::InputOptionsPtr input,
mojo::PendingRemote<mojom::ContextClient> client) { … }
FakeOnDeviceModel::FakeOnDeviceModel(FakeOnDeviceServiceSettings* settings,
FakeOnDeviceModel::Data&& data)
: … { … }
FakeOnDeviceModel::~FakeOnDeviceModel() = default;
void FakeOnDeviceModel::StartSession(
mojo::PendingReceiver<mojom::Session> session) { … }
void FakeOnDeviceModel::AddSession(
mojo::PendingReceiver<mojom::Session> receiver,
std::unique_ptr<FakeOnDeviceSession> session) { … }
void FakeOnDeviceModel::DetectLanguage(const std::string& text,
DetectLanguageCallback callback) { … }
void FakeOnDeviceModel::ClassifyTextSafety(
const std::string& text,
ClassifyTextSafetyCallback callback) { … }
void FakeOnDeviceModel::LoadAdaptation(
mojom::LoadAdaptationParamsPtr params,
mojo::PendingReceiver<mojom::OnDeviceModel> model,
LoadAdaptationCallback callback) { … }
FakeOnDeviceModelService::FakeOnDeviceModelService(
mojo::PendingReceiver<mojom::OnDeviceModelService> receiver,
FakeOnDeviceServiceSettings* settings)
: … { … }
FakeOnDeviceModelService::~FakeOnDeviceModelService() = default;
void FakeOnDeviceModelService::LoadModel(
mojom::LoadModelParamsPtr params,
mojo::PendingReceiver<mojom::OnDeviceModel> model,
LoadModelCallback callback) { … }
void FakeOnDeviceModelService::GetEstimatedPerformanceClass(
GetEstimatedPerformanceClassCallback callback) { … }
}