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 "chrome/browser/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
787 | 787 |
788 ChromeBrowserMainParts::~ChromeBrowserMainParts() { | 788 ChromeBrowserMainParts::~ChromeBrowserMainParts() { |
789 for (int i = static_cast<int>(chrome_extra_parts_.size())-1; i >= 0; --i) | 789 for (int i = static_cast<int>(chrome_extra_parts_.size())-1; i >= 0; --i) |
790 delete chrome_extra_parts_[i]; | 790 delete chrome_extra_parts_[i]; |
791 chrome_extra_parts_.clear(); | 791 chrome_extra_parts_.clear(); |
792 } | 792 } |
793 | 793 |
794 // This will be called after the command-line has been mutated by about:flags | 794 // This will be called after the command-line has been mutated by about:flags |
795 void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() { | 795 void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() { |
796 TRACE_EVENT0("startup", "ChromeBrowserMainParts::SetupMetricsAndFieldTrials"); | 796 TRACE_EVENT0("startup", "ChromeBrowserMainParts::SetupMetricsAndFieldTrials"); |
797 // Must initialize metrics after labs have been converted into switches, | |
798 // but before field trials are set up (so that client ID is available for | |
799 // one-time randomized field trials). | |
800 | 797 |
801 // Initialize FieldTrialList to support FieldTrials that use one-time | 798 // Initialize FieldTrialList to support FieldTrials that use one-time |
802 // randomization. | 799 // randomization. |
803 metrics::MetricsService* metrics = browser_process_->metrics_service(); | |
804 | |
805 DCHECK(!field_trial_list_); | 800 DCHECK(!field_trial_list_); |
806 field_trial_list_.reset( | 801 field_trial_list_.reset( |
807 new base::FieldTrialList(metrics->CreateEntropyProvider().release())); | 802 new base::FieldTrialList(browser_process_->GetMetricsServicesManager() |
803 ->CreateEntropyProvider() | |
brettw
2016/09/14 22:22:03
A nice and easy follow-up to this patch would be t
robliao
2016/09/15 14:31:18
Agreed to that.
| |
804 .release())); | |
808 | 805 |
809 const base::CommandLine* command_line = | 806 const base::CommandLine* command_line = |
810 base::CommandLine::ForCurrentProcess(); | 807 base::CommandLine::ForCurrentProcess(); |
811 if (command_line->HasSwitch(switches::kEnableBenchmarking) || | 808 if (command_line->HasSwitch(switches::kEnableBenchmarking) || |
812 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)) { | 809 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)) { |
813 base::FieldTrial::EnableBenchmarking(); | 810 base::FieldTrial::EnableBenchmarking(); |
814 } | 811 } |
815 | 812 |
816 if (command_line->HasSwitch(switches::kForceFieldTrialParams)) { | 813 if (command_line->HasSwitch(switches::kForceFieldTrialParams)) { |
817 bool result = chrome_variations::AssociateParamsFromString( | 814 bool result = chrome_variations::AssociateParamsFromString( |
(...skipping 20 matching lines...) Expand all Loading... | |
838 | 835 |
839 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 836 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
840 | 837 |
841 // Associate parameters chosen in about:flags and create trial/group for them. | 838 // Associate parameters chosen in about:flags and create trial/group for them. |
842 flags_ui::PrefServiceFlagsStorage flags_storage( | 839 flags_ui::PrefServiceFlagsStorage flags_storage( |
843 g_browser_process->local_state()); | 840 g_browser_process->local_state()); |
844 std::vector<std::string> variation_ids = | 841 std::vector<std::string> variation_ids = |
845 about_flags::RegisterAllFeatureVariationParameters( | 842 about_flags::RegisterAllFeatureVariationParameters( |
846 &flags_storage, feature_list.get()); | 843 &flags_storage, feature_list.get()); |
847 | 844 |
845 // Must initialize metrics after about:flags have been converted into | |
846 // switches, but before field trials are set up (so that client ID is | |
847 // available for one-time randomized field trials). | |
848 metrics::MetricsService* metrics = browser_process_->metrics_service(); | |
849 | |
848 variations::VariationsHttpHeaderProvider* http_header_provider = | 850 variations::VariationsHttpHeaderProvider* http_header_provider = |
849 variations::VariationsHttpHeaderProvider::GetInstance(); | 851 variations::VariationsHttpHeaderProvider::GetInstance(); |
850 // Force the variation ids selected in chrome://flags and/or specified using | 852 // Force the variation ids selected in chrome://flags and/or specified using |
851 // the command-line flag. | 853 // the command-line flag. |
852 bool result = http_header_provider->ForceVariationIds( | 854 bool result = http_header_provider->ForceVariationIds( |
853 command_line->GetSwitchValueASCII(switches::kForceVariationIds), | 855 command_line->GetSwitchValueASCII(switches::kForceVariationIds), |
854 &variation_ids); | 856 &variation_ids); |
855 CHECK(result) << "Invalid list of variation ids specified (either in --" | 857 CHECK(result) << "Invalid list of variation ids specified (either in --" |
856 << switches::kForceVariationIds << " or in chrome://flags)"; | 858 << switches::kForceVariationIds << " or in chrome://flags)"; |
857 metrics->AddSyntheticTrialObserver(http_header_provider); | 859 metrics->AddSyntheticTrialObserver(http_header_provider); |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2207 chromeos::CrosSettings::Shutdown(); | 2209 chromeos::CrosSettings::Shutdown(); |
2208 #endif // defined(OS_CHROMEOS) | 2210 #endif // defined(OS_CHROMEOS) |
2209 #endif // defined(OS_ANDROID) | 2211 #endif // defined(OS_ANDROID) |
2210 } | 2212 } |
2211 | 2213 |
2212 // Public members: | 2214 // Public members: |
2213 | 2215 |
2214 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2216 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
2215 chrome_extra_parts_.push_back(parts); | 2217 chrome_extra_parts_.push_back(parts); |
2216 } | 2218 } |
OLD | NEW |