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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/init/ChromeBrowserInitializer.java

Issue 1867463003: Avoid disk read when warming shared prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Execute async task only for N. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/init/ChromeBrowserInitializer.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/ChromeBrowserInitializer.java b/chrome/android/java/src/org/chromium/chrome/browser/init/ChromeBrowserInitializer.java
index 08ed6fa80406b9a65899923bf6704ec3cc76e81a..554602b1dc6979f8038e0666411f463263cb76b6 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/init/ChromeBrowserInitializer.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/init/ChromeBrowserInitializer.java
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.init;
import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
+import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
@@ -160,13 +161,25 @@ public class ChromeBrowserInitializer {
}
/**
- * Pre-load shared prefs to avoid being blocked on the
- * disk access async task in the future.
+ * Pre-load shared prefs to avoid being blocked on the disk access async task in the future.
+ * Running in an AsyncTask as pre-loading itself may cause I/O.
*/
private void warmUpSharedPrefs() {
- PreferenceManager.getDefaultSharedPreferences(mApplication);
- DocumentTabModelImpl.warmUpSharedPrefs(mApplication);
- ActivityAssigner.warmUpSharedPrefs(mApplication);
+ if (Build.VERSION.CODENAME.equals("N")) {
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... params) {
+ PreferenceManager.getDefaultSharedPreferences(mApplication);
+ DocumentTabModelImpl.warmUpSharedPrefs(mApplication);
+ ActivityAssigner.warmUpSharedPrefs(mApplication);
+ return null;
+ }
+ }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ } else {
+ PreferenceManager.getDefaultSharedPreferences(mApplication);
+ DocumentTabModelImpl.warmUpSharedPrefs(mApplication);
+ ActivityAssigner.warmUpSharedPrefs(mApplication);
+ }
}
private void preInflationStartup() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698