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

Unified Diff: chrome/browser/android/precache/precache_launcher.cc

Issue 1266243003: Tweaks to the precache triggering code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 4 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/precache/precache_launcher.cc
diff --git a/chrome/browser/android/precache/precache_launcher.cc b/chrome/browser/android/precache/precache_launcher.cc
index 6b89d59570afe2aa066f298253cebcb0f0b2711c..62be4d6d5eb9a93945839b577442666365cbd801 100644
--- a/chrome/browser/android/precache/precache_launcher.cc
+++ b/chrome/browser/android/precache/precache_launcher.cc
@@ -65,10 +65,8 @@ void PrecacheLauncher::Start(JNIEnv* env, jobject obj) {
history::HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::IMPLICIT_ACCESS);
- if (precache_manager == nullptr || hs == nullptr ||
- !precache_manager->IsPrecachingAllowed()) {
- Java_PrecacheLauncher_onPrecacheCompletedCallback(
- env, weak_java_precache_launcher_.get(env).obj());
+ if (precache_manager == nullptr || hs == nullptr) {
+ OnPrecacheCompleted();
return;
}
@@ -95,8 +93,11 @@ static jlong Init(JNIEnv* env, jobject obj) {
return reinterpret_cast<intptr_t>(new PrecacheLauncher(env, obj));
}
-static jboolean IsPrecachingEnabled(JNIEnv* env, jclass clazz) {
- return PrecacheManager::IsPrecachingEnabled();
+// Must be run on the UI thread.
+static jboolean ShouldRun(JNIEnv* env, jobject obj) {
+ Profile* profile = GetProfile();
+ PrecacheManager* precache_manager = GetPrecacheManager(profile);
+ return precache_manager && precache_manager->ShouldRun();
}
bool RegisterPrecacheLauncher(JNIEnv* env) {

Powered by Google App Engine
This is Rietveld 408576698