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

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

Issue 2669923004: Use TaskScheduler instead of blocking pool in google_update_metrics_provider_win.cc. (Closed)
Patch Set: upload Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/google_update_metrics_provider_win.h" 5 #include "chrome/browser/metrics/google_update_metrics_provider_win.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_scheduler/post_task.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "components/metrics/proto/system_profile.pb.h" 11 #include "components/metrics/proto/system_profile.pb.h"
12 #include "content/public/browser/browser_thread.h"
13 12
14 typedef metrics::SystemProfileProto::GoogleUpdate::ProductInfo ProductInfo; 13 typedef metrics::SystemProfileProto::GoogleUpdate::ProductInfo ProductInfo;
15 14
16 namespace { 15 namespace {
17 16
18 // Helper function for checking if this is an official build. Used instead of 17 // Helper function for checking if this is an official build. Used instead of
19 // the macro to allow checking for successful code compilation on non-official 18 // the macro to allow checking for successful code compilation on non-official
20 // builds. 19 // builds.
21 bool IsOfficialBuild() { 20 bool IsOfficialBuild() {
22 #if defined(GOOGLE_CHROME_BUILD) 21 #if defined(GOOGLE_CHROME_BUILD)
(...skipping 27 matching lines...) Expand all
50 49
51 void GoogleUpdateMetricsProviderWin::GetGoogleUpdateData( 50 void GoogleUpdateMetricsProviderWin::GetGoogleUpdateData(
52 const base::Closure& done_callback) { 51 const base::Closure& done_callback) {
53 if (!IsOfficialBuild()) { 52 if (!IsOfficialBuild()) {
54 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, done_callback); 53 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, done_callback);
55 return; 54 return;
56 } 55 }
57 56
58 // Schedules a task on a blocking pool thread to gather Google Update 57 // Schedules a task on a blocking pool thread to gather Google Update
59 // statistics (requires Registry reads). 58 // statistics (requires Registry reads).
60 base::PostTaskAndReplyWithResult( 59 base::PostTaskWithTraitsAndReplyWithResult(
61 content::BrowserThread::GetBlockingPool(), 60 FROM_HERE, base::TaskTraits().MayBlock().WithPriority(
62 FROM_HERE, 61 base::TaskPriority::BACKGROUND),
63 base::Bind( 62 base::Bind(&GoogleUpdateMetricsProviderWin::GetGoogleUpdateDataBlocking),
64 &GoogleUpdateMetricsProviderWin::GetGoogleUpdateDataOnBlockingPool), 63 base::Bind(&GoogleUpdateMetricsProviderWin::ReceiveGoogleUpdateData,
65 base::Bind( 64 weak_ptr_factory_.GetWeakPtr(), done_callback));
66 &GoogleUpdateMetricsProviderWin::ReceiveGoogleUpdateData,
67 weak_ptr_factory_.GetWeakPtr(), done_callback));
68 } 65 }
69 66
70 void GoogleUpdateMetricsProviderWin::ProvideSystemProfileMetrics( 67 void GoogleUpdateMetricsProviderWin::ProvideSystemProfileMetrics(
71 metrics::SystemProfileProto* system_profile_proto) { 68 metrics::SystemProfileProto* system_profile_proto) {
72 if (!IsOfficialBuild()) 69 if (!IsOfficialBuild())
73 return; 70 return;
74 71
75 metrics::SystemProfileProto::GoogleUpdate* google_update = 72 metrics::SystemProfileProto::GoogleUpdate* google_update =
76 system_profile_proto->mutable_google_update(); 73 system_profile_proto->mutable_google_update();
77 74
(...skipping 23 matching lines...) Expand all
101 98
102 GoogleUpdateMetricsProviderWin::GoogleUpdateMetrics::GoogleUpdateMetrics() 99 GoogleUpdateMetricsProviderWin::GoogleUpdateMetrics::GoogleUpdateMetrics()
103 : is_system_install(false) { 100 : is_system_install(false) {
104 } 101 }
105 102
106 GoogleUpdateMetricsProviderWin::GoogleUpdateMetrics::~GoogleUpdateMetrics() { 103 GoogleUpdateMetricsProviderWin::GoogleUpdateMetrics::~GoogleUpdateMetrics() {
107 } 104 }
108 105
109 // static 106 // static
110 GoogleUpdateMetricsProviderWin::GoogleUpdateMetrics 107 GoogleUpdateMetricsProviderWin::GoogleUpdateMetrics
111 GoogleUpdateMetricsProviderWin::GetGoogleUpdateDataOnBlockingPool() { 108 GoogleUpdateMetricsProviderWin::GetGoogleUpdateDataBlocking() {
112 GoogleUpdateMetrics google_update_metrics; 109 GoogleUpdateMetrics google_update_metrics;
113 110
114 if (!IsOfficialBuild()) 111 if (!IsOfficialBuild())
115 return google_update_metrics; 112 return google_update_metrics;
116 113
117 const bool is_system_install = GoogleUpdateSettings::IsSystemInstall(); 114 const bool is_system_install = GoogleUpdateSettings::IsSystemInstall();
118 google_update_metrics.is_system_install = is_system_install; 115 google_update_metrics.is_system_install = is_system_install;
119 google_update_metrics.last_started_automatic_update_check = 116 google_update_metrics.last_started_automatic_update_check =
120 GoogleUpdateSettings::GetGoogleUpdateLastStartedAU(is_system_install); 117 GoogleUpdateSettings::GetGoogleUpdateLastStartedAU(is_system_install);
121 google_update_metrics.last_checked = 118 google_update_metrics.last_checked =
122 GoogleUpdateSettings::GetGoogleUpdateLastChecked(is_system_install); 119 GoogleUpdateSettings::GetGoogleUpdateLastChecked(is_system_install);
123 GoogleUpdateSettings::GetUpdateDetailForGoogleUpdate( 120 GoogleUpdateSettings::GetUpdateDetailForGoogleUpdate(
124 is_system_install, 121 is_system_install,
125 &google_update_metrics.google_update_data); 122 &google_update_metrics.google_update_data);
126 GoogleUpdateSettings::GetUpdateDetail( 123 GoogleUpdateSettings::GetUpdateDetail(
127 is_system_install, 124 is_system_install,
128 &google_update_metrics.product_data); 125 &google_update_metrics.product_data);
129 return google_update_metrics; 126 return google_update_metrics;
130 } 127 }
131 128
132 void GoogleUpdateMetricsProviderWin::ReceiveGoogleUpdateData( 129 void GoogleUpdateMetricsProviderWin::ReceiveGoogleUpdateData(
133 const base::Closure& done_callback, 130 const base::Closure& done_callback,
134 const GoogleUpdateMetrics& google_update_metrics) { 131 const GoogleUpdateMetrics& google_update_metrics) {
135 google_update_metrics_ = google_update_metrics; 132 google_update_metrics_ = google_update_metrics;
136 done_callback.Run(); 133 done_callback.Run();
137 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698