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

Unified Diff: components/ntp_snippets/section_rankers/default_constant_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/default_constant_section_ranker.h
diff --git a/components/ntp_snippets/section_rankers/default_constant_section_ranker.h b/components/ntp_snippets/section_rankers/default_constant_section_ranker.h
new file mode 100644
index 0000000000000000000000000000000000000000..c2944dc840c158c4e639169d3547ca781123bd13
--- /dev/null
+++ b/components/ntp_snippets/section_rankers/default_constant_section_ranker.h
@@ -0,0 +1,40 @@
+// 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_DEFAULT_CONSTANT_SECTION_RANKER_H_
+#define COMPONENTS_NTP_SNIPPETS_SECTION_RANKERS_DEFAULT_CONSTANT_SECTION_RANKER_H_
+
+#include <vector>
+
+#include "base/time/time.h"
+#include "components/ntp_snippets/category.h"
+#include "components/ntp_snippets/section_rankers/section_ranker.h"
+
+namespace ntp_snippets {
+
+// TODO(vitaliii): Add unit tests.
Marc Treib 2016/12/13 12:22:42 Yes please. At the very least, port the CategoryFa
vitaliii 2016/12/14 08:59:38 But not in this CL.
Marc Treib 2016/12/14 10:24:31 No need to write additional tests in this CL, but
vitaliii 2016/12/15 15:30:12 Done.
+class DefaultConstantSectionRanker : public SectionRanker {
Marc Treib 2016/12/13 12:22:42 Remove the "Default" - that's not part of the clas
vitaliii 2016/12/14 08:59:38 Done.
+ public:
+ DefaultConstantSectionRanker();
+ virtual ~DefaultConstantSectionRanker();
+
+ bool Compare(Category left, Category right) const override;
Marc Treib 2016/12/13 12:22:42 nitty nit: Add a "CategoryRanker implementation."
vitaliii 2016/12/14 08:59:38 Done.
+
+ void ClearHistory(base::Time begin, base::Time end) override;
+
+ void AppendCategoryIfNecessary(Category category) override;
+
+ void OnSuggestionOpened(Category category) override;
+
+ private:
+ void AppendKnownCategory(KnownCategories known_category);
+
+ std::vector<Category> ordered_categories_;
+
+ DISALLOW_COPY_AND_ASSIGN(DefaultConstantSectionRanker);
+};
+
+} // namespace ntp_snippets
+
+#endif // COMPONENTS_NTP_SNIPPETS_SECTION_RANKERS_DEFAULT_CONSTANT_SECTION_RANKER_H_

Powered by Google App Engine
This is Rietveld 408576698