summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-02 21:07:14 +0000
committerasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-02 21:07:14 +0000
commite73b7c73836c70723a3ffc7598683edf7516b2c6 (patch)
tree937ebde79f6705fa02d7b59ef9bdfe101ea89c45
parente8a2d6478659976aa9d48a0abb4ecd0c963d5eb8 (diff)
downloadchromium_src-e73b7c73836c70723a3ffc7598683edf7516b2c6.zip
chromium_src-e73b7c73836c70723a3ffc7598683edf7516b2c6.tar.gz
chromium_src-e73b7c73836c70723a3ffc7598683edf7516b2c6.tar.bz2
Fix post task sequence in GoogleUpdateMetricsProviderWin.
Previously, it was posting a task to another thread with a weak pointer to itself, which is wrong. BUG=389665 Review URL: https://codereview.chromium.org/360563003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281093 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/metrics/google_update_metrics_provider_win.cc37
-rw-r--r--chrome/browser/metrics/google_update_metrics_provider_win.h8
2 files changed, 33 insertions, 12 deletions
diff --git a/chrome/browser/metrics/google_update_metrics_provider_win.cc b/chrome/browser/metrics/google_update_metrics_provider_win.cc
index 1b7dee8..397049f 100644
--- a/chrome/browser/metrics/google_update_metrics_provider_win.cc
+++ b/chrome/browser/metrics/google_update_metrics_provider_win.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/metrics/google_update_metrics_provider_win.h"
#include "base/message_loop/message_loop.h"
+#include "base/task_runner_util.h"
#include "components/metrics/proto/system_profile.pb.h"
#include "content/public/browser/browser_thread.h"
@@ -54,12 +55,14 @@ void GoogleUpdateMetricsProviderWin::GetGoogleUpdateData(
// Schedules a task on a blocking pool thread to gather Google Update
// statistics (requires Registry reads).
- content::BrowserThread::PostBlockingPoolTaskAndReply(
+ base::PostTaskAndReplyWithResult(
+ content::BrowserThread::GetBlockingPool(),
FROM_HERE,
base::Bind(
- &GoogleUpdateMetricsProviderWin::GetGoogleUpdateDataOnBlockingPool,
- weak_ptr_factory_.GetWeakPtr()),
- done_callback);
+ &GoogleUpdateMetricsProviderWin::GetGoogleUpdateDataOnBlockingPool),
+ base::Bind(
+ &GoogleUpdateMetricsProviderWin::ReceiveGoogleUpdateData,
+ weak_ptr_factory_.GetWeakPtr(), done_callback));
}
void GoogleUpdateMetricsProviderWin::ProvideSystemProfileMetrics(
@@ -101,20 +104,32 @@ GoogleUpdateMetricsProviderWin::GoogleUpdateMetrics::GoogleUpdateMetrics()
GoogleUpdateMetricsProviderWin::GoogleUpdateMetrics::~GoogleUpdateMetrics() {
}
-void GoogleUpdateMetricsProviderWin::GetGoogleUpdateDataOnBlockingPool() {
+// static
+GoogleUpdateMetricsProviderWin::GoogleUpdateMetrics
+GoogleUpdateMetricsProviderWin::GetGoogleUpdateDataOnBlockingPool() {
+ GoogleUpdateMetrics google_update_metrics;
+
if (!IsOfficialBuild())
- return;
+ return google_update_metrics;
const bool is_system_install = GoogleUpdateSettings::IsSystemInstall();
- google_update_metrics_.is_system_install = is_system_install;
- google_update_metrics_.last_started_automatic_update_check =
+ google_update_metrics.is_system_install = is_system_install;
+ google_update_metrics.last_started_automatic_update_check =
GoogleUpdateSettings::GetGoogleUpdateLastStartedAU(is_system_install);
- google_update_metrics_.last_checked =
+ google_update_metrics.last_checked =
GoogleUpdateSettings::GetGoogleUpdateLastChecked(is_system_install);
GoogleUpdateSettings::GetUpdateDetailForGoogleUpdate(
is_system_install,
- &google_update_metrics_.google_update_data);
+ &google_update_metrics.google_update_data);
GoogleUpdateSettings::GetUpdateDetail(
is_system_install,
- &google_update_metrics_.product_data);
+ &google_update_metrics.product_data);
+ return google_update_metrics;
+}
+
+void GoogleUpdateMetricsProviderWin::ReceiveGoogleUpdateData(
+ const base::Closure& done_callback,
+ const GoogleUpdateMetrics& google_update_metrics) {
+ google_update_metrics_ = google_update_metrics;
+ done_callback.Run();
}
diff --git a/chrome/browser/metrics/google_update_metrics_provider_win.h b/chrome/browser/metrics/google_update_metrics_provider_win.h
index 6c88a4d..073fd8d6 100644
--- a/chrome/browser/metrics/google_update_metrics_provider_win.h
+++ b/chrome/browser/metrics/google_update_metrics_provider_win.h
@@ -50,7 +50,13 @@ class GoogleUpdateMetricsProviderWin : public metrics::MetricsProvider {
};
// Retrieve the Google Update data on the blocking pool.
- void GetGoogleUpdateDataOnBlockingPool();
+ static GoogleUpdateMetrics GetGoogleUpdateDataOnBlockingPool();
+
+ // Receives |google_update_metrics| from a blocking pool thread and runs
+ // |done_callback|.
+ void ReceiveGoogleUpdateData(
+ const base::Closure& done_callback,
+ const GoogleUpdateMetrics& google_update_metrics);
// Google Update metrics that were fetched via GetGoogleUpdateData(). Will be
// filled in only after the successful completion of GetGoogleUpdateData().