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

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 & treib@ comments & ios. 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 sections (represented as categories).
Marc Treib 2016/12/14 10:24:31 nitty nit: don't talk about sections (they don't e
vitaliii 2016/12/15 15:30:12 Done.
17 // The order may be dynamic and change at any time.
18 class CategoryRanker {
19 public:
20 // Compares two categories. True means that |left| precedes |right|, i.e. it
21 // must be located earlier (above) on the NTP. This method must satisfy
22 // "Compare" contract required by sort algorithms.
23 virtual bool Compare(Category left, Category right) const = 0;
24
25 // Deletes all history related data between |begin| and |end|. After this
26 // call, the category order may not depend on this history range anymore.
27 virtual void ClearHistory(base::Time begin, base::Time end) = 0;
28
29 // If |category| has not been added previously, it is added after all already
30 // known categories, otherwise nothing is changed.
31 virtual void AppendCategoryIfNecessary(Category category) = 0;
32
33 // Feedback data from the user to update the ranking.
34
35 // Called whenever a suggestion is opened by the user.
36 virtual void OnSuggestionOpened(Category category) = 0;
37 };
38
39 } // namespace ntp_snippets
40
41 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_RANKERS_CATEGORY_RANKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698