chromium/components/visited_url_ranking/public/visited_url_ranking_service.h

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_VISITED_URL_RANKING_PUBLIC_VISITED_URL_RANKING_SERVICE_H_
#define COMPONENTS_VISITED_URL_RANKING_PUBLIC_VISITED_URL_RANKING_SERVICE_H_

#include <string>
#include <vector>

#include "base/functional/callback_forward.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/visited_url_ranking/public/fetch_options.h"
#include "components/visited_url_ranking/public/url_visit.h"

namespace visited_url_ranking {

// Value must match `segmentation_platform::kURLVisitResumptionClassifierKey`.
const char kTabResumptionRankerKey[] =;

// Aggregate metrics event related names.
const char kURLVisitSeenEventName[] =;
const char kURLVisitActivatedEventName[] =;
const char kURLVisitDismissedEventName[] =;

// An action performed by the user on a `URLVisit` through a UI surface.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.visited_url_ranking
// LINT.IfChange(ScoredURLUserAction)
enum ScoredURLUserAction {};
// LINT.ThenChange(/tools/metrics/histograms/visited_url_ranking/enums.xml:ScoredURLUserAction)

// Settings leveraged for ranking `URLVisitAggregate` objects.
struct Config {};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class ResultStatus {};

// Provides APIs suitable for combining URL Visit data across various data
// sources and their subsequent ranking via a model.
// Example usage:
//   auto on_rank_callback = base::BindOnce([](ResultStatus status,
//       std::vector<URLVisitAggregate> visits) {
//     if(status == ResultStatus::kSuccess) {
//       // Client logic placeholder.
//     }
//   });
//   auto on_fetch_callback = base::BindOnce([](OnceCallback on_rank_callback,
//       ResultStatus status, std::vector<URLVisitAggregate> visits) {
//     if(status == ResultStatus::kSuccess) {
//       // Client logic placeholder (e.g. filtering, caching, etc.).
//       Config config = {.key = kTabResumptionRankerKey};
//       GetService()->RankURLVisitAggregates(config, std::move(visits),
//           std::move(on_rank_callback));
//     }
//   }, std::move(on_rank_callback));
//   GetService()->FetchURLVisitAggregates(
//       CreateTabResumptionDefaultFetchOptions(),
//       std::move(on_fetch_callback));
//
class VisitedURLRankingService : public KeyedService {};

}  // namespace visited_url_ranking

#endif  // COMPONENTS_VISITED_URL_RANKING_PUBLIC_VISITED_URL_RANKING_SERVICE_H_