test_model_handler.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_OPTIMIZATION_GUIDE_CORE_TEST_MODEL_HANDLER_H_
  5. #define COMPONENTS_OPTIMIZATION_GUIDE_CORE_TEST_MODEL_HANDLER_H_
  6. #include "components/optimization_guide/core/model_handler.h"
  7. #include "components/optimization_guide/core/test_model_executor.h"
  8. namespace optimization_guide {
  9. class TestModelHandler
  10. : public ModelHandler<std::vector<float>, const std::vector<float>&> {
  11. public:
  12. TestModelHandler(
  13. OptimizationGuideModelProvider* model_provider,
  14. scoped_refptr<base::SequencedTaskRunner> background_task_runner,
  15. std::unique_ptr<TestModelExecutor> executor =
  16. std::make_unique<TestModelExecutor>())
  17. : ModelHandler<std::vector<float>, const std::vector<float>&>(
  18. model_provider,
  19. background_task_runner,
  20. std::move(executor),
  21. /*model_inference_timeout=*/absl::nullopt,
  22. proto::OptimizationTarget::OPTIMIZATION_TARGET_PAINFUL_PAGE_LOAD,
  23. /*model_metadata=*/absl::nullopt) {}
  24. ~TestModelHandler() override = default;
  25. TestModelHandler(const TestModelHandler&) = delete;
  26. TestModelHandler& operator=(const TestModelHandler&) = delete;
  27. // There is a method on the base class that exposes the returned supported
  28. // features, if provided by the loaded model received from the server.
  29. // absl::optional<T> ParsedSupportedFeaturesForLoadedModel();
  30. };
  31. } // namespace optimization_guide
  32. #endif // COMPONENTS_OPTIMIZATION_GUIDE_CORE_TEST_MODEL_HANDLER_H_