Commit a0282608 authored by Tomasz Tylenda's avatar Tomasz Tylenda Committed by Commit Bot

Migrate base::Callback to base::OnceCallback.

BUG=764795
TEST=build

Change-Id: I8afa2fd87eb5cf5d9a8f7ecde9fad95d420c5399
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2434405Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Tomasz Tylenda <ttylenda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811980}
parent b5e2856c
...@@ -37,13 +37,13 @@ ArcAuthContext::~ArcAuthContext() { ...@@ -37,13 +37,13 @@ ArcAuthContext::~ArcAuthContext() {
identity_manager_->RemoveObserver(this); identity_manager_->RemoveObserver(this);
} }
void ArcAuthContext::Prepare(const PrepareCallback& callback) { void ArcAuthContext::Prepare(PrepareCallback callback) {
if (context_prepared_) { if (context_prepared_) {
callback.Run(true); std::move(callback).Run(true);
return; return;
} }
callback_ = callback; callback_ = std::move(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::Callback<void(bool success)>; using PrepareCallback = base::OnceCallback<void(bool success)>;
void Prepare(const PrepareCallback& callback); void Prepare(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,21 +2247,23 @@ void ArcBluetoothBridge::EnableAdvertisementImpl( ...@@ -2247,21 +2247,23 @@ 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::Callback<void(BluetoothAdvertisement::ErrorCode)> error_callback = base::OnceCallback<void(BluetoothAdvertisement::ErrorCode)> error_callback =
base::Bind(&ArcBluetoothBridge::OnRegisterAdvertisementError, base::BindOnce(&ArcBluetoothBridge::OnRegisterAdvertisementError,
weak_factory_.GetWeakPtr(), repeating_callback, adv_handle); weak_factory_.GetWeakPtr(), repeating_callback,
adv_handle);
auto it = advertisements_.find(adv_handle); auto it = advertisements_.find(adv_handle);
if (it == advertisements_.end()) { if (it == advertisements_.end()) {
error_callback.Run( std::move(error_callback)
BluetoothAdvertisement::ErrorCode::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); .Run(BluetoothAdvertisement::ErrorCode::
ERROR_ADVERTISEMENT_DOES_NOT_EXIST);
return; return;
} }
if (it->second == nullptr) { if (it->second == nullptr) {
done_callback.Run(); std::move(done_callback).Run();
return; return;
} }
it->second->Unregister(done_callback, error_callback); it->second->Unregister(done_callback, std::move(error_callback));
} }
void ArcBluetoothBridge::DisableAdvertisement( void ArcBluetoothBridge::DisableAdvertisement(
...@@ -2284,21 +2286,23 @@ void ArcBluetoothBridge::DisableAdvertisementImpl( ...@@ -2284,21 +2286,23 @@ 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::Callback<void(BluetoothAdvertisement::ErrorCode)> error_callback = base::OnceCallback<void(BluetoothAdvertisement::ErrorCode)> error_callback =
base::Bind(&ArcBluetoothBridge::OnUnregisterAdvertisementError, base::BindOnce(&ArcBluetoothBridge::OnUnregisterAdvertisementError,
weak_factory_.GetWeakPtr(), repeating_callback, adv_handle); weak_factory_.GetWeakPtr(), repeating_callback,
adv_handle);
auto it = advertisements_.find(adv_handle); auto it = advertisements_.find(adv_handle);
if (it == advertisements_.end()) { if (it == advertisements_.end()) {
error_callback.Run( std::move(error_callback)
BluetoothAdvertisement::ErrorCode::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); .Run(BluetoothAdvertisement::ErrorCode::
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, error_callback); it->second->Unregister(done_callback, std::move(error_callback));
} }
void ArcBluetoothBridge::ReleaseAdvertisementHandle( void ArcBluetoothBridge::ReleaseAdvertisementHandle(
......
...@@ -174,9 +174,10 @@ class ArcFileSystemWatcherServiceFactory ...@@ -174,9 +174,10 @@ class ArcFileSystemWatcherServiceFactory
// directory. // directory.
class ArcFileSystemWatcherService::FileSystemWatcher { class ArcFileSystemWatcherService::FileSystemWatcher {
public: public:
using Callback = base::Callback<void(const std::vector<std::string>& paths)>; using Callback =
base::OnceCallback<void(const std::vector<std::string>& paths)>;
FileSystemWatcher(const Callback& callback, FileSystemWatcher(Callback callback,
const base::FilePath& cros_dir, const base::FilePath& cros_dir,
const base::FilePath& android_dir); const base::FilePath& android_dir);
~FileSystemWatcher(); ~FileSystemWatcher();
...@@ -219,10 +220,10 @@ class ArcFileSystemWatcherService::FileSystemWatcher { ...@@ -219,10 +220,10 @@ class ArcFileSystemWatcherService::FileSystemWatcher {
}; };
ArcFileSystemWatcherService::FileSystemWatcher::FileSystemWatcher( ArcFileSystemWatcherService::FileSystemWatcher::FileSystemWatcher(
const Callback& callback, Callback callback,
const base::FilePath& cros_dir, const base::FilePath& cros_dir,
const base::FilePath& android_dir) const base::FilePath& android_dir)
: callback_(callback), : callback_(std::move(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()),
...@@ -295,7 +296,7 @@ void ArcFileSystemWatcherService::FileSystemWatcher::OnBuildTimestampMap( ...@@ -295,7 +296,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(callback_, std::move(string_paths))); FROM_HERE, base::BindOnce(std::move(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(
const NegotiationCallback& callback) { NegotiationCallback callback) {
DCHECK(pending_callback_.is_null()); DCHECK(pending_callback_.is_null());
pending_callback_ = callback; pending_callback_ = std::move(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::Callback<void(bool accepted)>; using NegotiationCallback = base::OnceCallback<void(bool accepted)>;
void StartNegotiation(const NegotiationCallback& callback); void StartNegotiation(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(const CheckCallback& callback) { void ArcAndroidManagementChecker::StartCheck(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(const CheckCallback& callback) { ...@@ -78,11 +78,11 @@ void ArcAndroidManagementChecker::StartCheck(const CheckCallback& callback) {
if (policy_util::IsAccountManaged(profile_) || if (policy_util::IsAccountManaged(profile_) ||
policy::BrowserPolicyConnector::IsNonEnterpriseUser( policy::BrowserPolicyConnector::IsNonEnterpriseUser(
profile_->GetProfileUserName())) { profile_->GetProfileUserName())) {
callback.Run(policy::AndroidManagementClient::Result::UNMANAGED); std::move(callback).Run(policy::AndroidManagementClient::Result::UNMANAGED);
return; return;
} }
callback_ = callback; callback_ = std::move(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::Callback<void(policy::AndroidManagementClient::Result result)>; base::OnceCallback<void(policy::AndroidManagementClient::Result result)>;
void StartCheck(const CheckCallback& callback); void StartCheck(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