diff options
Diffstat (limited to 'chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service.h')
-rw-r--r-- | chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service.h b/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service.h index 23214ede416..1100a89f4f9 100644 --- a/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service.h +++ b/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service.h @@ -16,6 +16,8 @@ #include "components/keyed_service/core/keyed_service.h" #include "components/ntp_snippets/callbacks.h" #include "components/ntp_snippets/content_suggestion.h" +#include "components/ntp_snippets/contextual/contextual_suggestions_cache.h" +#include "components/ntp_snippets/contextual/contextual_suggestions_debugging_reporter.h" #include "components/ntp_snippets/contextual/contextual_suggestions_fetcher.h" #include "components/ntp_snippets/contextual/contextual_suggestions_reporter.h" #include "services/metrics/public/cpp/ukm_source_id.h" @@ -27,6 +29,8 @@ class RemoteSuggestionsDatabase; namespace contextual_suggestions { +static constexpr int kFetchCacheCapacity = 10; + class ContextualContentSuggestionsServiceProxy; // Retrieves contextual suggestions for a given URL and fetches images @@ -57,17 +61,34 @@ class ContextualContentSuggestionsService : public KeyedService { const GURL& url, ntp_snippets::ImageFetchedCallback callback); - void FetchDone(FetchClustersCallback callback, + void FetchDone(const GURL& url, + FetchClustersCallback callback, ReportFetchMetricsCallback metrics_callback, ContextualSuggestionsResult result); + // Used to surface metrics events via chrome://eoc-internals. + ContextualSuggestionsDebuggingReporter* GetDebuggingReporter(); + + // Expose cached results for debugging. + base::flat_map<GURL, ContextualSuggestionsResult> + GetAllCachedResultsForDebugging(); + + // Clear the cached results for debugging. + void ClearCachedResultsForDebugging(); + std::unique_ptr<ContextualContentSuggestionsServiceProxy> CreateProxy(); private: + void BelowConfidenceThresholdFetchDone( + FetchClustersCallback callback, + ReportFetchMetricsCallback metrics_callback); // Cache for images of contextual suggestions, needed by CachedImageFetcher. std::unique_ptr<ntp_snippets::RemoteSuggestionsDatabase> contextual_suggestions_database_; + // Cache of contextual suggestions fetch results, keyed by the context url. + ContextualSuggestionsCache fetch_cache_; + // Performs actual network request to fetch contextual suggestions. std::unique_ptr<ContextualSuggestionsFetcher> contextual_suggestions_fetcher_; |