Convert StatusCallback to base::RepeatingCallback
Bug: 1152282
Change-Id: Ieced102dbf0f15feadd688c5cc990438d0cdec08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2595846
Reviewed-by: John Lee <[email protected]>
Commit-Queue: Ella Ge <[email protected]>
Cr-Commit-Position: refs/heads/master@{#838746}
diff --git a/chrome/browser/ui/webui/help/test_version_updater.cc b/chrome/browser/ui/webui/help/test_version_updater.cc
index b159078..32e2acd2 100644
--- a/chrome/browser/ui/webui/help/test_version_updater.cc
+++ b/chrome/browser/ui/webui/help/test_version_updater.cc
@@ -8,7 +8,7 @@
TestVersionUpdater::~TestVersionUpdater() = default;
-void TestVersionUpdater::CheckForUpdate(const StatusCallback& callback,
+void TestVersionUpdater::CheckForUpdate(StatusCallback callback,
const PromoteCallback&) {
callback.Run(status_, progress_, rollback_, powerwash_, version_,
update_size_, message_);
diff --git a/chrome/browser/ui/webui/help/test_version_updater.h b/chrome/browser/ui/webui/help/test_version_updater.h
index 8a521dd4..6de58a7a 100644
--- a/chrome/browser/ui/webui/help/test_version_updater.h
+++ b/chrome/browser/ui/webui/help/test_version_updater.h
@@ -19,8 +19,7 @@
TestVersionUpdater();
~TestVersionUpdater() override;
- void CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) override;
+ void CheckForUpdate(StatusCallback callback, const PromoteCallback&) override;
void SetReturnedStatus(Status status) { status_ = status; }
@@ -34,7 +33,7 @@
void GetChannel(bool get_current_channel,
const ChannelCallback& callback) override {}
void GetEolInfo(EolInfoCallback callback) override {}
- void SetUpdateOverCellularOneTimePermission(const StatusCallback& callback,
+ void SetUpdateOverCellularOneTimePermission(StatusCallback callback,
const std::string& update_version,
int64_t update_size) override {}
#endif
diff --git a/chrome/browser/ui/webui/help/version_updater.h b/chrome/browser/ui/webui/help/version_updater.h
index 937a28b3..1c1277b 100644
--- a/chrome/browser/ui/webui/help/version_updater.h
+++ b/chrome/browser/ui/webui/help/version_updater.h
@@ -65,13 +65,13 @@
// |update_size| is the size of the available update in bytes and should be 0
// when update is not available.
// |message| is a message explaining a failure.
- typedef base::Callback<void(Status status,
- int progress,
- bool rollback,
- bool powerwash,
- const std::string& version,
- int64_t update_size,
- const base::string16& message)>
+ typedef base::RepeatingCallback<void(Status status,
+ int progress,
+ bool rollback,
+ bool powerwash,
+ const std::string& version,
+ int64_t update_size,
+ const base::string16& message)>
StatusCallback;
// Used to show or hide the promote UI elements. Mac-only.
@@ -89,7 +89,7 @@
// |status_callback| is called for each status update. |promote_callback|
// (which is only used on the Mac) can be used to show or hide the promote UI
// elements.
- virtual void CheckForUpdate(const StatusCallback& status_callback,
+ virtual void CheckForUpdate(StatusCallback status_callback,
const PromoteCallback& promote_callback) = 0;
#if defined(OS_MAC)
@@ -115,7 +115,7 @@
// there's a new update available or a delta update becomes a full update with
// a larger size.
virtual void SetUpdateOverCellularOneTimePermission(
- const StatusCallback& callback,
+ StatusCallback callback,
const std::string& update_version,
int64_t update_size) = 0;
#endif
diff --git a/chrome/browser/ui/webui/help/version_updater_basic.cc b/chrome/browser/ui/webui/help/version_updater_basic.cc
index 2a4c334..0b0a8c2 100644
--- a/chrome/browser/ui/webui/help/version_updater_basic.cc
+++ b/chrome/browser/ui/webui/help/version_updater_basic.cc
@@ -7,9 +7,8 @@
#include "base/strings/string16.h"
#include "chrome/browser/upgrade_detector/upgrade_detector.h"
-void VersionUpdaterBasic::CheckForUpdate(
- const StatusCallback& status_callback,
- const PromoteCallback&) {
+void VersionUpdaterBasic::CheckForUpdate(StatusCallback status_callback,
+ const PromoteCallback&) {
const Status status = UpgradeDetector::GetInstance()->notify_upgrade()
? NEARLY_UPDATED
: DISABLED;
diff --git a/chrome/browser/ui/webui/help/version_updater_basic.h b/chrome/browser/ui/webui/help/version_updater_basic.h
index 8fbb47a..d5cc437 100644
--- a/chrome/browser/ui/webui/help/version_updater_basic.h
+++ b/chrome/browser/ui/webui/help/version_updater_basic.h
@@ -13,8 +13,8 @@
class VersionUpdaterBasic : public VersionUpdater {
public:
// VersionUpdater implementation.
- void CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) override;
+ void CheckForUpdate(StatusCallback callback, const PromoteCallback&) override;
+
protected:
friend class VersionUpdater;
diff --git a/chrome/browser/ui/webui/help/version_updater_chromeos.cc b/chrome/browser/ui/webui/help/version_updater_chromeos.cc
index 3651443..bf58f02 100644
--- a/chrome/browser/ui/webui/help/version_updater_chromeos.cc
+++ b/chrome/browser/ui/webui/help/version_updater_chromeos.cc
@@ -136,11 +136,11 @@
return new VersionUpdaterCros(web_contents);
}
-void VersionUpdaterCros::GetUpdateStatus(const StatusCallback& callback) {
- callback_ = callback;
+void VersionUpdaterCros::GetUpdateStatus(StatusCallback callback) {
+ callback_ = std::move(callback);
// User is not actively checking for updates.
- if (!EnsureCanUpdate(false /* interactive */, callback))
+ if (!EnsureCanUpdate(false /* interactive */, callback_))
return;
UpdateEngineClient* update_engine_client =
@@ -152,12 +152,12 @@
DBusThreadManager::Get()->GetUpdateEngineClient()->GetLastStatus());
}
-void VersionUpdaterCros::CheckForUpdate(const StatusCallback& callback,
+void VersionUpdaterCros::CheckForUpdate(StatusCallback callback,
const PromoteCallback&) {
- callback_ = callback;
+ callback_ = std::move(callback);
// User is actively checking for updates.
- if (!EnsureCanUpdate(true /* interactive */, callback))
+ if (!EnsureCanUpdate(true /* interactive */, callback_))
return;
UpdateEngineClient* update_engine_client =
@@ -195,10 +195,10 @@
}
void VersionUpdaterCros::SetUpdateOverCellularOneTimePermission(
- const StatusCallback& callback,
+ StatusCallback callback,
const std::string& update_version,
int64_t update_size) {
- callback_ = callback;
+ callback_ = std::move(callback);
DBusThreadManager::Get()
->GetUpdateEngineClient()
->SetUpdateOverCellularOneTimePermission(
diff --git a/chrome/browser/ui/webui/help/version_updater_chromeos.h b/chrome/browser/ui/webui/help/version_updater_chromeos.h
index 0578815..39ac0f4 100644
--- a/chrome/browser/ui/webui/help/version_updater_chromeos.h
+++ b/chrome/browser/ui/webui/help/version_updater_chromeos.h
@@ -19,19 +19,18 @@
public chromeos::UpdateEngineClient::Observer {
public:
// VersionUpdater implementation.
- void CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) override;
+ void CheckForUpdate(StatusCallback callback, const PromoteCallback&) override;
void SetChannel(const std::string& channel,
bool is_powerwash_allowed) override;
void GetChannel(bool get_current_channel,
const ChannelCallback& callback) override;
void GetEolInfo(EolInfoCallback callback) override;
- void SetUpdateOverCellularOneTimePermission(const StatusCallback& callback,
+ void SetUpdateOverCellularOneTimePermission(StatusCallback callback,
const std::string& update_version,
int64_t update_size) override;
// Gets the last update status, without triggering a new check or download.
- void GetUpdateStatus(const StatusCallback& callback);
+ void GetUpdateStatus(StatusCallback callback);
protected:
friend class VersionUpdater;
diff --git a/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc b/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc
index 999a1a6..c0b1623 100644
--- a/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc
+++ b/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc
@@ -126,7 +126,7 @@
EXPECT_EQ(0, fake_update_engine_client_->request_update_check_call_count());
// IDLE -> DOWNLOADING transition after update check.
- version_updater_->CheckForUpdate(base::Bind(&CheckNotification),
+ version_updater_->CheckForUpdate(base::BindRepeating(&CheckNotification),
VersionUpdater::PromoteCallback());
EXPECT_EQ(1, fake_update_engine_client_->request_update_check_call_count());
@@ -150,7 +150,7 @@
fake_update_engine_client_->NotifyObserversThatStatusChanged(status);
}
- version_updater_->CheckForUpdate(base::Bind(&CheckNotification),
+ version_updater_->CheckForUpdate(base::BindRepeating(&CheckNotification),
VersionUpdater::PromoteCallback());
EXPECT_EQ(1, fake_update_engine_client_->request_update_check_call_count());
@@ -172,7 +172,7 @@
TEST_F(VersionUpdaterCrosTest, InteractiveCellularUpdateAllowed) {
SetCellularService();
EXPECT_EQ(0, fake_update_engine_client_->request_update_check_call_count());
- version_updater_->CheckForUpdate(base::Bind(&CheckNotification),
+ version_updater_->CheckForUpdate(base::BindRepeating(&CheckNotification),
VersionUpdater::PromoteCallback());
EXPECT_EQ(1, fake_update_engine_client_->request_update_check_call_count());
}
@@ -185,7 +185,7 @@
const std::string& update_version = "9999.0.0";
const int64_t update_size = 99999;
version_updater_->SetUpdateOverCellularOneTimePermission(
- base::Bind(&CheckNotification), update_version, update_size);
+ base::BindRepeating(&CheckNotification), update_version, update_size);
EXPECT_EQ(1, fake_update_engine_client_->request_update_check_call_count());
}
diff --git a/chrome/browser/ui/webui/help/version_updater_mac.h b/chrome/browser/ui/webui/help/version_updater_mac.h
index f00e08b..eab161d 100644
--- a/chrome/browser/ui/webui/help/version_updater_mac.h
+++ b/chrome/browser/ui/webui/help/version_updater_mac.h
@@ -27,7 +27,7 @@
class VersionUpdaterMac : public VersionUpdater {
public:
// VersionUpdater implementation.
- void CheckForUpdate(const StatusCallback& status_callback,
+ void CheckForUpdate(StatusCallback status_callback,
const PromoteCallback& promote_callback) override;
void PromoteUpdater() const override;
diff --git a/chrome/browser/ui/webui/help/version_updater_mac.mm b/chrome/browser/ui/webui/help/version_updater_mac.mm
index 0cdd1f8..5818db0d 100644
--- a/chrome/browser/ui/webui/help/version_updater_mac.mm
+++ b/chrome/browser/ui/webui/help/version_updater_mac.mm
@@ -78,7 +78,7 @@
}
void UpdateStatusFromChromiumUpdater(
- const VersionUpdater::StatusCallback& status_callback,
+ VersionUpdater::StatusCallback status_callback,
updater::UpdateService::UpdateState update_state) {
VersionUpdater::Status status = VersionUpdater::Status::CHECKING;
int progress = 0;
@@ -136,17 +136,17 @@
VersionUpdaterMac::~VersionUpdaterMac() {}
void VersionUpdaterMac::CheckForUpdate(
- const StatusCallback& status_callback,
+ StatusCallback status_callback,
const PromoteCallback& promote_callback) {
#if BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
if (!update_client_)
update_client_ = BrowserUpdaterClient::Create();
- update_client_->CheckForUpdate(
- base::BindRepeating(&UpdateStatusFromChromiumUpdater, status_callback));
+ update_client_->CheckForUpdate(base::BindRepeating(
+ &UpdateStatusFromChromiumUpdater, std::move(status_callback)));
return;
#else
- status_callback_ = status_callback;
+ status_callback_ = std::move(status_callback);
promote_callback_ = promote_callback;
KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue];
diff --git a/chrome/browser/ui/webui/help/version_updater_win.cc b/chrome/browser/ui/webui/help/version_updater_win.cc
index be910614..9101776 100644
--- a/chrome/browser/ui/webui/help/version_updater_win.cc
+++ b/chrome/browser/ui/webui/help/version_updater_win.cc
@@ -26,10 +26,10 @@
VersionUpdaterWin::~VersionUpdaterWin() {
}
-void VersionUpdaterWin::CheckForUpdate(const StatusCallback& callback,
+void VersionUpdaterWin::CheckForUpdate(StatusCallback callback,
const PromoteCallback&) {
// There is no supported integration with Google Update for Chromium.
- callback_ = callback;
+ callback_ = std::move(callback);
callback_.Run(CHECKING, 0, false, false, std::string(), 0, base::string16());
DoBeginUpdateCheck(false /* !install_update_if_possible */);
diff --git a/chrome/browser/ui/webui/help/version_updater_win.h b/chrome/browser/ui/webui/help/version_updater_win.h
index f225a23..94398857 100644
--- a/chrome/browser/ui/webui/help/version_updater_win.h
+++ b/chrome/browser/ui/webui/help/version_updater_win.h
@@ -25,8 +25,7 @@
~VersionUpdaterWin() override;
// VersionUpdater:
- void CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) override;
+ void CheckForUpdate(StatusCallback callback, const PromoteCallback&) override;
// UpdateCheckDelegate:
void OnUpdateCheckComplete(const base::string16& new_version) override;
diff --git a/chrome/browser/ui/webui/settings/about_handler.cc b/chrome/browser/ui/webui/settings/about_handler.cc
index d4522c4e..9a55940 100644
--- a/chrome/browser/ui/webui/settings/about_handler.cc
+++ b/chrome/browser/ui/webui/settings/about_handler.cc
@@ -470,7 +470,8 @@
if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
// Check for update after switching release channel.
version_updater_->CheckForUpdate(
- base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)),
+ base::BindRepeating(&AboutHandler::SetUpdateStatus,
+ base::Unretained(this)),
VersionUpdater::PromoteCallback());
}
}
@@ -570,7 +571,8 @@
void AboutHandler::RequestUpdateOverCellular(const std::string& update_version,
int64_t update_size) {
version_updater_->SetUpdateOverCellularOneTimePermission(
- base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)),
+ base::BindRepeating(&AboutHandler::SetUpdateStatus,
+ base::Unretained(this)),
update_version, update_size);
}
@@ -625,9 +627,11 @@
void AboutHandler::RequestUpdate() {
version_updater_->CheckForUpdate(
- base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)),
+ base::BindRepeating(&AboutHandler::SetUpdateStatus,
+ base::Unretained(this)),
#if defined(OS_MAC)
- base::Bind(&AboutHandler::SetPromotionState, base::Unretained(this)));
+ base::BindRepeating(&AboutHandler::SetPromotionState,
+ base::Unretained(this)));
#else
VersionUpdater::PromoteCallback());
#endif // OS_MAC
diff --git a/chrome/browser/ui/webui/settings/safety_check_handler.cc b/chrome/browser/ui/webui/settings/safety_check_handler.cc
index 0d00091..39e80de 100644
--- a/chrome/browser/ui/webui/settings/safety_check_handler.cc
+++ b/chrome/browser/ui/webui/settings/safety_check_handler.cc
@@ -388,8 +388,8 @@
void SafetyCheckHandler::CheckUpdates() {
// Usage of base::Unretained(this) is safe, because we own `version_updater_`.
version_updater_->CheckForUpdate(
- base::Bind(&SafetyCheckHandler::OnVersionUpdaterResult,
- base::Unretained(this)),
+ base::BindRepeating(&SafetyCheckHandler::OnVersionUpdaterResult,
+ base::Unretained(this)),
VersionUpdater::PromoteCallback());
}
diff --git a/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc b/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc
index 6e291145..a8eb9e7 100644
--- a/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc
+++ b/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc
@@ -99,7 +99,7 @@
public:
~TestDestructionVersionUpdater() override { destructor_invoked_ = true; }
- void CheckForUpdate(const StatusCallback& callback,
+ void CheckForUpdate(StatusCallback callback,
const PromoteCallback&) override {}
static bool GetDestructorInvoked() { return destructor_invoked_; }