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

Unified Diff: components/ntp_snippets/category_rankers/constant_category_ranker.cc

Issue 2889153003: [NTP::SectionOrder] Add ranker section to snippets internals. (Closed)
Patch Set: jkrcal@ nit. Created 3 years, 7 months 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/category_rankers/constant_category_ranker.cc
diff --git a/components/ntp_snippets/category_rankers/constant_category_ranker.cc b/components/ntp_snippets/category_rankers/constant_category_ranker.cc
index 828cd317e5d766fa5a170e3217e5c706f1b5c391..d68fe9104d432377c81e5f347d0925149200d87f 100644
--- a/components/ntp_snippets/category_rankers/constant_category_ranker.cc
+++ b/components/ntp_snippets/category_rankers/constant_category_ranker.cc
@@ -5,6 +5,8 @@
#include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
#include "base/stl_util.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
#include "components/ntp_snippets/features.h"
namespace ntp_snippets {
@@ -75,6 +77,33 @@ void ConstantCategoryRanker::InsertCategoryAfterIfNecessary(
AppendCategoryIfNecessary(category_to_insert);
}
+std::vector<CategoryRanker::DebugDataItem>
+ConstantCategoryRanker::GetDebugData() {
+ std::vector<CategoryRanker::DebugDataItem> result;
+ result.push_back(
+ CategoryRanker::DebugDataItem("Type", "ConstantCategoryRanker"));
+
+ std::string initial_order_type;
+ CategoryOrderChoice choice = GetSelectedCategoryOrder();
+ if (choice == CategoryOrderChoice::GENERAL) {
+ initial_order_type = "GENERAL";
+ }
+ if (choice == CategoryOrderChoice::EMERGING_MARKETS_ORIENTED) {
+ initial_order_type = "EMERGING_MARKETS_ORIENTED;";
+ }
+ result.push_back(
+ CategoryRanker::DebugDataItem("Initial order type", initial_order_type));
+
+ std::vector<std::string> category_strings;
+ for (Category category : ordered_categories_) {
+ category_strings.push_back(base::IntToString(category.id()));
+ }
+ result.push_back(CategoryRanker::DebugDataItem(
+ "Current order", base::JoinString(category_strings, ", ")));
+
+ return result;
+}
+
void ConstantCategoryRanker::OnSuggestionOpened(Category category) {
// Ignored. The order is constant.
}

Powered by Google App Engine
This is Rietveld 408576698