entity_metadata_provider.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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_ENTITY_METADATA_PROVIDER_H_
  5. #define COMPONENTS_OPTIMIZATION_GUIDE_CORE_ENTITY_METADATA_PROVIDER_H_
  6. #include "components/optimization_guide/core/entity_metadata.h"
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. namespace optimization_guide {
  9. // Callback to inform the caller that the metadata for an entity ID has been
  10. // retrieved.
  11. using EntityMetadataRetrievedCallback =
  12. base::OnceCallback<void(const absl::optional<EntityMetadata>&)>;
  13. // A class that provides metadata about entities.
  14. class EntityMetadataProvider {
  15. public:
  16. // Retrieves the metadata associated with |entity_id|. Invokes |callback|
  17. // when done.
  18. virtual void GetMetadataForEntityId(
  19. const std::string& entity_id,
  20. EntityMetadataRetrievedCallback callback) = 0;
  21. protected:
  22. EntityMetadataProvider() = default;
  23. virtual ~EntityMetadataProvider() = default;
  24. };
  25. } // namespace optimization_guide
  26. #endif // COMPONENTS_OPTIMIZATION_GUIDE_CORE_ENTITY_METADATA_PROVIDER_H_