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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 2380043002: Do not register synthetic field trial before initializing TaskScheduler. (Closed)
Patch Set: Created 4 years, 2 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 | « chrome/browser/chrome_browser_main.h ('k') | no next file » | 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 "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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 variations_service->CreateTrialsFromSeed(feature_list.get()); 871 variations_service->CreateTrialsFromSeed(feature_list.get());
872 872
873 browser_field_trials_.SetupFeatureControllingFieldTrials(has_seed, 873 browser_field_trials_.SetupFeatureControllingFieldTrials(has_seed,
874 feature_list.get()); 874 feature_list.get());
875 875
876 base::FeatureList::SetInstance(std::move(feature_list)); 876 base::FeatureList::SetInstance(std::move(feature_list));
877 877
878 // This must be called after |local_state_| is initialized. 878 // This must be called after |local_state_| is initialized.
879 browser_field_trials_.SetupFieldTrials(); 879 browser_field_trials_.SetupFieldTrials();
880 880
881 // Enable Navigation Tracing only if a trace upload url is specified.
882 if (command_line->HasSwitch(switches::kEnableNavigationTracing) &&
883 command_line->HasSwitch(switches::kTraceUploadURL)) {
884 tracing::SetupNavigationTracing();
885 }
886
887 // Initialize FieldTrialSynchronizer system. This is a singleton and is used 881 // Initialize FieldTrialSynchronizer system. This is a singleton and is used
888 // for posting tasks via base::Bind. Its deleted when it goes out of scope. 882 // for posting tasks via base::Bind. Its deleted when it goes out of scope.
889 // Even though base::Bind does AddRef and Release, the object will not be 883 // Even though base::Bind does AddRef and Release, the object will not be
890 // deleted after the Task is executed. 884 // deleted after the Task is executed.
891 field_trial_synchronizer_ = new FieldTrialSynchronizer(); 885 field_trial_synchronizer_ = new FieldTrialSynchronizer();
892
893 // Register a synthetic field trial for the sampling profiler configuration
894 // that was already chosen.
895 sampling_profiler_config_.RegisterSyntheticFieldTrial();
896
897 #if defined(OS_WIN) || defined(OS_MACOSX) || \
898 (defined(OS_LINUX) && !defined(OS_CHROMEOS))
899 metrics::DesktopSessionDurationTracker::Initialize();
900 #endif
901
902 #if defined(OS_WIN)
903 // Cleanup the PreRead field trial registry key.
904 // TODO(fdoray): Remove this when M56 hits stable.
905 const base::string16 pre_read_field_trial_registry_path =
906 BrowserDistribution::GetDistribution()->GetRegistryPath() +
907 L"\\PreReadFieldTrial";
908 base::win::RegKey(HKEY_CURRENT_USER,
909 pre_read_field_trial_registry_path.c_str(), KEY_SET_VALUE)
910 .DeleteKey(L"");
911 #endif // defined(OS_WIN)
912 } 886 }
913 887
914 void ChromeBrowserMainParts::SetupMetrics() { 888 void ChromeBrowserMainParts::SetupMetrics() {
915 TRACE_EVENT0("startup", "ChromeBrowserMainParts::SetupMetrics"); 889 TRACE_EVENT0("startup", "ChromeBrowserMainParts::SetupMetrics");
916 metrics::MetricsService* metrics = browser_process_->metrics_service(); 890 metrics::MetricsService* metrics = browser_process_->metrics_service();
917 metrics->AddSyntheticTrialObserver( 891 metrics->AddSyntheticTrialObserver(
918 variations::VariationsHttpHeaderProvider::GetInstance()); 892 variations::VariationsHttpHeaderProvider::GetInstance());
919 // Now that field trials have been created, initializes metrics recording. 893 // Now that field trials have been created, initializes metrics recording.
920 metrics->InitializeMetricsRecordingState(); 894 metrics->InitializeMetricsRecordingState();
921 895
922 const version_info::Channel channel = chrome::GetChannel(); 896 const version_info::Channel channel = chrome::GetChannel();
923 897
924 // Enable profiler instrumentation depending on the channel. 898 // Enable profiler instrumentation depending on the channel.
925 switch (channel) { 899 switch (channel) {
926 case version_info::Channel::UNKNOWN: 900 case version_info::Channel::UNKNOWN:
927 case version_info::Channel::CANARY: 901 case version_info::Channel::CANARY:
928 tracked_objects::ScopedTracker::Enable(); 902 tracked_objects::ScopedTracker::Enable();
929 break; 903 break;
930 904
931 case version_info::Channel::DEV: 905 case version_info::Channel::DEV:
932 case version_info::Channel::BETA: 906 case version_info::Channel::BETA:
933 case version_info::Channel::STABLE: 907 case version_info::Channel::STABLE:
934 // Don't enable instrumentation. 908 // Don't enable instrumentation.
935 break; 909 break;
936 } 910 }
911
912 // Enable Navigation Tracing only if a trace upload url is specified.
913 const base::CommandLine* command_line =
914 base::CommandLine::ForCurrentProcess();
915 if (command_line->HasSwitch(switches::kEnableNavigationTracing) &&
916 command_line->HasSwitch(switches::kTraceUploadURL)) {
917 tracing::SetupNavigationTracing();
robliao 2016/09/30 01:10:09 This section seems like it could go outside of Set
fdoray 2016/09/30 12:36:42 No longer changing this section in this CL.
918 }
919
920 #if defined(OS_WIN) || defined(OS_MACOSX) || \
921 (defined(OS_LINUX) && !defined(OS_CHROMEOS))
922 metrics::DesktopSessionDurationTracker::Initialize();
923 #endif
937 } 924 }
938 925
939 void ChromeBrowserMainParts::StartMetricsRecording() { 926 void ChromeBrowserMainParts::StartMetricsRecording() {
940 TRACE_EVENT0("startup", "ChromeBrowserMainParts::StartMetricsRecording"); 927 TRACE_EVENT0("startup", "ChromeBrowserMainParts::StartMetricsRecording");
941 928
942 g_browser_process->metrics_service()->CheckForClonedInstall( 929 g_browser_process->metrics_service()->CheckForClonedInstall(
943 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); 930 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE));
944 931
932 // Register a synthetic field trial for the sampling profiler configuration
933 // that was already chosen. This must be done before the line below creates
934 // the first MetricsLog.
935 sampling_profiler_config_.RegisterSyntheticFieldTrial();
936
945 g_browser_process->GetMetricsServicesManager()->UpdateUploadPermissions(true); 937 g_browser_process->GetMetricsServicesManager()->UpdateUploadPermissions(true);
946 } 938 }
947 939
948 void ChromeBrowserMainParts::RecordBrowserStartupTime() { 940 void ChromeBrowserMainParts::RecordBrowserStartupTime() {
949 // Don't record any metrics if UI was displayed before this point e.g. 941 // Don't record any metrics if UI was displayed before this point e.g.
950 // warning dialogs. 942 // warning dialogs.
951 if (startup_metric_utils::WasNonBrowserUIDisplayed()) 943 if (startup_metric_utils::WasNonBrowserUIDisplayed())
952 return; 944 return;
953 945
954 bool is_first_run = false; 946 bool is_first_run = false;
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 #if !defined(OS_ANDROID) 1516 #if !defined(OS_ANDROID)
1525 if (base::FeatureList::IsEnabled(features::kWebUsb)) { 1517 if (base::FeatureList::IsEnabled(features::kWebUsb)) {
1526 web_usb_detector_.reset(new WebUsbDetector()); 1518 web_usb_detector_.reset(new WebUsbDetector());
1527 BrowserThread::PostAfterStartupTask( 1519 BrowserThread::PostAfterStartupTask(
1528 FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), 1520 FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
1529 base::Bind(&WebUsbDetector::Initialize, 1521 base::Bind(&WebUsbDetector::Initialize,
1530 base::Unretained(web_usb_detector_.get()))); 1522 base::Unretained(web_usb_detector_.get())));
1531 } 1523 }
1532 #endif 1524 #endif
1533 1525
1526 #if defined(OS_WIN)
1527 // Cleanup the PreRead field trial registry key.
1528 // TODO(fdoray): Remove this when M56 hits stable.
1529 const base::string16 pre_read_field_trial_registry_path =
robliao 2016/09/30 01:10:09 Can this be done in a separate CL?
fdoray 2016/09/30 12:36:41 Done. Made the CL smaller.
1530 BrowserDistribution::GetDistribution()->GetRegistryPath() +
1531 L"\\PreReadFieldTrial";
1532 base::win::RegKey(HKEY_CURRENT_USER,
1533 pre_read_field_trial_registry_path.c_str(), KEY_SET_VALUE)
1534 .DeleteKey(L"");
1535 #endif // defined(OS_WIN)
1536
1534 // At this point, StartupBrowserCreator::Start has run creating initial 1537 // At this point, StartupBrowserCreator::Start has run creating initial
1535 // browser windows and tabs, but no progress has been made in loading 1538 // browser windows and tabs, but no progress has been made in loading
1536 // content as the main message loop hasn't started processing tasks yet. 1539 // content as the main message loop hasn't started processing tasks yet.
1537 // We setup to observe to the initial page load here to defer running 1540 // We setup to observe to the initial page load here to defer running
1538 // task posted via PostAfterStartupTask until its complete. 1541 // task posted via PostAfterStartupTask until its complete.
1539 AfterStartupTaskUtils::StartMonitoringStartup(); 1542 AfterStartupTaskUtils::StartMonitoringStartup();
1540 } 1543 }
1541 1544
1542 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { 1545 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
1543 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); 1546 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl");
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 chromeos::CrosSettings::Shutdown(); 2221 chromeos::CrosSettings::Shutdown();
2219 #endif // defined(OS_CHROMEOS) 2222 #endif // defined(OS_CHROMEOS)
2220 #endif // defined(OS_ANDROID) 2223 #endif // defined(OS_ANDROID)
2221 } 2224 }
2222 2225
2223 // Public members: 2226 // Public members:
2224 2227
2225 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 2228 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
2226 chrome_extra_parts_.push_back(parts); 2229 chrome_extra_parts_.push_back(parts);
2227 } 2230 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698