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

Unified Diff: base/android/java/src/org/chromium/base/ContextUtils.java

Issue 2242173003: Ignore multiple assignments to global context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODO. Created 4 years, 4 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: base/android/java/src/org/chromium/base/ContextUtils.java
diff --git a/base/android/java/src/org/chromium/base/ContextUtils.java b/base/android/java/src/org/chromium/base/ContextUtils.java
index 4b615cb3ea93160c5d55ad37905335d1a64c17db..252b50bc9bd6c06a72997cd40d60af4ddb3952be 100644
--- a/base/android/java/src/org/chromium/base/ContextUtils.java
+++ b/base/android/java/src/org/chromium/base/ContextUtils.java
@@ -54,7 +54,14 @@ public class ContextUtils {
// Conceding that occasionally in tests, native is loaded before the browser process is
// started, in which case the browser process re-sets the application context.
if (sApplicationContext != null && sApplicationContext != appContext) {
- throw new RuntimeException("Attempting to set multiple global application contexts.");
+ // For webview, sometimes the client app overrides getApplicationContext in a poor way
+ // and fails to make it idempotent. We cannot crash in this scenario, so we ignore new
+ // assignments and assume that the first initialized context is the right application
+ // object. See http://crbug.com/637389.
+ // TODO(wnwen): Add runtime exception back once the underlying issue in LibraryLoader is
+ // fixed.
+ Log.d(TAG, "Multiple contexts detected, ignoring new application context.");
+ return;
}
initJavaSideApplicationContext(appContext);
}
« 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