Skip to content

Commit

Permalink
Add Browser Task Scheduler Flags
Browse files Browse the repository at this point in the history
Adds the browser scheduler command line flags as well as exposing it
via chrome://flags.

Enabling the feature will place the browser in a forced variations
group, allowing it to use task scheduler parameters from there. If the
variations group is unavailable, then enabling this will still not
enable the browser task scheduler

BUG=553459,633389

Review-Url: https://codereview.chromium.org/2227343002
Cr-Commit-Position: refs/heads/master@{#411199}
  • Loading branch information
robliao authored and Commit bot committed Aug 11, 2016
1 parent a684684 commit 2ce242f
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,8 @@ static_library("base_static") {
sources = [
"base_switches.cc",
"base_switches.h",
"task_scheduler/switches.cc",
"task_scheduler/switches.h",
"win/pe_image.cc",
"win/pe_image.h",
]
Expand Down
12 changes: 12 additions & 0 deletions base/task_scheduler/switches.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2016 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.

#include "base/task_scheduler/switches.h"

namespace switches {

const char kDisableBrowserTaskScheduler[] = "disable-browser-task-scheduler";
const char kEnableBrowserTaskScheduler[] = "enable-browser-task-scheduler";

} // namespace switches
15 changes: 15 additions & 0 deletions base/task_scheduler/switches.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2016 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.

#ifndef BASE_TASK_SCHEDULER_SWITCHES_H_
#define BASE_TASK_SCHEDULER_SWITCHES_H_

namespace switches {

extern const char kDisableBrowserTaskScheduler[];
extern const char kEnableBrowserTaskScheduler[];

} // namespace switches

#endif // BASE_TASK_SCHEDULER_SWITCHES_H_
12 changes: 12 additions & 0 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -13656,6 +13656,18 @@ Please check your email at <ph name="ACCOUNT_EMAIL">$2<ex>jane.doe@gmail.com</ex
Highly experimental performance mode where cross-site iframes are kept in a separate process from the top document. In this mode, iframes from different third-party sites will be allowed to share a process.
</message>

<!-- Browser Task Scheduler -->
<message name="IDS_FLAGS_BROWSER_TASK_SCHEDULER_NAME"
desc="Name of about:flag option to control the availability of the browser task scheduler."
translateable="false">
Browser Task Scheduler
</message>
<message name="IDS_FLAGS_BROWSER_TASK_SCHEDULER_DESCRIPTION"
desc="Description of about:flag option to control the availability of the browser task scheduler."
translateable="false">
Enables the browser task scheduler to dispatch tasks instead of the existing worker pools. The browser task scheduler will only be used if variation parameters are available.
</message>

<!-- Windows 8 Metro mode. -->
<if expr="is_win">
<message name="IDS_METRO_FLOW_DESCRIPTION"
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_scheduler/switches.h"
#include "base/values.h"
#include "build/build_config.h"
#include "cc/base/switches.h"
Expand Down Expand Up @@ -2044,6 +2045,10 @@ const FeatureEntry kFeatureEntries[] = {
IDS_FLAGS_QUICK_UNLOCK_PIN_DESCRIPTION, kOsCrOS,
FEATURE_VALUE_TYPE(features::kQuickUnlockPin)},
#endif // defined(OS_CHROMEOS)
{"browser-task-scheduler", IDS_FLAGS_BROWSER_TASK_SCHEDULER_NAME,
IDS_FLAGS_BROWSER_TASK_SCHEDULER_DESCRIPTION, kOsAll,
ENABLE_DISABLE_VALUE_TYPE(switches::kEnableBrowserTaskScheduler,
switches::kDisableBrowserTaskScheduler)},
// NOTE: Adding new command-line switches requires adding corresponding
// entries to enum "LoginCustomFlags" in histograms.xml. See note in
// histograms.xml and don't forget to run AboutFlagsHistogramTest unit test.
Expand Down
10 changes: 9 additions & 1 deletion chrome/browser/chrome_browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
#include "base/task_scheduler/scheduler_worker_pool_params.h"
#include "base/task_scheduler/switches.h"
#include "base/task_scheduler/task_scheduler.h"
#include "base/task_scheduler/task_traits.h"
#include "base/threading/platform_thread.h"
Expand Down Expand Up @@ -395,8 +396,15 @@ size_t WorkerPoolIndexForTraits(const base::TaskTraits& traits) {
void MaybeInitializeTaskScheduler() {
static constexpr char kFieldTrialName[] = "BrowserScheduler";
std::map<std::string, std::string> variation_params;
if (!variations::GetVariationParams(kFieldTrialName, &variation_params))
if (!variations::GetVariationParams(kFieldTrialName, &variation_params)) {
DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserTaskScheduler))
<< "The Browser Task Scheduler remains disabled with "
<< switches::kEnableBrowserTaskScheduler
<< " because there is no available variation param for this build or "
" the task scheduler is disabled in chrome://flags.";
return;
}

using ThreadPriority = base::ThreadPriority;
using IORestriction = base::SchedulerWorkerPoolParams::IORestriction;
Expand Down
2 changes: 2 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83237,6 +83237,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="-474322576" label="disable-quick-unlock-pin"/>
<int value="-462205750" label="enable-service-worker-sync"/>
<int value="-455203267" label="use_new_features_summary"/>
<int value="-449465495" label="disable-browser-task-scheduler"/>
<int value="-430360431" label="disable-password-generation"/>
<int value="-418868128" label="enable-experimental-web-platform-features"/>
<int value="-396994784" label="enable-vr-shell"/>
Expand Down Expand Up @@ -83277,6 +83278,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="-158197254" label="enable-credential-manager-api"/>
<int value="-147283486" label="enable-network-portal-notification"/>
<int value="-146552997" label="enable-affiliation-based-matching"/>
<int value="-122492389" label="enable-browser-task-scheduler"/>
<int value="-102537270" label="extension-content-verification"/>
<int value="-99781021" label="disable-roboto-font-ui"/>
<int value="-88822940" label="ssl-version-min"/>
Expand Down

0 comments on commit 2ce242f

Please sign in to comment.