Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java |
index ca67c875eaf62a34432c43bb5853044c45e3dc44..7022ef318d8d07909215a9e15830a78a08f042f5 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java |
@@ -60,6 +60,8 @@ |
protected WebappInfo mWebappInfo; |
+ private boolean mOldWebappCleanupStarted; |
+ |
private ViewGroup mSplashScreen; |
private WebappUrlBar mUrlBar; |
@@ -124,23 +126,7 @@ |
@Override |
public void preInflationStartup() { |
WebappInfo info = WebappInfo.create(getIntent()); |
- |
- String id = ""; |
- if (info != null) { |
- mWebappInfo = info; |
- id = info.id(); |
- } |
- |
- // Initialize the WebappRegistry and warm up the shared preferences for this web app. No-ops |
- // if the registry and this web app are already initialized. Must override Strict Mode to |
- // avoid a violation. |
- StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); |
- try { |
- WebappRegistry.getInstance(); |
- WebappRegistry.warmUpSharedPrefsForId(id); |
- } finally { |
- StrictMode.setThreadPolicy(oldPolicy); |
- } |
+ if (info != null) mWebappInfo = info; |
ScreenOrientationProvider.lockOrientation((byte) mWebappInfo.orientation(), this); |
super.preInflationStartup(); |
@@ -209,6 +195,13 @@ |
updateTaskDescription(); |
} |
super.onResume(); |
+ |
+ // Kick off the old web app cleanup (if we haven't already) now that we have queued the |
+ // current web app's storage to be opened. |
+ if (!mOldWebappCleanupStarted) { |
+ WebappRegistry.unregisterOldWebapps(System.currentTimeMillis()); |
+ mOldWebappCleanupStarted = true; |
+ } |
} |
@Override |
@@ -269,20 +262,25 @@ |
} |
protected void initializeSplashScreenWidgets(final int backgroundColor) { |
- WebappDataStorage storage = |
- WebappRegistry.getInstance().getWebappDataStorage(mWebappInfo.id()); |
- if (storage == null) { |
- onStorageIsNull(backgroundColor); |
- return; |
- } |
- |
- updateStorage(storage); |
- storage.getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>() { |
- @Override |
- public void onDataRetrieved(Bitmap splashImage) { |
- initializeSplashScreenWidgets(backgroundColor, splashImage); |
- } |
- }); |
+ WebappRegistry.getWebappDataStorage( |
+ mWebappInfo.id(), new WebappRegistry.FetchWebappDataStorageCallback() { |
+ @Override |
+ public void onWebappDataStorageRetrieved(WebappDataStorage storage) { |
+ if (storage == null) { |
+ onStorageIsNull(backgroundColor); |
+ return; |
+ } |
+ updateStorage(storage); |
+ |
+ // Retrieve the splash image if it exists. |
+ storage.getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>() { |
+ @Override |
+ public void onDataRetrieved(Bitmap splashImage) { |
+ initializeSplashScreenWidgets(backgroundColor, splashImage); |
+ } |
+ }); |
+ } |
+ }); |
} |
protected void onStorageIsNull(int backgroundColor) {} |