Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/ActivityAssigner.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/ActivityAssigner.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/ActivityAssigner.java |
index cb0abe5b740f8264b2a5eea614d9971c65bc1dfa..a05bdf7f0836052b7d3454f7e7d6e2749e6a6ef7 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/ActivityAssigner.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/ActivityAssigner.java |
@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.webapps; |
import android.content.Context; |
import android.content.SharedPreferences; |
-import android.os.StrictMode; |
import android.util.Log; |
import org.chromium.base.ThreadUtils; |
@@ -73,6 +72,14 @@ public class ActivityAssigner { |
private final Context mContext; |
private final List<ActivityEntry> mActivityList; |
+ /** |
+ * Pre-load shared prefs to avoid being blocked on the |
+ * disk access async task in the future. |
+ */ |
+ public static void warmUpSharedPrefs(Context context) { |
+ context.getSharedPreferences(PREF_PACKAGE, Context.MODE_PRIVATE); |
+ } |
+ |
static class ActivityEntry { |
final int mActivityIndex; |
final String mWebappId; |
@@ -205,23 +212,7 @@ public class ActivityAssigner { |
// Restore any entries that were previously saved. If it seems that the preferences have |
// been corrupted somehow, just discard the whole map. |
- // Temporarily allowing disk access while fixing. TODO: http://crbug.com/562189 |
- SharedPreferences prefs = null; |
- StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); |
- try { |
- prefs = mContext.getSharedPreferences(PREF_PACKAGE, Context.MODE_PRIVATE); |
- try { |
- // Immediately try to query from the new prefs object. This will more reliably force |
- // the StrictMode violation to happen right away if there's going to be one. |
- // This is a bit of a hack and should be removed when we fix the violation |
- // TODO: http://crbug.com/562189. |
- prefs.getInt(PREF_NUM_SAVED_ENTRIES, 0); |
- } catch (ClassCastException exception) { |
- } |
- } finally { |
- StrictMode.setThreadPolicy(oldPolicy); |
- } |
- |
+ SharedPreferences prefs = mContext.getSharedPreferences(PREF_PACKAGE, Context.MODE_PRIVATE); |
try { |
final int numSavedEntries = prefs.getInt(PREF_NUM_SAVED_ENTRIES, 0); |
if (numSavedEntries <= NUM_WEBAPP_ACTIVITIES) { |
@@ -268,22 +259,7 @@ public class ActivityAssigner { |
* Saves the mapping between webapps and WebappActivities. |
*/ |
private void storeActivityList() { |
- // Temporarily allowing disk access while fixing. TODO: http://crbug.com/562189 |
- SharedPreferences prefs = null; |
- StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); |
- try { |
- prefs = mContext.getSharedPreferences(PREF_PACKAGE, Context.MODE_PRIVATE); |
- try { |
- // Immediately try to query from the new prefs object. This will more reliably force |
- // the StrictMode violation to happen right away if there's going to be one. |
- // This is a bit of a hack and should be removed when we fix the violation |
- // TODO: http://crbug.com/562189. |
- prefs.getInt(PREF_NUM_SAVED_ENTRIES, 0); |
- } catch (ClassCastException exception) { |
- } |
- } finally { |
- StrictMode.setThreadPolicy(oldPolicy); |
- } |
+ SharedPreferences prefs = mContext.getSharedPreferences(PREF_PACKAGE, Context.MODE_PRIVATE); |
SharedPreferences.Editor editor = prefs.edit(); |
editor.clear(); |
editor.putInt(PREF_NUM_SAVED_ENTRIES, mActivityList.size()); |