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

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: Comments from jam. 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
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..001acfb0254a6ca6fbe6c3df77c6937378424238 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,42 @@ extern int DownloadMain(const MainFunctionParams&);
namespace content {
+namespace {
+
+// This sets up two singletons responsible for managing field trials. The
+// |field_trial_list| singleton lives on the stack and must outlive the Run()
+// method of the process.
+void InitializeFieldTrialAndFeatureList(
+ 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);
+
+ // 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
+
#if !defined(CHROME_MULTIPLE_DLL_CHILD)
base::LazyInstance<ContentBrowserClient>
g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER;
@@ -301,6 +340,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 +771,12 @@ class ContentMainRunnerImpl : public ContentMainRunner {
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
+ // Run this logic on all child processes. Zygotes will run this at a later
+ // point in time when the command line has been updated.
+ std::unique_ptr<base::FieldTrialList> field_trial_list;
+ if (process_type != "" && process_type != switches::kZygoteProcess)
jam 2016/05/03 21:33:48 nit !process_type.empty() which is convention
erikchen 2016/05/03 21:49:32 Done.
+ InitializeFieldTrialAndFeatureList(&field_trial_list);
+
base::HistogramBase::EnableActivityReportHistogram(process_type);
MainFunctionParams main_params(command_line);
« no previous file with comments | « no previous file | content/browser/browser_child_process_host_impl.h » ('j') | content/common/child_process_host_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698