Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Unified Diff: content/app/content_main_runner.cc

Issue 1928863002: Enable FeatureList for the GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/gpu/gpu_process_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/app/content_main_runner.cc
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index abe4f13051c45db0ac11f31e7ef09b59fe3f618b..9bfea2c3d1bb7fbbcc27593d3c7241dbe886c3ec 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -15,15 +15,18 @@
#include "base/allocator/allocator_check.h"
#include "base/allocator/allocator_extension.h"
#include "base/at_exit.h"
+#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "base/debug/stack_trace.h"
+#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/i18n/icu_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/scoped_vector.h"
+#include "base/metrics/field_trial.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/statistics_recorder.h"
#include "base/path_service.h"
@@ -125,6 +128,45 @@ extern int DownloadMain(const MainFunctionParams&);
namespace content {
+namespace {
Alexei Svitkine (slow) 2016/05/03 18:59:47 Nit: Add an empty line below. You can remove the e
erikchen 2016/05/03 19:22:31 Done.
+void InitializeFieldTrialAndFeatureList(
Alexei Svitkine (slow) 2016/05/03 18:59:47 Nit: Please add a short comment about what this do
erikchen 2016/05/03 19:22:31 Done.
+ std::unique_ptr<base::FieldTrialList>* field_trial_list) {
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+ std::string process_type =
+ command_line.GetSwitchValueASCII(switches::kProcessType);
+
+ // TODO(asvitkine): This logic should run for all child processes.
+ // https://crbug.com/563705.
+ if (process_type == switches::kGpuProcess ||
+#if defined(ENABLE_PLUGINS)
+ process_type == switches::kPpapiPluginProcess ||
+#endif // ENABLE_PLUGINS
+ process_type == switches::kUtilityProcess) {
+ // Initialize statistical testing infrastructure. We set the entropy
+ // provider to nullptr to disallow non-browser processes from creating
+ // their own one-time randomized trials; they should be created in the
+ // browser process.
+ field_trial_list->reset(new base::FieldTrialList(nullptr));
+
+ // Ensure any field trials in browser are reflected into the child
+ // process.
+ if (command_line.HasSwitch(switches::kForceFieldTrials)) {
+ bool result = base::FieldTrialList::CreateTrialsFromString(
+ command_line.GetSwitchValueASCII(switches::kForceFieldTrials),
+ std::set<std::string>());
+ DCHECK(result);
+ }
+
+ std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
+ feature_list->InitializeFromCommandLine(
+ command_line.GetSwitchValueASCII(switches::kEnableFeatures),
+ command_line.GetSwitchValueASCII(switches::kDisableFeatures));
+ base::FeatureList::SetInstance(std::move(feature_list));
+ }
+}
+} // namespace
Alexei Svitkine (slow) 2016/05/03 18:59:47 Nit: Add an empty line above it.
erikchen 2016/05/03 19:22:31 Done.
+
#if !defined(CHROME_MULTIPLE_DLL_CHILD)
base::LazyInstance<ContentBrowserClient>
g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER;
@@ -301,6 +343,9 @@ int RunZygote(const MainFunctionParams& main_function_params,
MainFunctionParams main_params(command_line);
main_params.zygote_child = true;
+ std::unique_ptr<base::FieldTrialList> field_trial_list;
+ InitializeFieldTrialAndFeatureList(&field_trial_list);
+
for (size_t i = 0; i < arraysize(kMainFunctions); ++i) {
if (process_type == kMainFunctions[i].name)
return kMainFunctions[i].function(main_params);
@@ -729,6 +774,9 @@ class ContentMainRunnerImpl : public ContentMainRunner {
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
+ std::unique_ptr<base::FieldTrialList> field_trial_list;
+ InitializeFieldTrialAndFeatureList(&field_trial_list);
+
base::HistogramBase::EnableActivityReportHistogram(process_type);
MainFunctionParams main_params(command_line);
« no previous file with comments | « no previous file | content/browser/gpu/gpu_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698