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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java

Issue 2397623004: Revert of [Reland] Refactor WebappRegistry into a singleton instance. (Closed)
Patch Set: Created 4 years, 2 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/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) {}

Powered by Google App Engine
This is Rietveld 408576698