Index: content/public/android/java/src/org/chromium/content/common/CommandLine.java |
diff --git a/content/public/android/java/src/org/chromium/content/common/CommandLine.java b/content/public/android/java/src/org/chromium/content/common/CommandLine.java |
index 8956650e0e0ce5fe5f54fcf997dfecb47014e69d..1620c0f34c33c8f4142ada9a7665957e989600ca 100644 |
--- a/content/public/android/java/src/org/chromium/content/common/CommandLine.java |
+++ b/content/public/android/java/src/org/chromium/content/common/CommandLine.java |
@@ -125,8 +125,9 @@ public abstract class CommandLine { |
// Equivalent to CommandLine::ForCurrentProcess in C++. |
public static CommandLine getInstance() { |
- assert sCommandLine.get() != null; |
- return sCommandLine.get(); |
+ CommandLine commandLine = sCommandLine.get(); |
+ assert commandLine != null; |
+ return commandLine; |
} |
/** |
@@ -135,8 +136,7 @@ public abstract class CommandLine { |
* @param args command line flags in 'argv' format: args[0] is the program name. |
*/ |
public static void init(String[] args) { |
- assert sCommandLine.get() == null; |
- sCommandLine.compareAndSet(null, new JavaCommandLine(args)); |
+ setInstance(new JavaCommandLine(args)); |
} |
/** |
@@ -162,10 +162,7 @@ public abstract class CommandLine { |
* command line initialization to be re-run including the call to onJniLoaded. |
*/ |
public static void reset() { |
- if (sCommandLine.get() != null && sCommandLine.get().isNativeImplementation()) { |
- nativeReset(); |
- } |
- sCommandLine.set(null); |
+ setInstance(null); |
} |
/** |
@@ -229,6 +226,13 @@ public abstract class CommandLine { |
return null; |
} |
+ private static void setInstance(CommandLine commandLine) { |
+ CommandLine oldCommandLine = sCommandLine.getAndSet(commandLine); |
+ if (oldCommandLine != null && oldCommandLine.isNativeImplementation()) { |
+ nativeReset(); |
+ } |
+ } |
+ |
/** |
* @param fileName the file to read in. |
* @param sizeLimit cap on the file size: will throw an exception if exceeded |