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

Unified Diff: chrome/browser/android/ntp/ntp_snippets_bridge.cc

Issue 1888913002: [NTP Snippets] Refresh the displayed snippets less frequently (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and fix tests Created 4 years, 8 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: chrome/browser/android/ntp/ntp_snippets_bridge.cc
diff --git a/chrome/browser/android/ntp/ntp_snippets_bridge.cc b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
index b1154ceb7fe7c429fdbc60cd003f62fc899a03ac..89211d0d2b6f0483f8eac7bcf289ba92e9938af4 100644
--- a/chrome/browser/android/ntp/ntp_snippets_bridge.cc
+++ b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
@@ -41,14 +41,14 @@ NTPSnippetsBridge::NTPSnippetsBridge(JNIEnv* env,
: snippet_service_observer_(this) {
Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
ntp_snippets_service_ = NTPSnippetsServiceFactory::GetForProfile(profile);
+ snippet_service_observer_.Add(ntp_snippets_service_);
}
void NTPSnippetsBridge::SetObserver(JNIEnv* env,
const JavaParamRef<jobject>& obj,
const JavaParamRef<jobject>& j_observer) {
observer_.Reset(env, j_observer);
- // This will call NTPSnippetsServiceLoaded.
- snippet_service_observer_.Add(ntp_snippets_service_);
+ NTPSnippetsServiceLoaded();
}
NTPSnippetsBridge::~NTPSnippetsBridge() {}
@@ -65,7 +65,8 @@ void NTPSnippetsBridge::DiscardSnippet(JNIEnv* env,
}
void NTPSnippetsBridge::NTPSnippetsServiceLoaded() {
- DCHECK(!observer_.is_null());
+ if (observer_.is_null())
+ return;
std::vector<std::string> titles;
std::vector<std::string> urls;

Powered by Google App Engine
This is Rietveld 408576698