Commit 1864e6e3 authored by Tomasz Tylenda's avatar Tomasz Tylenda Committed by Commit Bot

Revert "Migrate base::Callback to base::OnceCallback."

This reverts commit a0282608.

Reason for revert: b/169804713 

Original change's description:
> Migrate base::Callback to base::OnceCallback.
>
> BUG=764795
> TEST=build
>
> Change-Id: I8afa2fd87eb5cf5d9a8f7ecde9fad95d420c5399
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2434405
> Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
> Commit-Queue: Tomasz Tylenda <ttylenda@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#811980}

TBR=hidehiko@chromium.org,ttylenda@chromium.org

Change-Id: I7de1e3dac102f4c760aef90da690016b020baa3f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 764795
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440088Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Tomasz Tylenda <ttylenda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812516}
parent 49e56e4b
...@@ -37,13 +37,13 @@ ArcAuthContext::~ArcAuthContext() { ...@@ -37,13 +37,13 @@ ArcAuthContext::~ArcAuthContext() {
identity_manager_->RemoveObserver(this); identity_manager_->RemoveObserver(this);
} }
void ArcAuthContext::Prepare(PrepareCallback callback) { void ArcAuthContext::Prepare(const PrepareCallback& callback) {
if (context_prepared_) { if (context_prepared_) {
std::move(callback).Run(true); callback.Run(true);
return; return;
} }
callback_ = std::move(callback); callback_ = callback;
identity_manager_->RemoveObserver(this); identity_manager_->RemoveObserver(this);
refresh_token_timeout_.Stop(); refresh_token_timeout_.Stop();
......
...@@ -31,8 +31,8 @@ class ArcAuthContext : public signin::IdentityManager::Observer { ...@@ -31,8 +31,8 @@ class ArcAuthContext : public signin::IdentityManager::Observer {
// cancel the inflight operation. // cancel the inflight operation.
// On completion, |true| is passed to the callback. On error, |false| // On completion, |true| is passed to the callback. On error, |false|
// is passed. // is passed.
using PrepareCallback = base::OnceCallback<void(bool success)>; using PrepareCallback = base::Callback<void(bool success)>;
void Prepare(PrepareCallback callback); void Prepare(const PrepareCallback& callback);
// Creates and starts a request to fetch an access token for the given // Creates and starts a request to fetch an access token for the given
// |scopes|. The caller owns the returned request. |callback| will be // |scopes|. The caller owns the returned request. |callback| will be
......
...@@ -2247,23 +2247,21 @@ void ArcBluetoothBridge::EnableAdvertisementImpl( ...@@ -2247,23 +2247,21 @@ void ArcBluetoothBridge::EnableAdvertisementImpl(
base::Bind(&ArcBluetoothBridge::OnReadyToRegisterAdvertisement, base::Bind(&ArcBluetoothBridge::OnReadyToRegisterAdvertisement,
weak_factory_.GetWeakPtr(), repeating_callback, adv_handle, weak_factory_.GetWeakPtr(), repeating_callback, adv_handle,
base::Passed(std::move(advertisement))); base::Passed(std::move(advertisement)));
base::OnceCallback<void(BluetoothAdvertisement::ErrorCode)> error_callback = base::Callback<void(BluetoothAdvertisement::ErrorCode)> error_callback =
base::BindOnce(&ArcBluetoothBridge::OnRegisterAdvertisementError, base::Bind(&ArcBluetoothBridge::OnRegisterAdvertisementError,
weak_factory_.GetWeakPtr(), repeating_callback, weak_factory_.GetWeakPtr(), repeating_callback, adv_handle);
adv_handle);
auto it = advertisements_.find(adv_handle); auto it = advertisements_.find(adv_handle);
if (it == advertisements_.end()) { if (it == advertisements_.end()) {
std::move(error_callback) error_callback.Run(
.Run(BluetoothAdvertisement::ErrorCode:: BluetoothAdvertisement::ErrorCode::ERROR_ADVERTISEMENT_DOES_NOT_EXIST);
ERROR_ADVERTISEMENT_DOES_NOT_EXIST);
return; return;
} }
if (it->second == nullptr) { if (it->second == nullptr) {
std::move(done_callback).Run(); done_callback.Run();
return; return;
} }
it->second->Unregister(done_callback, std::move(error_callback)); it->second->Unregister(done_callback, error_callback);
} }
void ArcBluetoothBridge::DisableAdvertisement( void ArcBluetoothBridge::DisableAdvertisement(
...@@ -2286,23 +2284,21 @@ void ArcBluetoothBridge::DisableAdvertisementImpl( ...@@ -2286,23 +2284,21 @@ void ArcBluetoothBridge::DisableAdvertisementImpl(
base::Closure done_callback = base::Closure done_callback =
base::Bind(&ArcBluetoothBridge::OnUnregisterAdvertisementDone, base::Bind(&ArcBluetoothBridge::OnUnregisterAdvertisementDone,
weak_factory_.GetWeakPtr(), repeating_callback, adv_handle); weak_factory_.GetWeakPtr(), repeating_callback, adv_handle);
base::OnceCallback<void(BluetoothAdvertisement::ErrorCode)> error_callback = base::Callback<void(BluetoothAdvertisement::ErrorCode)> error_callback =
base::BindOnce(&ArcBluetoothBridge::OnUnregisterAdvertisementError, base::Bind(&ArcBluetoothBridge::OnUnregisterAdvertisementError,
weak_factory_.GetWeakPtr(), repeating_callback, weak_factory_.GetWeakPtr(), repeating_callback, adv_handle);
adv_handle);
auto it = advertisements_.find(adv_handle); auto it = advertisements_.find(adv_handle);
if (it == advertisements_.end()) { if (it == advertisements_.end()) {
std::move(error_callback) error_callback.Run(
.Run(BluetoothAdvertisement::ErrorCode:: BluetoothAdvertisement::ErrorCode::ERROR_ADVERTISEMENT_DOES_NOT_EXIST);
ERROR_ADVERTISEMENT_DOES_NOT_EXIST);
return; return;
} }
if (it->second == nullptr) { if (it->second == nullptr) {
done_callback.Run(); done_callback.Run();
return; return;
} }
it->second->Unregister(done_callback, std::move(error_callback)); it->second->Unregister(done_callback, error_callback);
} }
void ArcBluetoothBridge::ReleaseAdvertisementHandle( void ArcBluetoothBridge::ReleaseAdvertisementHandle(
......
...@@ -174,10 +174,9 @@ class ArcFileSystemWatcherServiceFactory ...@@ -174,10 +174,9 @@ class ArcFileSystemWatcherServiceFactory
// directory. // directory.
class ArcFileSystemWatcherService::FileSystemWatcher { class ArcFileSystemWatcherService::FileSystemWatcher {
public: public:
using Callback = using Callback = base::Callback<void(const std::vector<std::string>& paths)>;
base::OnceCallback<void(const std::vector<std::string>& paths)>;
FileSystemWatcher(Callback callback, FileSystemWatcher(const Callback& callback,
const base::FilePath& cros_dir, const base::FilePath& cros_dir,
const base::FilePath& android_dir); const base::FilePath& android_dir);
~FileSystemWatcher(); ~FileSystemWatcher();
...@@ -220,10 +219,10 @@ class ArcFileSystemWatcherService::FileSystemWatcher { ...@@ -220,10 +219,10 @@ class ArcFileSystemWatcherService::FileSystemWatcher {
}; };
ArcFileSystemWatcherService::FileSystemWatcher::FileSystemWatcher( ArcFileSystemWatcherService::FileSystemWatcher::FileSystemWatcher(
Callback callback, const Callback& callback,
const base::FilePath& cros_dir, const base::FilePath& cros_dir,
const base::FilePath& android_dir) const base::FilePath& android_dir)
: callback_(std::move(callback)), : callback_(callback),
cros_dir_(cros_dir), cros_dir_(cros_dir),
android_dir_(android_dir), android_dir_(android_dir),
last_notify_time_(base::TimeTicks()), last_notify_time_(base::TimeTicks()),
...@@ -296,7 +295,7 @@ void ArcFileSystemWatcherService::FileSystemWatcher::OnBuildTimestampMap( ...@@ -296,7 +295,7 @@ void ArcFileSystemWatcherService::FileSystemWatcher::OnBuildTimestampMap(
string_paths[i] = changed_paths[i].value(); string_paths[i] = changed_paths[i].value();
} }
content::GetUIThreadTaskRunner({})->PostTask( content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(std::move(callback_), std::move(string_paths))); FROM_HERE, base::BindOnce(callback_, std::move(string_paths)));
if (last_notify_time_ > snapshot_time) if (last_notify_time_ > snapshot_time)
DelayBuildTimestampMap(); DelayBuildTimestampMap();
else else
......
...@@ -13,9 +13,9 @@ ArcTermsOfServiceNegotiator::ArcTermsOfServiceNegotiator() = default; ...@@ -13,9 +13,9 @@ ArcTermsOfServiceNegotiator::ArcTermsOfServiceNegotiator() = default;
ArcTermsOfServiceNegotiator::~ArcTermsOfServiceNegotiator() = default; ArcTermsOfServiceNegotiator::~ArcTermsOfServiceNegotiator() = default;
void ArcTermsOfServiceNegotiator::StartNegotiation( void ArcTermsOfServiceNegotiator::StartNegotiation(
NegotiationCallback callback) { const NegotiationCallback& callback) {
DCHECK(pending_callback_.is_null()); DCHECK(pending_callback_.is_null());
pending_callback_ = std::move(callback); pending_callback_ = callback;
StartNegotiationImpl(); StartNegotiationImpl();
} }
......
...@@ -20,8 +20,8 @@ class ArcTermsOfServiceNegotiator { ...@@ -20,8 +20,8 @@ class ArcTermsOfServiceNegotiator {
// accepts ToS. If user explicitly rejects ToS, invokes |callback| with // accepts ToS. If user explicitly rejects ToS, invokes |callback| with
// |accepted| = false. Deleting this instance cancels the operation, so // |accepted| = false. Deleting this instance cancels the operation, so
// |callback| will never be invoked then. // |callback| will never be invoked then.
using NegotiationCallback = base::OnceCallback<void(bool accepted)>; using NegotiationCallback = base::Callback<void(bool accepted)>;
void StartNegotiation(NegotiationCallback callback); void StartNegotiation(const NegotiationCallback& callback);
protected: protected:
// Reports result of negotiation via callback and then resets it. If // Reports result of negotiation via callback and then resets it. If
......
...@@ -70,7 +70,7 @@ void ArcAndroidManagementChecker::StartClient() { ...@@ -70,7 +70,7 @@ void ArcAndroidManagementChecker::StartClient() {
GetDeviceManagementService()->ScheduleInitialization(0); GetDeviceManagementService()->ScheduleInitialization(0);
} }
void ArcAndroidManagementChecker::StartCheck(CheckCallback callback) { void ArcAndroidManagementChecker::StartCheck(const CheckCallback& callback) {
DCHECK(callback_.is_null()); DCHECK(callback_.is_null());
// Do not send requests for Chrome OS managed users, nor for well-known // Do not send requests for Chrome OS managed users, nor for well-known
...@@ -78,11 +78,11 @@ void ArcAndroidManagementChecker::StartCheck(CheckCallback callback) { ...@@ -78,11 +78,11 @@ void ArcAndroidManagementChecker::StartCheck(CheckCallback callback) {
if (policy_util::IsAccountManaged(profile_) || if (policy_util::IsAccountManaged(profile_) ||
policy::BrowserPolicyConnector::IsNonEnterpriseUser( policy::BrowserPolicyConnector::IsNonEnterpriseUser(
profile_->GetProfileUserName())) { profile_->GetProfileUserName())) {
std::move(callback).Run(policy::AndroidManagementClient::Result::UNMANAGED); callback.Run(policy::AndroidManagementClient::Result::UNMANAGED);
return; return;
} }
callback_ = std::move(callback); callback_ = callback;
EnsureRefreshTokenLoaded(); EnsureRefreshTokenLoaded();
} }
......
...@@ -30,8 +30,8 @@ class ArcAndroidManagementChecker : public signin::IdentityManager::Observer { ...@@ -30,8 +30,8 @@ class ArcAndroidManagementChecker : public signin::IdentityManager::Observer {
// If the instance is destructed while it has inflight check, then the // If the instance is destructed while it has inflight check, then the
// check will be cancelled and |callback| will not be called. // check will be cancelled and |callback| will not be called.
using CheckCallback = using CheckCallback =
base::OnceCallback<void(policy::AndroidManagementClient::Result result)>; base::Callback<void(policy::AndroidManagementClient::Result result)>;
void StartCheck(CheckCallback callback); void StartCheck(const CheckCallback& callback);
private: private:
void StartCheckInternal(); void StartCheckInternal();
......
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