blob: 6d80dadec905fc896629fce03de32a13e53b28dc [file] [log] [blame]
// Copyright 2017 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 "chrome/browser/resource_coordinator/tab_manager_features.h"
#include "base/metrics/field_trial_params.h"
#include "chrome/common/chrome_features.h"
namespace {
constexpr char kTabLoadTimeoutInMsParameterName[] = "tabLoadTimeoutInMs";
} // namespace
namespace features {
// Enables delaying the navigation of background tabs in order to improve
// foreground tab's user experience.
const base::Feature kStaggeredBackgroundTabOpening{
"StaggeredBackgroundTabOpening", base::FEATURE_DISABLED_BY_DEFAULT};
// This controls whether we are running experiment with staggered background
// tab opening feature. For control group, this should be disabled. This depends
// on |kStaggeredBackgroundTabOpening| above.
const base::Feature kStaggeredBackgroundTabOpeningExperiment{
"StaggeredBackgroundTabOpeningExperiment",
base::FEATURE_ENABLED_BY_DEFAULT};
// Enables using customized value for tab load timeout. This is used by both
// staggered background tab opening and session restore in finch experiment to
// see what timeout value is better. The default timeout is used when this
// feature is disabled.
const base::Feature kCustomizedTabLoadTimeout{
"CustomizedTabLoadTimeout", base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace features
namespace resource_coordinator {
base::TimeDelta GetTabLoadTimeout(const base::TimeDelta& default_timeout) {
int timeout_in_ms = base::GetFieldTrialParamByFeatureAsInt(
features::kCustomizedTabLoadTimeout, kTabLoadTimeoutInMsParameterName,
default_timeout.InMilliseconds());
if (timeout_in_ms <= 0)
return default_timeout;
return base::TimeDelta::FromMilliseconds(timeout_in_ms);
}
} // namespace resource_coordinator