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

Side by Side Diff: chrome/browser/metrics/chrome_metrics_services_manager_client.cc

Issue 2237643002: Delay asynchronous work from the metrics clients until after startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b2_afterstartup_runner
Patch Set: rebase dependent Created 4 years, 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/metrics/chrome_metrics_services_manager_client.h" 5 #include "chrome/browser/metrics/chrome_metrics_services_manager_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 21 matching lines...) Expand all
32 32
33 // Metrics reporting feature. This feature, along with user consent, controls if 33 // Metrics reporting feature. This feature, along with user consent, controls if
34 // recording and reporting are enabled. If the feature is enabled, but no 34 // recording and reporting are enabled. If the feature is enabled, but no
35 // consent is given, then there will be no recording or reporting. 35 // consent is given, then there will be no recording or reporting.
36 const base::Feature kMetricsReportingFeature{"MetricsReporting", 36 const base::Feature kMetricsReportingFeature{"MetricsReporting",
37 base::FEATURE_ENABLED_BY_DEFAULT}; 37 base::FEATURE_ENABLED_BY_DEFAULT};
38 38
39 // Posts |GoogleUpdateSettings::StoreMetricsClientInfo| on blocking pool thread 39 // Posts |GoogleUpdateSettings::StoreMetricsClientInfo| on blocking pool thread
40 // because it needs access to IO and cannot work from UI thread. 40 // because it needs access to IO and cannot work from UI thread.
41 void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) { 41 void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) {
42 content::BrowserThread::GetBlockingPool()->PostTask( 42 content::BrowserThread::PostAfterStartupTask(
43 FROM_HERE, 43 FROM_HERE, content::BrowserThread::GetBlockingPool(),
Alexei Svitkine (slow) 2016/08/12 18:28:18 Hmm, in the following CL I'm clearing the client i
gab 2016/08/15 19:39:56 If there is, the race condition already exists tod
44 base::Bind(&GoogleUpdateSettings::StoreMetricsClientInfo, client_info)); 44 base::Bind(&GoogleUpdateSettings::StoreMetricsClientInfo, client_info));
45 } 45 }
46 46
47 // Only clients that were given an opt-out metrics-reporting consent flow are 47 // Only clients that were given an opt-out metrics-reporting consent flow are
48 // eligible for sampling. 48 // eligible for sampling.
49 bool IsClientEligibleForSampling() { 49 bool IsClientEligibleForSampling() {
50 return metrics::GetMetricsReportingDefaultState( 50 return metrics::GetMetricsReportingDefaultState(
51 g_browser_process->local_state()) == 51 g_browser_process->local_state()) ==
52 metrics::EnableMetricsDefault::OPT_OUT; 52 metrics::EnableMetricsDefault::OPT_OUT;
53 } 53 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 ChromeMetricsServicesManagerClient::GetMetricsStateManager() { 175 ChromeMetricsServicesManagerClient::GetMetricsStateManager() {
176 DCHECK(thread_checker_.CalledOnValidThread()); 176 DCHECK(thread_checker_.CalledOnValidThread());
177 if (!metrics_state_manager_) { 177 if (!metrics_state_manager_) {
178 metrics_state_manager_ = metrics::MetricsStateManager::Create( 178 metrics_state_manager_ = metrics::MetricsStateManager::Create(
179 local_state_, enabled_state_provider_.get(), 179 local_state_, enabled_state_provider_.get(),
180 base::Bind(&PostStoreMetricsClientInfo), 180 base::Bind(&PostStoreMetricsClientInfo),
181 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo)); 181 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo));
182 } 182 }
183 return metrics_state_manager_.get(); 183 return metrics_state_manager_.get();
184 } 184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698