| // Copyright 2017 The Chromium Authors |
| // 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 using customized value for tab load timeout. This is used by session |
| // restore in finch experiment to see what timeout value is better. The default |
| // timeout is used when this feature is disabled. |
| 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::Milliseconds(timeout_in_ms); |
| } |
| |
| } // namespace resource_coordinator |