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

Unified Diff: content/public/android/java/src/org/chromium/content/common/CommandLine.java

Issue 11103016: [Android] Upstreaming CommandLine.java diff (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
« 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: 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
« 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