OLD | NEW |
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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 } | 725 } |
723 | 726 |
724 int Run() override { | 727 int Run() override { |
725 DCHECK(is_initialized_); | 728 DCHECK(is_initialized_); |
726 DCHECK(!is_shutdown_); | 729 DCHECK(!is_shutdown_); |
727 const base::CommandLine& command_line = | 730 const base::CommandLine& command_line = |
728 *base::CommandLine::ForCurrentProcess(); | 731 *base::CommandLine::ForCurrentProcess(); |
729 std::string process_type = | 732 std::string process_type = |
730 command_line.GetSwitchValueASCII(switches::kProcessType); | 733 command_line.GetSwitchValueASCII(switches::kProcessType); |
731 | 734 |
| 735 std::unique_ptr<base::FieldTrialList> field_trial_list; |
| 736 |
| 737 // TODO(asvitkine): This logic should run for all child processes. |
| 738 // https://crbug.com/563705. |
| 739 if (process_type == switches::kGpuProcess || |
| 740 process_type == switches::kUtilityProcess || |
| 741 process_type == switches::kRendererProcess || |
| 742 process_type == switches::kZygoteProcess || |
| 743 process_type == switches::kPpapiPluginProcess) { |
| 744 // Initialize statistical testing infrastructure. We set the entropy |
| 745 // provider to nullptr to disallow non-browser processes from creating |
| 746 // their own one-time randomized trials; they should be created in the |
| 747 // browser process. |
| 748 field_trial_list.reset(new base::FieldTrialList(nullptr)); |
| 749 |
| 750 // Ensure any field trials in browser are reflected into the child |
| 751 // process. |
| 752 if (command_line.HasSwitch(switches::kForceFieldTrials)) { |
| 753 bool result = base::FieldTrialList::CreateTrialsFromString( |
| 754 command_line.GetSwitchValueASCII(switches::kForceFieldTrials), |
| 755 std::set<std::string>()); |
| 756 DCHECK(result); |
| 757 } |
| 758 |
| 759 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 760 feature_list->InitializeFromCommandLine( |
| 761 command_line.GetSwitchValueASCII(switches::kEnableFeatures), |
| 762 command_line.GetSwitchValueASCII(switches::kDisableFeatures)); |
| 763 base::FeatureList::SetInstance(std::move(feature_list)); |
| 764 } |
| 765 |
732 base::HistogramBase::EnableActivityReportHistogram(process_type); | 766 base::HistogramBase::EnableActivityReportHistogram(process_type); |
733 | 767 |
734 MainFunctionParams main_params(command_line); | 768 MainFunctionParams main_params(command_line); |
735 main_params.ui_task = ui_task_; | 769 main_params.ui_task = ui_task_; |
736 #if defined(OS_WIN) | 770 #if defined(OS_WIN) |
737 main_params.sandbox_info = &sandbox_info_; | 771 main_params.sandbox_info = &sandbox_info_; |
738 #elif defined(OS_MACOSX) | 772 #elif defined(OS_MACOSX) |
739 main_params.autorelease_pool = autorelease_pool_.get(); | 773 main_params.autorelease_pool = autorelease_pool_.get(); |
740 #endif | 774 #endif |
741 | 775 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 832 |
799 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 833 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
800 }; | 834 }; |
801 | 835 |
802 // static | 836 // static |
803 ContentMainRunner* ContentMainRunner::Create() { | 837 ContentMainRunner* ContentMainRunner::Create() { |
804 return new ContentMainRunnerImpl(); | 838 return new ContentMainRunnerImpl(); |
805 } | 839 } |
806 | 840 |
807 } // namespace content | 841 } // namespace content |
OLD | NEW |