Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: components/ntp_snippets/category_rankers/category_ranker.h

Issue 2568033005: [NTP::SectionOrder] Replace CategoryFactory with a category ranker. (Closed)
Patch Set: rebase. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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
5 #ifndef COMPONENTS_NTP_SNIPPETS_CATEGORY_RANKERS_CATEGORY_RANKER_H_
6 #define COMPONENTS_NTP_SNIPPETS_CATEGORY_RANKERS_CATEGORY_RANKER_H_
7
8 #include "base/time/time.h"
9 #include "components/ntp_snippets/category.h"
10
11 namespace ntp_snippets {
12
13 // TODO(vitaliii): Ensure that changes in the order are propagated to the UI.
14 // (crbug.com/673743)
15
16 // Orders categories.
17 // The order may be dynamic and change at any time.
18 class CategoryRanker {
19 public:
20 virtual ~CategoryRanker() = default;
21
22 // Compares two categories. True means that |left| precedes |right|, i.e. it
23 // must be located earlier (above) on the NTP. This method must satisfy
24 // "Compare" contract required by sort algorithms.
25 virtual bool Compare(Category left, Category right) const = 0;
26
27 // Deletes all history related data between |begin| and |end|. After this
28 // call, the category order may not depend on this history range anymore.
29 virtual void ClearHistory(base::Time begin, base::Time end) = 0;
30
31 // If |category| has not been added previously, it is added after all already
32 // known categories, otherwise nothing is changed.
33 virtual void AppendCategoryIfNecessary(Category category) = 0;
34
35 // Feedback data from the user to update the ranking.
36
37 // Called whenever a suggestion is opened by the user.
38 virtual void OnSuggestionOpened(Category category) = 0;
39 };
40
41 } // namespace ntp_snippets
42
43 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_RANKERS_CATEGORY_RANKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698