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