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

Side by Side Diff: ios/chrome/browser/ios_chrome_main_parts.mm

Issue 2569863003: Move SetupMetrics() to PreMainMessageLoopRun (Closed)
Patch Set: Created 4 years 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 | 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/ios_chrome_main_parts.h" 5 #include "ios/chrome/browser/ios_chrome_main_parts.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // the calls below end up implicitly creating threads and as such new calls 125 // the calls below end up implicitly creating threads and as such new calls
126 // typically either belong before them or in a later startup phase. 126 // typically either belong before them or in a later startup phase.
127 127
128 // Now that the command line has been mutated based on about:flags, we can 128 // Now that the command line has been mutated based on about:flags, we can
129 // initialize field trials and setup metrics. The field trials are needed by 129 // initialize field trials and setup metrics. The field trials are needed by
130 // IOThread's initialization in ApplicationContext's PreCreateThreads. 130 // IOThread's initialization in ApplicationContext's PreCreateThreads.
131 SetupFieldTrials(); 131 SetupFieldTrials();
132 132
133 // Task Scheduler initialization needs to be here for the following reasons: 133 // Task Scheduler initialization needs to be here for the following reasons:
134 // * After |SetupFieldTrials()|: Initialization uses variations. 134 // * After |SetupFieldTrials()|: Initialization uses variations.
135 // * Before |SetupMetrics()|: |SetupMetrics()| uses the blocking pool. The
136 // Task Scheduler must do any necessary redirection before then.
137 // * Near the end of |PreCreateThreads()|: The TaskScheduler needs to be 135 // * Near the end of |PreCreateThreads()|: The TaskScheduler needs to be
138 // created before any other threads are (by contract) but it creates 136 // created before any other threads are (by contract) but it creates
139 // threads itself so instantiating it earlier is also incorrect. 137 // threads itself so instantiating it earlier is also incorrect.
140 // To maintain scoping symmetry, if this line is moved, the corresponding 138 // To maintain scoping symmetry, if this line is moved, the corresponding
141 // shutdown call may also need to be moved. 139 // shutdown call may also need to be moved.
142 task_scheduler_util::InitializeDefaultBrowserTaskScheduler(); 140 task_scheduler_util::InitializeDefaultBrowserTaskScheduler();
143 141
144 SetupMetrics();
145 142
146 // Initialize FieldTrialSynchronizer system. 143 // Initialize FieldTrialSynchronizer system.
147 field_trial_synchronizer_.reset(new ios::FieldTrialSynchronizer); 144 field_trial_synchronizer_.reset(new ios::FieldTrialSynchronizer);
148 145
149 application_context_->PreCreateThreads(); 146 application_context_->PreCreateThreads();
150 } 147 }
151 148
152 void IOSChromeMainParts::PreMainMessageLoopRun() { 149 void IOSChromeMainParts::PreMainMessageLoopRun() {
150 // This must occur at PreMainMessageLoopRun because |SetupMetrics()| uses the
151 // blocking pool, which is disabled until the CreateThreads phase of startup.
152 SetupMetrics();
153
153 // Now that the file thread has been started, start recording. 154 // Now that the file thread has been started, start recording.
154 StartMetricsRecording(); 155 StartMetricsRecording();
155 156
156 application_context_->PreMainMessageLoopRun(); 157 application_context_->PreMainMessageLoopRun();
157 158
158 // ContentSettingsPattern need to be initialized before creating the 159 // ContentSettingsPattern need to be initialized before creating the
159 // ChromeBrowserState. 160 // ChromeBrowserState.
160 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme( 161 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme(
161 kDummyExtensionScheme); 162 kDummyExtensionScheme);
162 163
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 302
302 void IOSChromeMainParts::StartMetricsRecording() { 303 void IOSChromeMainParts::StartMetricsRecording() {
303 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly); 304 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly);
304 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular( 305 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular(
305 net::NetworkChangeNotifier::GetConnectionType()); 306 net::NetworkChangeNotifier::GetConnectionType());
306 bool mayUpload = !wifiOnly || !isConnectionCellular; 307 bool mayUpload = !wifiOnly || !isConnectionCellular;
307 308
308 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions( 309 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions(
309 mayUpload); 310 mayUpload);
310 } 311 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698