Commit 646065c9 authored by Nate Fischer's avatar Nate Fischer Committed by Commit Bot

Android: generate BaseSwitches from C++ switches

No change to logic. This generates BaseSwitches.java from
base_switches.cc, using java_cpp_strings. This adds a few Android-only
switches to base_switches.cc which were previously only defined by Java.
This removes AwSwitches.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH in
favor of BaseSwitches.ENABLE_CRASH_REPORTER_FOR_TESTING.

Fixed: 1112008
Test: autoninja -C out/Default system_webview_apk
Change-Id: Iadc10fcfeda880668e23a7bcb693a0636116fb7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337271
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796670}
parent a76d59e8
...@@ -27,6 +27,7 @@ import org.chromium.android_webview.metrics.AwNonembeddedUmaReplayer; ...@@ -27,6 +27,7 @@ import org.chromium.android_webview.metrics.AwNonembeddedUmaReplayer;
import org.chromium.android_webview.policy.AwPolicyProvider; import org.chromium.android_webview.policy.AwPolicyProvider;
import org.chromium.android_webview.proto.MetricsBridgeRecords.HistogramRecord; import org.chromium.android_webview.proto.MetricsBridgeRecords.HistogramRecord;
import org.chromium.android_webview.safe_browsing.AwSafeBrowsingConfigHelper; import org.chromium.android_webview.safe_browsing.AwSafeBrowsingConfigHelper;
import org.chromium.base.BaseSwitches;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
...@@ -185,7 +186,7 @@ public final class AwBrowserProcess { ...@@ -185,7 +186,7 @@ public final class AwBrowserProcess {
try (ScopedSysTraceEvent e1 = ScopedSysTraceEvent.scoped( try (ScopedSysTraceEvent e1 = ScopedSysTraceEvent.scoped(
"AwBrowserProcess.handleMinidumpsAndSetMetricsConsent")) { "AwBrowserProcess.handleMinidumpsAndSetMetricsConsent")) {
final boolean enableMinidumpUploadingForTesting = CommandLine.getInstance().hasSwitch( final boolean enableMinidumpUploadingForTesting = CommandLine.getInstance().hasSwitch(
AwSwitches.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH); BaseSwitches.ENABLE_CRASH_REPORTER_FOR_TESTING);
if (enableMinidumpUploadingForTesting) { if (enableMinidumpUploadingForTesting) {
handleMinidumps(true /* enabled */); handleMinidumps(true /* enabled */);
} }
......
...@@ -11,10 +11,6 @@ public final class AwSwitches {{ ...@@ -11,10 +11,6 @@ public final class AwSwitches {{
{NATIVE_STRINGS} {NATIVE_STRINGS}
// Native switch kEnableCrashReporterForTesting in //base/base_switches.h
public static final String CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH =
"enable-crash-reporter-for-testing";
// Do not instantiate this class. // Do not instantiate this class.
private AwSwitches() {{}} private AwSwitches() {{}}
}} }}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package org.chromium.android_webview.common; package org.chromium.android_webview.common;
import org.chromium.base.BaseSwitches;
import org.chromium.components.metrics.MetricsSwitches; import org.chromium.components.metrics.MetricsSwitches;
/** /**
...@@ -53,7 +54,7 @@ public final class ProductionSupportedFlagList { ...@@ -53,7 +54,7 @@ public final class ProductionSupportedFlagList {
+ "choice to opt-out."), + "choice to opt-out."),
Flag.commandLine(AwSwitches.WEBVIEW_LOG_JS_CONSOLE_MESSAGES, Flag.commandLine(AwSwitches.WEBVIEW_LOG_JS_CONSOLE_MESSAGES,
"Mirrors JavaScript console messages to system logs."), "Mirrors JavaScript console messages to system logs."),
Flag.commandLine(AwSwitches.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH, Flag.commandLine(BaseSwitches.ENABLE_CRASH_REPORTER_FOR_TESTING,
"Used for turning on Breakpad crash reporting in a debug environment where " "Used for turning on Breakpad crash reporting in a debug environment where "
+ "crash reporting is typically compiled but disabled."), + "crash reporting is typically compiled but disabled."),
Flag.commandLine("disable-gpu-rasterization", Flag.commandLine("disable-gpu-rasterization",
......
...@@ -32,7 +32,6 @@ import androidx.annotation.NonNull; ...@@ -32,7 +32,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread; import androidx.annotation.WorkerThread;
import org.chromium.android_webview.common.AwSwitches;
import org.chromium.android_webview.common.DeveloperModeUtils; import org.chromium.android_webview.common.DeveloperModeUtils;
import org.chromium.android_webview.common.PlatformServiceBridge; import org.chromium.android_webview.common.PlatformServiceBridge;
import org.chromium.android_webview.common.crash.CrashInfo; import org.chromium.android_webview.common.crash.CrashInfo;
...@@ -40,6 +39,7 @@ import org.chromium.android_webview.common.crash.CrashInfo.UploadState; ...@@ -40,6 +39,7 @@ import org.chromium.android_webview.common.crash.CrashInfo.UploadState;
import org.chromium.android_webview.common.crash.CrashUploadUtil; import org.chromium.android_webview.common.crash.CrashUploadUtil;
import org.chromium.android_webview.devui.util.CrashBugUrlFactory; import org.chromium.android_webview.devui.util.CrashBugUrlFactory;
import org.chromium.android_webview.devui.util.WebViewCrashInfoCollector; import org.chromium.android_webview.devui.util.WebViewCrashInfoCollector;
import org.chromium.base.BaseSwitches;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
...@@ -145,14 +145,13 @@ public class CrashesListFragment extends DevUiBaseFragment { ...@@ -145,14 +145,13 @@ public class CrashesListFragment extends DevUiBaseFragment {
} }
private boolean isCrashUploadsEnabledFromCommandLine() { private boolean isCrashUploadsEnabledFromCommandLine() {
return CommandLine.getInstance().hasSwitch( return CommandLine.getInstance().hasSwitch(BaseSwitches.ENABLE_CRASH_REPORTER_FOR_TESTING);
AwSwitches.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH);
} }
private boolean isCrashUploadsEnabledFromFlagsUi() { private boolean isCrashUploadsEnabledFromFlagsUi() {
if (DeveloperModeUtils.isDeveloperModeEnabled(mContext.getPackageName())) { if (DeveloperModeUtils.isDeveloperModeEnabled(mContext.getPackageName())) {
Boolean flagValue = DeveloperModeUtils.getFlagOverrides(mContext.getPackageName()) Boolean flagValue = DeveloperModeUtils.getFlagOverrides(mContext.getPackageName())
.get(AwSwitches.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH); .get(BaseSwitches.ENABLE_CRASH_REPORTER_FOR_TESTING);
return Boolean.TRUE.equals(flagValue); return Boolean.TRUE.equals(flagValue);
} }
return false; return false;
......
...@@ -9,9 +9,9 @@ import android.net.ConnectivityManager; ...@@ -9,9 +9,9 @@ import android.net.ConnectivityManager;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.android_webview.common.AwSwitches;
import org.chromium.android_webview.common.PlatformServiceBridge; import org.chromium.android_webview.common.PlatformServiceBridge;
import org.chromium.android_webview.common.crash.SystemWideCrashDirectories; import org.chromium.android_webview.common.crash.SystemWideCrashDirectories;
import org.chromium.base.BaseSwitches;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
...@@ -108,7 +108,7 @@ public class AwMinidumpUploaderDelegate implements MinidumpUploaderDelegate { ...@@ -108,7 +108,7 @@ public class AwMinidumpUploaderDelegate implements MinidumpUploaderDelegate {
// on the main thread, but before the current worker thread started - so this thread // on the main thread, but before the current worker thread started - so this thread
// will have seen the initialization of the CommandLine. // will have seen the initialization of the CommandLine.
return CommandLine.getInstance().hasSwitch( return CommandLine.getInstance().hasSwitch(
AwSwitches.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH); BaseSwitches.ENABLE_CRASH_REPORTER_FOR_TESTING);
} }
}; };
} }
......
...@@ -3458,12 +3458,20 @@ if (is_android) { ...@@ -3458,12 +3458,20 @@ if (is_android) {
jar_excluded_patterns = [ "*/BuildConfig.class" ] jar_excluded_patterns = [ "*/BuildConfig.class" ]
} }
java_cpp_strings("java_switches_srcjar") {
# External code should depend on ":base_java" instead.
visibility = [ ":*" ]
sources = [ "base_switches.cc" ]
template = "android/java/src/org/chromium/base/BaseSwitches.java.tmpl"
}
android_library("base_java") { android_library("base_java") {
srcjar_deps = [ srcjar_deps = [
":base_android_java_enums_srcjar", ":base_android_java_enums_srcjar",
":base_build_config_gen", ":base_build_config_gen",
":base_java_aidl", ":base_java_aidl",
":base_native_libraries_gen", ":base_native_libraries_gen",
":java_switches_srcjar",
] ]
deps = [ deps = [
...@@ -3481,7 +3489,6 @@ if (is_android) { ...@@ -3481,7 +3489,6 @@ if (is_android) {
"android/java/src/org/chromium/base/ApiCompatibilityUtils.java", "android/java/src/org/chromium/base/ApiCompatibilityUtils.java",
"android/java/src/org/chromium/base/ApkAssets.java", "android/java/src/org/chromium/base/ApkAssets.java",
"android/java/src/org/chromium/base/ApplicationStatus.java", "android/java/src/org/chromium/base/ApplicationStatus.java",
"android/java/src/org/chromium/base/BaseSwitches.java",
"android/java/src/org/chromium/base/BuildInfo.java", "android/java/src/org/chromium/base/BuildInfo.java",
"android/java/src/org/chromium/base/BundleUtils.java", "android/java/src/org/chromium/base/BundleUtils.java",
"android/java/src/org/chromium/base/Callback.java", "android/java/src/org/chromium/base/Callback.java",
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.base;
/**
* Contains all of the command line switches that are specific to the base/
* portion of Chromium on Android.
*/
public abstract class BaseSwitches {
// Block ChildProcessMain thread of render process service until a Java debugger is attached.
// To pause even earlier: am set-debug-app org.chromium.chrome:sandbox_process0
// However, this flag is convenient when you don't know the process number, or want
// all renderers to pause (set-debug-app applies to only one process at a time).
public static final String RENDERER_WAIT_FOR_JAVA_DEBUGGER = "renderer-wait-for-java-debugger";
// Force low-end device mode when set.
public static final String ENABLE_LOW_END_DEVICE_MODE = "enable-low-end-device-mode";
// Force disabling of low-end device mode when set.
public static final String DISABLE_LOW_END_DEVICE_MODE = "disable-low-end-device-mode";
// Adds additional thread idle time information into the trace event output.
public static final String ENABLE_IDLE_TRACING = "enable-idle-tracing";
// Default country code to be used for search engine localization.
public static final String DEFAULT_COUNTRY_CODE_AT_INSTALL = "default-country-code";
// Enables the reached code profiler.
public static final String ENABLE_REACHED_CODE_PROFILER = "enable-reached-code-profiler";
// Specifies the profiling interval for reached code profiler in microseconds.
public static final String REACHED_CODE_SAMPLING_INTERVAL_US =
"reached-code-sampling-interval-us";
// Comma-separated list of feature names to enable.
public static final String ENABLE_FEATURES = "enable-features";
// This option can be used to force field trials when testing changes locally.
public static final String FORCE_FIELD_TRIALS_SWITCH = "force-fieldtrials";
// The field trial parameters and their values when testing changes locally.
public static final String FORCE_FIELD_TRIAL_PARAMS_SWITCH = "force-fieldtrial-params";
// Prevent instantiation.
private BaseSwitches() {}
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.base;
/**
* Contains all of the command line switches that are specific to the base/
* portion of Chromium on Android.
*/
public final class BaseSwitches {{
{NATIVE_STRINGS}
// Prefer CommonSwitches.RENDERER_WAIT_FOR_JAVA_DEBUGGER where possible.
// Block ChildProcessMain thread of render process service until a Java debugger
// is attached. To pause even earlier: am set-debug-app
// org.chromium.chrome:sandbox_process0 However, this flag is convenient when
// you don't know the process number, or want all renderers to pause
// (set-debug-app applies to only one process at a time).
public static final String RENDERER_WAIT_FOR_JAVA_DEBUGGER = "renderer-wait-for-java-debugger";
// Prevent instantiation.
private BaseSwitches() {{}}
}}
...@@ -140,6 +140,16 @@ const char kEnableReachedCodeProfiler[] = "enable-reached-code-profiler"; ...@@ -140,6 +140,16 @@ const char kEnableReachedCodeProfiler[] = "enable-reached-code-profiler";
// Specifies the profiling interval in microseconds for reached code profiler. // Specifies the profiling interval in microseconds for reached code profiler.
const char kReachedCodeSamplingIntervalUs[] = const char kReachedCodeSamplingIntervalUs[] =
"reached-code-sampling-interval-us"; "reached-code-sampling-interval-us";
// Default country code to be used for search engine localization.
const char kDefaultCountryCodeAtInstall[] = "default-country-code";
// Adds additional thread idle time information into the trace event output.
const char kEnableIdleTracing[] = "enable-idle-tracing";
// The field trial parameters and their values when testing changes locally.
const char kForceFieldTrialParams[] = "force-fieldtrial-params";
#endif #endif
#if defined(OS_LINUX) #if defined(OS_LINUX)
......
...@@ -50,7 +50,9 @@ extern const char kEnableCrashReporterForTesting[]; ...@@ -50,7 +50,9 @@ extern const char kEnableCrashReporterForTesting[];
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
extern const char kEnableReachedCodeProfiler[]; extern const char kEnableReachedCodeProfiler[];
extern const char kReachedCodeSamplingIntervalUs[]; extern const char kReachedCodeSamplingIntervalUs[];
extern const char kOrderfileMemoryOptimization[]; extern const char kDefaultCountryCodeAtInstall[];
extern const char kEnableIdleTracing[];
extern const char kForceFieldTrialParams[];
#endif #endif
#if defined(OS_LINUX) #if defined(OS_LINUX)
......
...@@ -108,10 +108,9 @@ public class FieldTrials { ...@@ -108,10 +108,9 @@ public class FieldTrials {
*/ */
public void applyFieldTrials() { public void applyFieldTrials() {
CommandLine commandLine = CommandLine.getInstance(); CommandLine commandLine = CommandLine.getInstance();
String forceFieldTrials = String forceFieldTrials = commandLine.getSwitchValue(BaseSwitches.FORCE_FIELD_TRIALS);
commandLine.getSwitchValue(BaseSwitches.FORCE_FIELD_TRIALS_SWITCH);
String forceFieldTrialParams = String forceFieldTrialParams =
commandLine.getSwitchValue(BaseSwitches.FORCE_FIELD_TRIAL_PARAMS_SWITCH); commandLine.getSwitchValue(BaseSwitches.FORCE_FIELD_TRIAL_PARAMS);
String enableFeatures = commandLine.getSwitchValue(BaseSwitches.ENABLE_FEATURES); String enableFeatures = commandLine.getSwitchValue(BaseSwitches.ENABLE_FEATURES);
Set<String> enableFeaturesSet = new HashSet<>(); Set<String> enableFeaturesSet = new HashSet<>();
...@@ -145,9 +144,9 @@ public class FieldTrials { ...@@ -145,9 +144,9 @@ public class FieldTrials {
} catch (Exception e) { } catch (Exception e) {
assert false : e.toString() + "\n" assert false : e.toString() + "\n"
+ "The format of field trials parameters declared isn't correct:" + "The format of field trials parameters declared isn't correct:"
+ BaseSwitches.FORCE_FIELD_TRIALS_SWITCH + "=" + forceFieldTrials + ", " + BaseSwitches.FORCE_FIELD_TRIALS + "=" + forceFieldTrials + ", "
+ BaseSwitches.FORCE_FIELD_TRIAL_PARAMS_SWITCH + "=" + forceFieldTrialParams + BaseSwitches.FORCE_FIELD_TRIAL_PARAMS + "=" + forceFieldTrialParams + ", "
+ ", " + BaseSwitches.ENABLE_FEATURES + "=" + enableFeatures + "."; + BaseSwitches.ENABLE_FEATURES + "=" + enableFeatures + ".";
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment