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

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

Issue 2769803002: Use TaskScheduler instead of blocking pool in chrome_metrics_services_manager_client.cc. (Closed)
Patch Set: rebase Created 3 years, 7 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 | « 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 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"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/task_scheduler/post_task.h"
12 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 14 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
14 #include "chrome/browser/metrics/chrome_metrics_service_client.h" 15 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
15 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h" 16 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h"
16 #include "chrome/browser/metrics/variations/ui_string_overrider_factory.h" 17 #include "chrome/browser/metrics/variations/ui_string_overrider_factory.h"
17 #include "chrome/browser/ui/browser_otr_state.h" 18 #include "chrome/browser/ui/browser_otr_state.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/installer/util/google_update_settings.h" 20 #include "chrome/installer/util/google_update_settings.h"
20 #include "components/metrics/enabled_state_provider.h" 21 #include "components/metrics/enabled_state_provider.h"
21 #include "components/metrics/metrics_state_manager.h" 22 #include "components/metrics/metrics_state_manager.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 56
56 // Metrics reporting feature. This feature, along with user consent, controls if 57 // Metrics reporting feature. This feature, along with user consent, controls if
57 // recording and reporting are enabled. If the feature is enabled, but no 58 // recording and reporting are enabled. If the feature is enabled, but no
58 // consent is given, then there will be no recording or reporting. 59 // consent is given, then there will be no recording or reporting.
59 const base::Feature kMetricsReportingFeature{"MetricsReporting", 60 const base::Feature kMetricsReportingFeature{"MetricsReporting",
60 base::FEATURE_ENABLED_BY_DEFAULT}; 61 base::FEATURE_ENABLED_BY_DEFAULT};
61 62
62 // Posts |GoogleUpdateSettings::StoreMetricsClientInfo| on blocking pool thread 63 // Posts |GoogleUpdateSettings::StoreMetricsClientInfo| on blocking pool thread
63 // because it needs access to IO and cannot work from UI thread. 64 // because it needs access to IO and cannot work from UI thread.
64 void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) { 65 void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) {
65 // The message loop processes messages after the blocking pool is initialized. 66 base::PostTaskWithTraits(
66 // Posting a task to the message loop to post a task to the blocking pool 67 FROM_HERE,
67 // ensures that the blocking pool is ready to accept tasks at that time. 68 base::TaskTraits()
68 content::BrowserThread::PostTask( 69 .WithPriority(base::TaskPriority::BACKGROUND)
69 content::BrowserThread::UI, FROM_HERE, 70 .MayBlock(),
70 base::BindOnce( 71 base::BindOnce(&GoogleUpdateSettings::StoreMetricsClientInfo,
71 [](const metrics::ClientInfo& client_info) { 72 client_info));
72 content::BrowserThread::PostBlockingPoolTask(
73 FROM_HERE,
74 base::BindOnce(&GoogleUpdateSettings::StoreMetricsClientInfo,
75 client_info));
76 },
77 client_info));
78 } 73 }
79 74
80 // Appends a group to the sampling controlling |trial|. The group will be 75 // Appends a group to the sampling controlling |trial|. The group will be
81 // associated with a variation param for reporting sampling |rate| in per mille. 76 // associated with a variation param for reporting sampling |rate| in per mille.
82 void AppendSamplingTrialGroup(const std::string& group_name, 77 void AppendSamplingTrialGroup(const std::string& group_name,
83 int rate, 78 int rate,
84 base::FieldTrial* trial) { 79 base::FieldTrial* trial) {
85 std::map<std::string, std::string> params = { 80 std::map<std::string, std::string> params = {
86 {kRateParamName, base::IntToString(rate)}}; 81 {kRateParamName, base::IntToString(rate)}};
87 variations::AssociateVariationParams(trial->trial_name(), group_name, params); 82 variations::AssociateVariationParams(trial->trial_name(), group_name, params);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 ChromeMetricsServicesManagerClient::GetMetricsStateManager() { 284 ChromeMetricsServicesManagerClient::GetMetricsStateManager() {
290 DCHECK(thread_checker_.CalledOnValidThread()); 285 DCHECK(thread_checker_.CalledOnValidThread());
291 if (!metrics_state_manager_) { 286 if (!metrics_state_manager_) {
292 metrics_state_manager_ = metrics::MetricsStateManager::Create( 287 metrics_state_manager_ = metrics::MetricsStateManager::Create(
293 local_state_, enabled_state_provider_.get(), 288 local_state_, enabled_state_provider_.get(),
294 base::Bind(&PostStoreMetricsClientInfo), 289 base::Bind(&PostStoreMetricsClientInfo),
295 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo)); 290 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo));
296 } 291 }
297 return metrics_state_manager_.get(); 292 return metrics_state_manager_.get();
298 } 293 }
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