Skip to content

Commit

Permalink
Add disable-best-effort-tasks to Chrome flags
Browse files Browse the repository at this point in the history
The new flag can be switched on and off on "chrome://flags". It is
disabled by default, and if turned on, all tasks of lowest priority
"base::TaskPriority::BEST_EFFORT" will not be executed. This is
equivalent to the command line flag "--disable-best-effort-tasks".

Change-Id: Ic098e08f9f61b7ad8239da52d779c4660074ba5c
Reviewed-on: https://chromium-review.googlesource.com/c/1452488
Commit-Queue: Yue Ru Sun <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: François Doray <[email protected]>
Cr-Commit-Position: refs/heads/master@{#630198}
  • Loading branch information
protostellarsun authored and Commit Bot committed Feb 8, 2019
1 parent 557ce1d commit a50a80f
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion base/base_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace switches {

// Delays execution of base::TaskPriority::BEST_EFFORT tasks until shutdown.
const char kDisableBackgroundTasks[] = "disable-background-tasks";
const char kDisableBestEffortTasks[] = "disable-best-effort-tasks";

// Disables the crash reporting.
const char kDisableBreakpad[] = "disable-breakpad";
Expand Down
2 changes: 1 addition & 1 deletion base/base_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace switches {

extern const char kDisableBackgroundTasks[];
extern const char kDisableBestEffortTasks[];
extern const char kDisableBreakpad[];
extern const char kDisableFeatures[];
extern const char kDisableLowEndDeviceMode[];
Expand Down
2 changes: 1 addition & 1 deletion base/task/task_scheduler/task_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ int GetMaxNumScheduledBestEffortSequences() {
// in a dynamic library which doesn't have access to argc/argv.
if (CommandLine::InitializedForCurrentProcess() &&
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableBackgroundTasks)) {
switches::kDisableBestEffortTasks)) {
return 0;
}
return std::numeric_limits<int>::max();
Expand Down
2 changes: 1 addition & 1 deletion base/task/task_scheduler/task_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class BASE_EXPORT TaskTracker {
// |histogram_label| is used as a suffix for histograms, it must not be empty.
// The first constructor sets the maximum number of TaskPriority::BEST_EFFORT
// sequences that can be scheduled concurrently to 0 if the
// --disable-background-tasks flag is specified, max() otherwise. The second
// --disable-best-effort-tasks flag is specified, max() otherwise. The second
// constructor sets it to |max_num_scheduled_best_effort_sequences|.
TaskTracker(StringPiece histogram_label);
TaskTracker(StringPiece histogram_label,
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4298,6 +4298,10 @@ const FeatureEntry kFeatureEntries[] = {
autofill_assistant::features::kAutofillAssistantChromeEntry)},
#endif // defined(OS_ANDROID)

{"disable-best-effort-tasks",
flag_descriptions::kDisableBestEffortTasksName,
flag_descriptions::kDisableBestEffortTasksDescription, kOsAll,
SINGLE_VALUE_TYPE(switches::kDisableBestEffortTasks)},
{"enable-sync-uss-passwords",
flag_descriptions::kEnableSyncUSSPasswordsName,
flag_descriptions::kEnableSyncUSSPasswordsDescription,
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/flag-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,11 @@
// "owners": [ "your-team" ],
"expiry_milestone": 76
},
{
"name": "disable-best-effort-tasks",
"owners": [ "[email protected]" ],
"expiry_milestone": 75
},
{
"name": "disable-captive-portal-bypass-proxy",
// "owners": [ "your-team" ],
Expand Down
9 changes: 9 additions & 0 deletions chrome/browser/flag_descriptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@ const char kDisableAudioForDesktopShareDescription[] =
"With this flag on, desktop share picker window will not let the user "
"choose whether to share audio.";

const char kDisableBestEffortTasksName[] = "Skip best effort tasks";
const char kDisableBestEffortTasksDescription[] =
"With this flag on, tasks of the lowest priority will not be executed "
"until shutdown. The queue of low priority tasks can increase memory usage."
"Also, while it should be possible to use Chrome almost normally with this "
"flag, it is expected that some non-visible operations such as writing "
"user data to disk, cleaning caches, reporting metrics or updating "
"components won't be performed until shutdown.";

const char kDisableIpcFloodingProtectionName[] =
"Disable IPC flooding protection";
const char kDisableIpcFloodingProtectionDescription[] =
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/flag_descriptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ extern const char kDevtoolsExperimentsDescription[];
extern const char kDisableAudioForDesktopShareName[];
extern const char kDisableAudioForDesktopShareDescription[];

extern const char kDisableBestEffortTasksName[];
extern const char kDisableBestEffortTasksDescription[];

extern const char kDisableIpcFloodingProtectionName[];
extern const char kDisableIpcFloodingProtectionDescription[];

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/no_best_effort_tasks_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class NoBestEffortTasksTest : public InProcessBrowserTest {

private:
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitch(switches::kDisableBackgroundTasks);
command_line->AppendSwitch(switches::kDisableBestEffortTasks);
InProcessBrowserTest::SetUpCommandLine(command_line);
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/startup/bad_flags_prompt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static const char* kBadFlags[] = {
// normally with this flag, it is expected that some non-visible operations
// such as writing user data to disk, cleaning caches, reporting metrics or
// updating components won't be performed until shutdown.
switches::kDisableBackgroundTasks,
switches::kDisableBestEffortTasks,

// The UI for Web Bluetooth scanning is not yet implemented. Without the
// UI websites can scan for bluetooth without user intervention. Show a
Expand Down
2 changes: 1 addition & 1 deletion content/browser/browser_child_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void BrowserChildProcessHostImpl::LaunchWithoutExtraCommandLineSwitches(
*base::CommandLine::ForCurrentProcess();
static const char* const kForwardSwitches[] = {
service_manager::switches::kDisableInProcessStackTraces,
switches::kDisableBackgroundTasks,
switches::kDisableBestEffortTasks,
switches::kDisableLogging,
switches::kEnableLogging,
switches::kEnablePerfetto,
Expand Down
2 changes: 1 addition & 1 deletion content/browser/renderer_host/render_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2933,8 +2933,8 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kDisable2dCanvasImageChromium,
switches::kDisableAcceleratedJpegDecoding,
switches::kDisableAcceleratedVideoDecode,
switches::kDisableBackgroundTasks,
switches::kDisableBackgroundTimerThrottling,
switches::kDisableBestEffortTasks,
switches::kDisableBreakpad,
switches::kDisableCompositorUkmForTests,
switches::kDisablePreferCompositingToLCDText,
Expand Down
1 change: 1 addition & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30851,6 +30851,7 @@ from previous Chrome versions.
<int value="-1691668194" label="enable-new-bookmark-apps"/>
<int value="-1691281364" label="enable-notification-action-icons"/>
<int value="-1686782572" label="ChromeHomeInactivitySheetExpansion:disabled"/>
<int value="-1684123448" label="disable-best-effort-tasks"/>
<int value="-1682843294" label="DataReductionProxyDecidesTransform:enabled"/>
<int value="-1677715989" label="UnifiedConsent:disabled"/>
<int value="-1676256979"
Expand Down

0 comments on commit a50a80f

Please sign in to comment.