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

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

Issue 1269083005: [Android] Reland CommandLine reset listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | chrome/android/java/src/org/chromium/chrome/browser/util/FeatureUtilities.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/CommandLine.java
diff --git a/base/android/java/src/org/chromium/base/CommandLine.java b/base/android/java/src/org/chromium/base/CommandLine.java
index 9f5407921a9fd492f760d9e9ab2875cc99dcb5a8..409329cfabf8ec6b05adec145155e75f3e973ad8 100644
--- a/base/android/java/src/org/chromium/base/CommandLine.java
+++ b/base/android/java/src/org/chromium/base/CommandLine.java
@@ -16,6 +16,7 @@ import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
/**
@@ -25,6 +26,15 @@ import java.util.concurrent.atomic.AtomicReference;
* ContentShellApplication.COMMAND_LINE_FILE or ChromeShellApplication.COMMAND_LINE_FILE.
**/
public abstract class CommandLine {
+ /**
+ * Allows classes who cache command line flags to be notified when those arguments are updated
+ * at runtime. This happens in tests.
+ */
+ public interface ResetListener {
+ /** Called when the command line arguments are reset. */
+ void onCommandLineReset();
+ }
+
// Public abstract interface, implemented in derived classes.
// All these methods reflect their native-side counterparts.
/**
@@ -87,6 +97,7 @@ public abstract class CommandLine {
return false;
}
+ private static final List<ResetListener> sResetListeners = new ArrayList<>();
private static final AtomicReference<CommandLine> sCommandLine =
new AtomicReference<CommandLine>();
@@ -132,6 +143,20 @@ public abstract class CommandLine {
@VisibleForTesting
public static void reset() {
setInstance(null);
+ ThreadUtils.postOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ for (ResetListener listener : sResetListeners) listener.onCommandLineReset();
+ }
+ });
+ }
+
+ public static void addResetListener(ResetListener listener) {
+ sResetListeners.add(listener);
+ }
+
+ public static void removeResetListener(ResetListener listener) {
+ sResetListeners.remove(listener);
}
/**
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/util/FeatureUtilities.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698