Commit 5b44e33f authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

TaskScheduler: Use a Feature to control whether all tasks are USER_BLOCKING.

Previously, we read a variation param from the "BrowserScheduler" study
to determine whether all tasks should have USER_BLOCKING priority.
With this CL, we instead use a base::Feature.

Benefits:
- Study that controls the feature doesn't have to be "BrowserScheduler".
- Enabling/disabling a feature is less verbose than setting a variation
  params with the new GCL config format.

Bug: 902441
Change-Id: Ib38dcfdf097c1ca92784a22c3501b644b077f744
Reviewed-on: https://chromium-review.googlesource.com/c/1321032
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606988}
parent 6296e827
......@@ -8,7 +8,10 @@
namespace base {
const base::Feature kMergeBlockingNonBlockingPools = {
const Feature kAllTasksUserBlocking{"AllTasksUserBlocking",
FEATURE_DISABLED_BY_DEFAULT};
const Feature kMergeBlockingNonBlockingPools = {
"MergeBlockingNonBlockingPools", base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace base
......@@ -10,7 +10,9 @@
namespace base {
struct Feature;
extern const BASE_EXPORT base::Feature kMergeBlockingNonBlockingPools;
extern const BASE_EXPORT Feature kAllTasksUserBlocking;
extern const BASE_EXPORT Feature kMergeBlockingNonBlockingPools;
} // namespace base
......
......@@ -115,10 +115,8 @@ void TaskSchedulerImpl::Start(
SchedulerWorkerObserver* scheduler_worker_observer) {
// This is set in Start() and not in the constructor because variation params
// are usually not ready when TaskSchedulerImpl is instantiated in a process.
if (base::GetFieldTrialParamValue("BrowserScheduler",
"AllTasksUserBlocking") == "true") {
if (FeatureList::IsEnabled(kAllTasksUserBlocking))
all_tasks_user_blocking_.Set();
}
const bool use_blocking_pools =
!base::FeatureList::IsEnabled(kMergeBlockingNonBlockingPools);
......
......@@ -248,20 +248,17 @@ std::vector<TaskSchedulerImplTestParams> GetTaskSchedulerImplTestParams() {
class TaskSchedulerImplTest
: public testing::TestWithParam<TaskSchedulerImplTestParams> {
protected:
TaskSchedulerImplTest() : scheduler_("Test"), field_trial_list_(nullptr) {
if (GetParam().pool_config == PoolConfiguration::kMergeBlockingNonBlocking)
feature_list.InitWithFeatures({kMergeBlockingNonBlockingPools}, {});
TaskSchedulerImplTest() : scheduler_("Test") {
feature_list_.emplace();
feature_list_->InitWithFeatures(GetFeaturesEnabledByConstructor(), {});
}
void EnableAllTasksUserBlocking() {
constexpr char kFieldTrialName[] = "BrowserScheduler";
constexpr char kFieldTrialTestGroup[] = "DummyGroup";
std::map<std::string, std::string> variation_params;
variation_params["AllTasksUserBlocking"] = "true";
base::AssociateFieldTrialParams(kFieldTrialName, kFieldTrialTestGroup,
variation_params);
base::FieldTrialList::CreateFieldTrial(kFieldTrialName,
kFieldTrialTestGroup);
feature_list_.reset();
feature_list_.emplace();
std::vector<Feature> enabled_features = GetFeaturesEnabledByConstructor();
enabled_features.push_back(kAllTasksUserBlocking);
feature_list_->InitWithFeatures(enabled_features, {});
}
void set_scheduler_worker_observer(
......@@ -296,8 +293,14 @@ class TaskSchedulerImplTest
TaskSchedulerImpl scheduler_;
private:
base::FieldTrialList field_trial_list_;
base::test::ScopedFeatureList feature_list;
std::vector<Feature> GetFeaturesEnabledByConstructor() {
if (GetParam().pool_config == PoolConfiguration::kMergeBlockingNonBlocking)
return {kMergeBlockingNonBlockingPools};
else
return {};
}
Optional<base::test::ScopedFeatureList> feature_list_;
SchedulerWorkerObserver* scheduler_worker_observer_ = nullptr;
bool did_tear_down_ = false;
......
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