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

Unified Diff: components/ntp_snippets/section_rankers/section_ranker.h

Issue 2568033005: [NTP::SectionOrder] Replace CategoryFactory with a category ranker. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/section_rankers/section_ranker.h
diff --git a/components/ntp_snippets/section_rankers/section_ranker.h b/components/ntp_snippets/section_rankers/section_ranker.h
new file mode 100644
index 0000000000000000000000000000000000000000..6fe55babe76700aee0d2b187f4f7b4b5d9b6f173
--- /dev/null
+++ b/components/ntp_snippets/section_rankers/section_ranker.h
@@ -0,0 +1,42 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_NTP_SNIPPETS_SECTION_RANKERS_SECTION_RANKER_H_
+#define COMPONENTS_NTP_SNIPPETS_SECTION_RANKERS_SECTION_RANKER_H_
+
+#include "base/time/time.h"
+#include "components/ntp_snippets/category.h"
+
+namespace ntp_snippets {
+
+// TODO(vitaliii): Ensure that changes in the order are propagated to the UI.
Marc Treib 2016/12/13 12:22:42 This should have a bug assigned.
vitaliii 2016/12/14 08:59:38 Done.
+
+// Orders sections (represented as categories).
+// The order can be changed.
Marc Treib 2016/12/13 12:22:42 What does this mean?
vitaliii 2016/12/14 08:59:38 Done.
+class SectionRanker {
Marc Treib 2016/12/13 12:22:42 CategoryRanker. "Section" is the UI term, which we
vitaliii 2016/12/14 08:59:38 Done.
+ public:
+ // Compare two categories. True means that |left| precedes |right|, i.e. it
Marc Treib 2016/12/13 12:22:42 "Compares two categories", similar below. The styl
vitaliii 2016/12/14 08:59:38 Done.
+ // must be located earlier (above) on the NTP. This method must satisfy
+ // "Compare" contract required by sort algorithms.
+ virtual bool Compare(Category left, Category right) const = 0;
+
+ // Delete all history related data between |begin| and |end|. The order
+ // after this call should not reflect the history in any way.
Marc Treib 2016/12/13 12:22:42 After this call, the category order may not depend
vitaliii 2016/12/14 08:59:38 Done.
+ virtual void ClearHistory(base::Time begin, base::Time end) = 0;
+
+ // If there is no previous data for |category|, it is added to the end with
+ // the score 0, otherwise does nothing. Before the data for new categories
Marc Treib 2016/12/13 12:22:42 "score 0" is an implementation detail of some poss
vitaliii 2016/12/14 08:59:38 Done.
+ // is obtained, the order of the categories must be the same as the order
+ // they have been added in.
+ virtual void AppendCategoryIfNecessary(Category category) = 0;
+
+ // Feedback data from the user to update the ranking.
+
+ // Suggestion click data.
Marc Treib 2016/12/13 12:22:42 This comment isn't useful. "Called whenever a sugg
vitaliii 2016/12/14 08:59:38 Done.
+ virtual void OnSuggestionOpened(Category category) = 0;
+};
+
+} // namespace ntp_snippets
+
+#endif // COMPONENTS_NTP_SNIPPETS_SECTION_RANKERS_SECTION_RANKER_H_

Powered by Google App Engine
This is Rietveld 408576698