Commit d9339152 authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

Replace GetBlockingPool and FILE thread with post_task API

BUG=689520,667892

Change-Id: I1143fbc8c5f7c12dfdd8e5764d58c9b372d3cb16
Reviewed-on: https://chromium-review.googlesource.com/544782
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481889}
parent 42a42788
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/task_scheduler/post_task.h"
#include "base/win/win_util.h" #include "base/win/win_util.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -40,7 +40,7 @@ void VersionUpdaterWin::CheckForUpdate(const StatusCallback& callback, ...@@ -40,7 +40,7 @@ void VersionUpdaterWin::CheckForUpdate(const StatusCallback& callback,
(base::win::OSInfo::GetInstance()->service_pack().major == 0) && (base::win::OSInfo::GetInstance()->service_pack().major == 0) &&
!base::win::UserAccountControlIsEnabled())) { !base::win::UserAccountControlIsEnabled())) {
callback_.Run(CHECKING, 0, std::string(), 0, base::string16()); callback_.Run(CHECKING, 0, std::string(), 0, base::string16());
BeginUpdateCheckOnFileThread(false /* !install_update_if_possible */); BeginUpdateCheckInBackground(false /* !install_update_if_possible */);
} }
} }
...@@ -51,11 +51,12 @@ void VersionUpdaterWin::OnUpdateCheckComplete( ...@@ -51,11 +51,12 @@ void VersionUpdaterWin::OnUpdateCheckComplete(
if (new_version.empty()) { if (new_version.empty()) {
// Google Update says that no new version is available. Check to see if a // Google Update says that no new version is available. Check to see if a
// restart is needed for a previously-applied update to take effect. // restart is needed for a previously-applied update to take effect.
if (base::PostTaskAndReplyWithResult( if (base::PostTaskWithTraitsAndReplyWithResult(
content::BrowserThread::GetBlockingPool(),
FROM_HERE, FROM_HERE,
base::Bind(&upgrade_util::IsUpdatePendingRestart), {base::TaskPriority::USER_VISIBLE, base::MayBlock(),
base::Bind(&VersionUpdaterWin::OnPendingRestartCheck, base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&upgrade_util::IsUpdatePendingRestart),
base::BindOnce(&VersionUpdaterWin::OnPendingRestartCheck,
weak_factory_.GetWeakPtr()))) { weak_factory_.GetWeakPtr()))) {
// Early exit since callback_ will be Run in OnPendingRestartCheck. // Early exit since callback_ will be Run in OnPendingRestartCheck.
return; return;
...@@ -67,7 +68,7 @@ void VersionUpdaterWin::OnUpdateCheckComplete( ...@@ -67,7 +68,7 @@ void VersionUpdaterWin::OnUpdateCheckComplete(
} else { } else {
// Notify the caller that the update is now beginning and initiate it. // Notify the caller that the update is now beginning and initiate it.
status = UPDATING; status = UPDATING;
BeginUpdateCheckOnFileThread(true /* install_update_if_possible */); BeginUpdateCheckInBackground(true /* install_update_if_possible */);
} }
callback_.Run(status, 0, std::string(), 0, base::string16()); callback_.Run(status, 0, std::string(), 0, base::string16());
} }
...@@ -114,12 +115,13 @@ void VersionUpdaterWin::OnError(GoogleUpdateErrorCode error_code, ...@@ -114,12 +115,13 @@ void VersionUpdaterWin::OnError(GoogleUpdateErrorCode error_code,
callback_.Run(status, 0, std::string(), 0, message); callback_.Run(status, 0, std::string(), 0, message);
} }
void VersionUpdaterWin::BeginUpdateCheckOnFileThread( void VersionUpdaterWin::BeginUpdateCheckInBackground(
bool install_update_if_possible) { bool install_update_if_possible) {
// Disconnect from any previous attempts to avoid redundant callbacks. // Disconnect from any previous attempts to avoid redundant callbacks.
weak_factory_.InvalidateWeakPtrs(); weak_factory_.InvalidateWeakPtrs();
BeginUpdateCheck(content::BrowserThread::GetTaskRunnerForThread( BeginUpdateCheck(base::CreateCOMSTATaskRunnerWithTraits(
content::BrowserThread::FILE), (base::TaskPriority::USER_VISIBLE, base::MayBlock(),
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)),
g_browser_process->GetApplicationLocale(), g_browser_process->GetApplicationLocale(),
install_update_if_possible, owner_widget_, install_update_if_possible, owner_widget_,
weak_factory_.GetWeakPtr()); weak_factory_.GetWeakPtr());
......
...@@ -38,7 +38,7 @@ class VersionUpdaterWin : public VersionUpdater, ...@@ -38,7 +38,7 @@ class VersionUpdaterWin : public VersionUpdater,
const base::string16& new_version) override; const base::string16& new_version) override;
private: private:
void BeginUpdateCheckOnFileThread(bool install_update_if_possible); void BeginUpdateCheckInBackground(bool install_update_if_possible);
// A task run on the UI thread with the result of checking for a pending // A task run on the UI thread with the result of checking for a pending
// restart. // restart.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment