page_entities_model_executor.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2022 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. #include "components/optimization_guide/core/page_entities_model_executor.h"
  5. #include "base/bind.h"
  6. #include "base/callback.h"
  7. namespace optimization_guide {
  8. void PageEntitiesModelExecutor::ExecuteOnSingleInput(
  9. AnnotationType annotation_type,
  10. const std::string& input,
  11. base::OnceCallback<void(const BatchAnnotationResult&)> callback) {
  12. DCHECK_EQ(annotation_type, AnnotationType::kPageEntities);
  13. ExecuteModelWithInput(
  14. input, base::BindOnce(
  15. [](const std::string& input,
  16. base::OnceCallback<void(const BatchAnnotationResult&)>
  17. pca_callback,
  18. const absl::optional<std::vector<ScoredEntityMetadata>>&
  19. entity_metadata) {
  20. std::move(pca_callback)
  21. .Run(BatchAnnotationResult::CreatePageEntitiesResult(
  22. input, entity_metadata));
  23. },
  24. input, std::move(callback)));
  25. }
  26. } // namespace optimization_guide