зеркало из https://github.com/electron/electron.git
feat: initialize field trials from command line arguments (#28305)
Fixes: #27877
This commit is contained in:
Родитель
521146f71e
Коммит
2632564ccf
|
@ -75,6 +75,12 @@ This switch can not be used in `app.commandLine.appendSwitch` since it is parsed
|
|||
earlier than user's app is loaded, but you can set the `ELECTRON_ENABLE_LOGGING`
|
||||
environment variable to achieve the same effect.
|
||||
|
||||
## --force-fieldtrials=`trials`
|
||||
|
||||
Field trials to be forcefully enabled or disabled.
|
||||
|
||||
For example: `WebRTC-Audio-Red-For-Opus/Enabled/`
|
||||
|
||||
### --host-rules=`rules`
|
||||
|
||||
A comma-separated list of `rules` that control how hostnames are mapped.
|
||||
|
|
|
@ -279,6 +279,9 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {
|
|||
base::FeatureList::ClearInstanceForTesting();
|
||||
InitializeFeatureList();
|
||||
|
||||
// Initialize field trials.
|
||||
InitializeFieldTrials();
|
||||
|
||||
// Initialize after user script environment creation.
|
||||
fake_browser_process_->PostEarlyInitialization();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "base/base_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/metrics/field_trial.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "media/base/media_switches.h"
|
||||
|
@ -49,4 +50,12 @@ void InitializeFeatureList() {
|
|||
base::FeatureList::InitializeInstance(enable_features, disable_features);
|
||||
}
|
||||
|
||||
void InitializeFieldTrials() {
|
||||
auto* cmd_line = base::CommandLine::ForCurrentProcess();
|
||||
auto force_fieldtrials =
|
||||
cmd_line->GetSwitchValueASCII(::switches::kForceFieldTrials);
|
||||
|
||||
base::FieldTrialList::CreateTrialsFromString(force_fieldtrials);
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace electron {
|
||||
void InitializeFeatureList();
|
||||
}
|
||||
void InitializeFieldTrials();
|
||||
} // namespace electron
|
||||
|
||||
#endif // SHELL_BROWSER_FEATURE_LIST_H_
|
||||
|
|
Загрузка…
Ссылка в новой задаче