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

Unified Diff: chrome/browser/ui/webui/snippets_internals_message_handler.cc

Issue 2557363002: [NTP Snippets] Refactor background scheduling for remote suggestions (Closed)
Patch Set: Make unit-tests pass 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: chrome/browser/ui/webui/snippets_internals_message_handler.cc
diff --git a/chrome/browser/ui/webui/snippets_internals_message_handler.cc b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
index 988dc19ce21135d458c7272408c78501d1934be9..15433dedce67abb695bc2d0cb999a86aba07c921 100644
--- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
@@ -80,7 +80,7 @@ std::string GetCategoryStatusName(CategoryStatus status) {
SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler()
: content_suggestions_service_observer_(this),
dom_loaded_(false),
- ntp_snippets_service_(nullptr),
+ remote_suggestions_provider_(nullptr),
content_suggestions_service_(nullptr),
weak_ptr_factory_(this) {}
@@ -94,7 +94,8 @@ void SnippetsInternalsMessageHandler::RegisterMessages() {
ContentSuggestionsServiceFactory::GetInstance()->GetForProfile(profile);
content_suggestions_service_observer_.Add(content_suggestions_service_);
- ntp_snippets_service_ = content_suggestions_service_->ntp_snippets_service();
+ remote_suggestions_provider_ =
+ content_suggestions_service_->remote_suggestions_provider();
web_ui()->RegisterMessageCallback(
"refreshContent",
@@ -186,7 +187,7 @@ void SnippetsInternalsMessageHandler::HandleDownload(
SendString("hosts-status", std::string());
- if (!ntp_snippets_service_)
+ if (!remote_suggestions_provider_)
return;
std::string hosts_string;
@@ -197,7 +198,7 @@ void SnippetsInternalsMessageHandler::HandleDownload(
hosts_string, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
std::set<std::string> hosts(hosts_vector.begin(), hosts_vector.end());
- ntp_snippets_service_->FetchSnippetsFromHosts(hosts,
+ remote_suggestions_provider_->FetchSnippetsFromHosts(hosts,
/*interactive_request=*/true);
}
@@ -296,8 +297,9 @@ void SnippetsInternalsMessageHandler::SendAllContent() {
SendClassification();
- if (ntp_snippets_service_) {
- switch (ntp_snippets_service_->snippets_fetcher()->personalization()) {
+ if (remote_suggestions_provider_) {
+ switch (
+ remote_suggestions_provider_->snippets_fetcher()->personalization()) {
case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal:
SendString("switch-personalized", "Only personalized");
break;
@@ -310,12 +312,13 @@ void SnippetsInternalsMessageHandler::SendAllContent() {
break;
}
- SendString("switch-fetch-url",
- ntp_snippets_service_->snippets_fetcher()->fetch_url().spec());
+ SendString(
+ "switch-fetch-url",
+ remote_suggestions_provider_->snippets_fetcher()->fetch_url().spec());
web_ui()->CallJavascriptFunctionUnsafe(
"chrome.SnippetsInternals.receiveJson",
base::StringValue(
- ntp_snippets_service_->snippets_fetcher()->last_json()));
+ remote_suggestions_provider_->snippets_fetcher()->last_json()));
}
SendContentSuggestions();
@@ -374,9 +377,9 @@ void SnippetsInternalsMessageHandler::SendContentSuggestions() {
categories_list->Append(std::move(category_entry));
}
- if (ntp_snippets_service_) {
+ if (remote_suggestions_provider_) {
const std::string& status =
- ntp_snippets_service_->snippets_fetcher()->last_status();
+ remote_suggestions_provider_->snippets_fetcher()->last_status();
if (!status.empty())
SendString("hosts-status", "Finished: " + status);
}

Powered by Google App Engine
This is Rietveld 408576698