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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java

Issue 2351113005: [Reland] Refactor WebappRegistry into a singleton instance. (Closed)
Patch Set: Comments 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/notifications/NotificationService.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java
index 4b3eed1e42f5228c0b6222a9cef9abfbfe85c03f..176e45f0c1971127f3ff9a03fc8bf119f57f6ffd 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java
@@ -8,12 +8,14 @@ import android.app.IntentService;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.os.StrictMode;
import android.util.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.library_loader.ProcessInitException;
import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
+import org.chromium.chrome.browser.webapps.WebappRegistry;
/**
* The Notification service receives intents fired as responses to user actions issued on Android
@@ -76,6 +78,18 @@ public class NotificationService extends IntentService {
try {
ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup();
+ // Warm up the WebappRegistry, as we need to check if this notification should launch a
+ // standalone web app. This no-ops if the registry is already initialized and warmed,
+ // but triggers a strict mode violation otherwise (i.e. the browser isn't running).
+ // Temporarily disable strict mode to work around the violation.
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+ try {
+ WebappRegistry.getInstance();
+ WebappRegistry.warmUpSharedPrefs();
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
+ }
+
// Now that the browser process is initialized, we pass forward the call to the
// NotificationPlatformBridge which will take care of delivering the appropriate events.
if (!NotificationPlatformBridge.dispatchNotificationEvent(intent)) {

Powered by Google App Engine
This is Rietveld 408576698