Index: android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java |
diff --git a/android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java b/android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java |
index 27331a89ab9eb92b3ea300b7a7a6f0d829377db8..0d8c86747cc0d8f1bf3e06951d91b7e169dc91f7 100644 |
--- a/android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java |
+++ b/android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java |
@@ -4,6 +4,7 @@ |
package org.chromium.android_webview.crash; |
+import org.chromium.android_webview.command_line.CommandLineUtil; |
import org.chromium.base.CommandLine; |
import org.chromium.base.annotations.SuppressFBWarnings; |
@@ -13,17 +14,20 @@ import org.chromium.base.annotations.SuppressFBWarnings; |
class SynchronizedWebViewCommandLine { |
private static final Object sLock = new Object(); |
private static InitState sInitialized = InitState.NOT_STARTED; |
- // TODO(gsennton): this value is used in WebViewChromiumFactoryProvider as well - set it |
- // somewhere where it can be read from both classes. |
- private static final String WEBVIEW_COMMAND_LINE_FILE = "/data/local/tmp/webview-command-line"; |
private enum InitState { NOT_STARTED, STARTED, DONE } |
+ private SynchronizedWebViewCommandLine() {} |
+ |
+ public static SynchronizedWebViewCommandLine getInstance() { |
+ return new SynchronizedWebViewCommandLine(); |
sgurun-gerrit only
2017/01/24 08:58:49
why is it necessary to be able to create different
gsennton
2017/01/24 10:41:48
To be able to mock the behaviour of SynchronizedWe
|
+ } |
+ |
/** |
* Initialize the global CommandLine using the WebView command line file. |
* This method includes IO operations - it shouldn't be performed on the main thread. |
*/ |
- public static void initOnSeparateThread() { |
+ public void initOnSeparateThread() { |
synchronized (sLock) { |
if (sInitialized != InitState.NOT_STARTED) return; |
sInitialized = InitState.STARTED; |
@@ -32,7 +36,12 @@ class SynchronizedWebViewCommandLine { |
@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") |
@Override |
public void run() { |
- CommandLine.initFromFile(WEBVIEW_COMMAND_LINE_FILE); |
+ // Only read command line flags if the device is debuggable. |
+ if (CommandLineUtil.isBuildDebuggable()) { |
+ CommandLine.initFromFile(CommandLineUtil.WEBVIEW_COMMAND_LINE_FILE); |
+ } else { |
+ CommandLine.init(null); |
+ } |
synchronized (sLock) { |
sInitialized = InitState.DONE; |
sLock.notifyAll(); |
@@ -44,7 +53,7 @@ class SynchronizedWebViewCommandLine { |
/** |
* Returns true if this command line contains the given switch. |
*/ |
- public static boolean hasSwitch(String switchString) { |
+ public boolean hasSwitch(String switchString) { |
synchronized (sLock) { |
while (sInitialized != InitState.DONE) { |
try { |