Skip to content

Commit

Permalink
WebUI NTP: return HTML with data available for promo/OGB
Browse files Browse the repository at this point in the history
If data is available, serve it immediately and refresh data. Most of the
time the data should be the same. The call should not wait until the
refresh completes before serving the data.

Change-Id: I8ed46e38f8256fa356645cdfc0019329b809ae67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2164992
Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763017}
  • Loading branch information
Esmael El-Moslimany authored and Commit Bot committed Apr 27, 2020
1 parent 5c7eabc commit 53ddacb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions chrome/browser/ui/webui/new_tab_page/untrusted_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ void UntrustedSource::StartDataRequest(
GURL url_param = GURL(url.query());
if (path == "one-google-bar" && one_google_bar_service_) {
one_google_bar_callbacks_.push_back(std::move(callback));
if (one_google_bar_callbacks_.size() == 1) {
one_google_bar_service_->Refresh();
if (one_google_bar_service_->one_google_bar_data().has_value()) {
OnOneGoogleBarDataUpdated();
}
one_google_bar_service_->Refresh();
return;
}
if (path == "one_google_bar.js") {
Expand All @@ -106,9 +107,10 @@ void UntrustedSource::StartDataRequest(
}
if (path == "promo" && promo_service_) {
promo_callbacks_.push_back(std::move(callback));
if (promo_callbacks_.size() == 1) {
promo_service_->Refresh();
if (promo_service_->promo_data().has_value()) {
OnPromoDataUpdated();
}
promo_service_->Refresh();
return;
}
if (path == "promo.js") {
Expand Down

0 comments on commit 53ddacb

Please sign in to comment.