clustering_backend.h 1.3 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_HISTORY_CLUSTERS_CORE_CLUSTERING_BACKEND_H_
  5. #define COMPONENTS_HISTORY_CLUSTERS_CORE_CLUSTERING_BACKEND_H_
  6. #include "base/callback.h"
  7. #include "components/history/core/browser/history_types.h"
  8. namespace history_clusters {
  9. enum class ClusteringRequestSource { kKeywordCacheGeneration, kJourneysPage };
  10. // An abstract interface for a swappable clustering backend.
  11. class ClusteringBackend {
  12. public:
  13. using ClustersCallback =
  14. base::OnceCallback<void(std::vector<history::Cluster>)>;
  15. virtual ~ClusteringBackend() = default;
  16. // The backend clusters `visits` and returns the results asynchronously via
  17. // `callback`. `visits` can be passed in arbitrary order, and the resulting
  18. // clusters can be in arbitrary order too. Caller is responsible for sorting
  19. // the output however they want it.
  20. virtual void GetClusters(ClusteringRequestSource clustering_request_source,
  21. ClustersCallback callback,
  22. std::vector<history::AnnotatedVisit> visits) = 0;
  23. };
  24. } // namespace history_clusters
  25. #endif // COMPONENTS_HISTORY_CLUSTERS_CORE_CLUSTERING_BACKEND_H_