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

Side by Side 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, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/gpu/gpu_process_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/app/content_main_runner.h" 5 #include "content/public/app/content_main_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/allocator/allocator_check.h" 15 #include "base/allocator/allocator_check.h"
16 #include "base/allocator/allocator_extension.h" 16 #include "base/allocator/allocator_extension.h"
17 #include "base/at_exit.h" 17 #include "base/at_exit.h"
18 #include "base/base_switches.h"
18 #include "base/command_line.h" 19 #include "base/command_line.h"
19 #include "base/debug/debugger.h" 20 #include "base/debug/debugger.h"
20 #include "base/debug/stack_trace.h" 21 #include "base/debug/stack_trace.h"
22 #include "base/feature_list.h"
21 #include "base/files/file_path.h" 23 #include "base/files/file_path.h"
22 #include "base/i18n/icu_util.h" 24 #include "base/i18n/icu_util.h"
23 #include "base/lazy_instance.h" 25 #include "base/lazy_instance.h"
24 #include "base/logging.h" 26 #include "base/logging.h"
25 #include "base/macros.h" 27 #include "base/macros.h"
26 #include "base/memory/scoped_vector.h" 28 #include "base/memory/scoped_vector.h"
29 #include "base/metrics/field_trial.h"
27 #include "base/metrics/histogram_base.h" 30 #include "base/metrics/histogram_base.h"
28 #include "base/metrics/statistics_recorder.h" 31 #include "base/metrics/statistics_recorder.h"
29 #include "base/path_service.h" 32 #include "base/path_service.h"
30 #include "base/process/launch.h" 33 #include "base/process/launch.h"
31 #include "base/process/memory.h" 34 #include "base/process/memory.h"
32 #include "base/process/process_handle.h" 35 #include "base/process/process_handle.h"
33 #include "base/profiler/scoped_tracker.h" 36 #include "base/profiler/scoped_tracker.h"
34 #include "base/strings/string_number_conversions.h" 37 #include "base/strings/string_number_conversions.h"
35 #include "base/strings/string_util.h" 38 #include "base/strings/string_util.h"
36 #include "base/strings/stringprintf.h" 39 #include "base/strings/stringprintf.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 #endif 121 #endif
119 extern int RendererMain(const content::MainFunctionParams&); 122 extern int RendererMain(const content::MainFunctionParams&);
120 extern int UtilityMain(const MainFunctionParams&); 123 extern int UtilityMain(const MainFunctionParams&);
121 #if defined(OS_ANDROID) 124 #if defined(OS_ANDROID)
122 extern int DownloadMain(const MainFunctionParams&); 125 extern int DownloadMain(const MainFunctionParams&);
123 #endif 126 #endif
124 } // namespace content 127 } // namespace content
125 128
126 namespace content { 129 namespace content {
127 130
131 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.
132 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.
133 std::unique_ptr<base::FieldTrialList>* field_trial_list) {
134 const base::CommandLine& command_line =
135 *base::CommandLine::ForCurrentProcess();
136 std::string process_type =
137 command_line.GetSwitchValueASCII(switches::kProcessType);
138
139 // TODO(asvitkine): This logic should run for all child processes.
140 // https://crbug.com/563705.
141 if (process_type == switches::kGpuProcess ||
142 #if defined(ENABLE_PLUGINS)
143 process_type == switches::kPpapiPluginProcess ||
144 #endif // ENABLE_PLUGINS
145 process_type == switches::kUtilityProcess) {
146 // Initialize statistical testing infrastructure. We set the entropy
147 // provider to nullptr to disallow non-browser processes from creating
148 // their own one-time randomized trials; they should be created in the
149 // browser process.
150 field_trial_list->reset(new base::FieldTrialList(nullptr));
151
152 // Ensure any field trials in browser are reflected into the child
153 // process.
154 if (command_line.HasSwitch(switches::kForceFieldTrials)) {
155 bool result = base::FieldTrialList::CreateTrialsFromString(
156 command_line.GetSwitchValueASCII(switches::kForceFieldTrials),
157 std::set<std::string>());
158 DCHECK(result);
159 }
160
161 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
162 feature_list->InitializeFromCommandLine(
163 command_line.GetSwitchValueASCII(switches::kEnableFeatures),
164 command_line.GetSwitchValueASCII(switches::kDisableFeatures));
165 base::FeatureList::SetInstance(std::move(feature_list));
166 }
167 }
168 } // 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.
169
128 #if !defined(CHROME_MULTIPLE_DLL_CHILD) 170 #if !defined(CHROME_MULTIPLE_DLL_CHILD)
129 base::LazyInstance<ContentBrowserClient> 171 base::LazyInstance<ContentBrowserClient>
130 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; 172 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER;
131 #endif // !CHROME_MULTIPLE_DLL_CHILD 173 #endif // !CHROME_MULTIPLE_DLL_CHILD
132 174
133 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) 175 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
134 base::LazyInstance<ContentGpuClient> 176 base::LazyInstance<ContentGpuClient>
135 g_empty_content_gpu_client = LAZY_INSTANCE_INITIALIZER; 177 g_empty_content_gpu_client = LAZY_INSTANCE_INITIALIZER;
136 base::LazyInstance<ContentRendererClient> 178 base::LazyInstance<ContentRendererClient>
137 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; 179 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // line so update it here with the new version. 336 // line so update it here with the new version.
295 const base::CommandLine& command_line = 337 const base::CommandLine& command_line =
296 *base::CommandLine::ForCurrentProcess(); 338 *base::CommandLine::ForCurrentProcess();
297 std::string process_type = 339 std::string process_type =
298 command_line.GetSwitchValueASCII(switches::kProcessType); 340 command_line.GetSwitchValueASCII(switches::kProcessType);
299 ContentClientInitializer::Set(process_type, delegate); 341 ContentClientInitializer::Set(process_type, delegate);
300 342
301 MainFunctionParams main_params(command_line); 343 MainFunctionParams main_params(command_line);
302 main_params.zygote_child = true; 344 main_params.zygote_child = true;
303 345
346 std::unique_ptr<base::FieldTrialList> field_trial_list;
347 InitializeFieldTrialAndFeatureList(&field_trial_list);
348
304 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { 349 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) {
305 if (process_type == kMainFunctions[i].name) 350 if (process_type == kMainFunctions[i].name)
306 return kMainFunctions[i].function(main_params); 351 return kMainFunctions[i].function(main_params);
307 } 352 }
308 353
309 if (delegate) 354 if (delegate)
310 return delegate->RunProcess(process_type, main_params); 355 return delegate->RunProcess(process_type, main_params);
311 356
312 NOTREACHED() << "Unknown zygote process type: " << process_type; 357 NOTREACHED() << "Unknown zygote process type: " << process_type;
313 return 1; 358 return 1;
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 } 767 }
723 768
724 int Run() override { 769 int Run() override {
725 DCHECK(is_initialized_); 770 DCHECK(is_initialized_);
726 DCHECK(!is_shutdown_); 771 DCHECK(!is_shutdown_);
727 const base::CommandLine& command_line = 772 const base::CommandLine& command_line =
728 *base::CommandLine::ForCurrentProcess(); 773 *base::CommandLine::ForCurrentProcess();
729 std::string process_type = 774 std::string process_type =
730 command_line.GetSwitchValueASCII(switches::kProcessType); 775 command_line.GetSwitchValueASCII(switches::kProcessType);
731 776
777 std::unique_ptr<base::FieldTrialList> field_trial_list;
778 InitializeFieldTrialAndFeatureList(&field_trial_list);
779
732 base::HistogramBase::EnableActivityReportHistogram(process_type); 780 base::HistogramBase::EnableActivityReportHistogram(process_type);
733 781
734 MainFunctionParams main_params(command_line); 782 MainFunctionParams main_params(command_line);
735 main_params.ui_task = ui_task_; 783 main_params.ui_task = ui_task_;
736 #if defined(OS_WIN) 784 #if defined(OS_WIN)
737 main_params.sandbox_info = &sandbox_info_; 785 main_params.sandbox_info = &sandbox_info_;
738 #elif defined(OS_MACOSX) 786 #elif defined(OS_MACOSX)
739 main_params.autorelease_pool = autorelease_pool_.get(); 787 main_params.autorelease_pool = autorelease_pool_.get();
740 #endif 788 #endif
741 789
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 846
799 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 847 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
800 }; 848 };
801 849
802 // static 850 // static
803 ContentMainRunner* ContentMainRunner::Create() { 851 ContentMainRunner* ContentMainRunner::Create() {
804 return new ContentMainRunnerImpl(); 852 return new ContentMainRunnerImpl();
805 } 853 }
806 854
807 } // namespace content 855 } // namespace content
OLDNEW
« 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