Commit 1d78c8f2 authored by Reilly Grant's avatar Reilly Grant Committed by Chromium LUCI CQ

Convert callbacks in //chrome/browser/chromeos/arc

This change converts callbacks from base::Bind and base::Callback to
Once/Repeating in //chrome/browser/chromeos/arc.

Code previously using base::AdaptCallbackForRepeating now uses the more
purpose-specific base::SplitOnceCallback.

Bug: 1148570
Change-Id: Ie087afe3f6be92b267f2e36a7785052107344580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644344
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845952}
parent c17e30b6
......@@ -55,8 +55,8 @@ void ArcSnapshotRebootNotificationImpl::Show() {
base::string16() /* display_source */, GURL(), notifier_id,
optional_fields,
new message_center::HandleNotificationClickDelegate(
base::Bind(&ArcSnapshotRebootNotificationImpl::HandleClick,
weak_ptr_factory_.GetWeakPtr())),
base::BindRepeating(&ArcSnapshotRebootNotificationImpl::HandleClick,
weak_ptr_factory_.GetWeakPtr())),
vector_icons::kBusinessIcon,
message_center::SystemNotificationWarningLevel::NORMAL);
SystemNotificationHelper::GetInstance()->Display(*notification);
......
......@@ -351,17 +351,17 @@ class CertStoreServiceTest : public MixinBasedInProcessBrowserTest {
void OnKeyRegisteredForCorporateUsage(
std::unique_ptr<chromeos::platform_keys::ExtensionKeyPermissionsService>
extension_key_permissions_service,
const base::Closure& done_callback,
base::OnceClosure done_callback,
chromeos::platform_keys::Status status) {
ASSERT_EQ(status, chromeos::platform_keys::Status::kSuccess);
done_callback.Run();
std::move(done_callback).Run();
}
// Register only client_cert1_ for corporate usage to test that
// client_cert2_ is not allowed.
void GotPermissionsForExtension(
CERTCertificate* cert,
const base::Closure& done_callback,
base::OnceClosure done_callback,
std::unique_ptr<chromeos::platform_keys::ExtensionKeyPermissionsService>
extension_key_permissions_service) {
auto* extension_key_permissions_service_unowned =
......@@ -374,11 +374,11 @@ class CertStoreServiceTest : public MixinBasedInProcessBrowserTest {
base::BindOnce(&CertStoreServiceTest::OnKeyRegisteredForCorporateUsage,
base::Unretained(this),
std::move(extension_key_permissions_service),
done_callback));
std::move(done_callback)));
}
void SetUpTestClientCerts(const std::vector<std::string>& key_file_names,
const base::Closure& done_callback,
base::OnceClosure done_callback,
net::NSSCertDatabase* cert_db) {
for (const auto& file_name : key_file_names) {
base::ScopedAllowBlockingForTesting allow_io;
......@@ -391,31 +391,31 @@ class CertStoreServiceTest : public MixinBasedInProcessBrowserTest {
net::X509Certificate::FORMAT_AUTO);
EXPECT_EQ(1U, certs.size());
if (certs.size() != 1U) {
done_callback.Run();
std::move(done_callback).Run();
return;
}
client_certs_.emplace_back(
net::x509_util::DupCERTCertificate(certs[0].get()));
}
done_callback.Run();
std::move(done_callback).Run();
}
void ImportTestClientCerts(const base::Closure& done_callback,
void ImportTestClientCerts(base::OnceClosure done_callback,
net::NSSCertDatabase* cert_db) {
for (const auto& cert : client_certs_) {
// Import user certificate properly how it's done in PlatfromKeys.
cert_db->ImportUserCert(cert.get());
}
done_callback.Run();
std::move(done_callback).Run();
}
void DeleteCertAndKey(CERTCertificate* cert,
const base::Closure& done_callback,
base::OnceClosure done_callback,
net::NSSCertDatabase* cert_db) {
base::ScopedAllowBlockingForTesting allow_io;
EXPECT_TRUE(cert_db->DeleteCertAndKey(cert));
done_callback.Run();
std::move(done_callback).Run();
}
std::unique_ptr<policy::UserPolicyTestHelper> policy_helper_;
......
......@@ -91,31 +91,32 @@ void ArcDocumentsProviderFileStreamReader::RunPendingRead(
net::CompletionOnceCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(content_url_resolved_);
// Create |copyable_callback| which is copyable, though it can still only
// called at most once. This is safe, because Read() is guaranteed not to
// call |callback| if it returns synchronously.
auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));
// Create two copies of |callback| though it can still only called at most
// once. This is safe because Read() is guaranteed not to call |callback| if
// it returns synchronously.
auto split_callback = base::SplitOnceCallback(std::move(callback));
int result = underlying_reader_
? underlying_reader_->Read(buffer.get(), buffer_length,
copyable_callback)
std::move(split_callback.first))
: net::ERR_FILE_NOT_FOUND;
if (result != net::ERR_IO_PENDING)
copyable_callback.Run(result);
std::move(split_callback.second).Run(result);
}
void ArcDocumentsProviderFileStreamReader::RunPendingGetLength(
net::Int64CompletionOnceCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(content_url_resolved_);
// Create |copyable_callback| which is copyable, though it can still only
// called at most once. This is safe, because GetLength() is guaranteed not
// to call |callback| if it returns synchronously.
auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));
int64_t result = underlying_reader_
? underlying_reader_->GetLength(copyable_callback)
: net::ERR_FILE_NOT_FOUND;
// Create two copies of |callback| though it can still only called at most
// once. This is safe because GetLength() is guaranteed not to call |callback|
// if it returns synchronously.
auto split_callback = base::SplitOnceCallback(std::move(callback));
int64_t result =
underlying_reader_
? underlying_reader_->GetLength(std::move(split_callback.first))
: net::ERR_FILE_NOT_FOUND;
if (result != net::ERR_IO_PENDING)
copyable_callback.Run(result);
std::move(split_callback.second).Run(result);
}
} // namespace arc
......@@ -110,45 +110,46 @@ void ArcDocumentsProviderFileStreamWriter::RunPendingWrite(
net::CompletionOnceCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(content_url_resolved_);
// Create |copyable_callback| which is copyable, though it can still only
// called at most once. This is safe, because Write() is guaranteed not to
// call |callback| if it returns synchronously.
auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));
// Create two copies of |callback| though it can still only called at most
// once. This is safe because Write() is guaranteed not to call |callback| if
// it returns synchronously.
auto split_callback = base::SplitOnceCallback(std::move(callback));
int result = underlying_writer_
? underlying_writer_->Write(buffer.get(), buffer_length,
copyable_callback)
std::move(split_callback.first))
: net::ERR_FILE_NOT_FOUND;
if (result != net::ERR_IO_PENDING)
copyable_callback.Run(result);
std::move(split_callback.second).Run(result);
}
void ArcDocumentsProviderFileStreamWriter::RunPendingCancel(
net::CompletionOnceCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(content_url_resolved_);
// Create |copyable_callback| which is copyable, though it can still only
// called at most once. This is safe, because Cancel() is guaranteed not to
// call |callback| if it returns synchronously.
auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));
// Create two copies of |callback| though it can still only called at most
// once. This is safe because Cancel() is guaranteed not to call |callback| if
// it returns synchronously.
auto split_callback = base::SplitOnceCallback(std::move(callback));
int result = underlying_writer_
? underlying_writer_->Cancel(copyable_callback)
? underlying_writer_->Cancel(std::move(split_callback.first))
: net::ERR_FILE_NOT_FOUND;
if (result != net::ERR_IO_PENDING)
copyable_callback.Run(result);
std::move(split_callback.second).Run(result);
}
void ArcDocumentsProviderFileStreamWriter::RunPendingFlush(
net::CompletionOnceCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(content_url_resolved_);
// Create |copyable_callback| which is copyable, though it can still only
// called at most once. This is safe, because Flush() is guaranteed not to
// call |callback| if it returns synchronously.
auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));
int result = underlying_writer_ ? underlying_writer_->Flush(copyable_callback)
: net::ERR_FILE_NOT_FOUND;
// Create two copies of |callback| though it can still only called at most
// once. This is safe because Flush() is guaranteed not to call |callback| if
// it returns synchronously.
auto split_callback = base::SplitOnceCallback(std::move(callback));
int result = underlying_writer_
? underlying_writer_->Flush(std::move(split_callback.first))
: net::ERR_FILE_NOT_FOUND;
if (result != net::ERR_IO_PENDING)
copyable_callback.Run(result);
std::move(split_callback.second).Run(result);
}
} // namespace arc
......@@ -173,13 +173,13 @@ void ExpectString(std::unique_ptr<CheckedBoolean> was_run,
was_run->set_value(true);
}
void ExpectStringWithClosure(base::Closure quit_closure,
void ExpectStringWithClosure(base::OnceClosure quit_closure,
std::unique_ptr<CheckedBoolean> was_run,
const std::string& expected,
const std::string& received) {
EXPECT_EQ(expected, received);
was_run->set_value(true);
quit_closure.Run();
std::move(quit_closure).Run();
}
arc::ArcPolicyBridge::GetPoliciesCallback PolicyStringCallback(
......@@ -189,10 +189,10 @@ arc::ArcPolicyBridge::GetPoliciesCallback PolicyStringCallback(
}
arc::ArcPolicyBridge::ReportComplianceCallback PolicyComplianceCallback(
base::Closure quit_closure,
base::OnceClosure quit_closure,
const std::string& expected) {
auto was_run = std::make_unique<CheckedBoolean>();
return base::BindOnce(&ExpectStringWithClosure, quit_closure,
return base::BindOnce(&ExpectStringWithClosure, std::move(quit_closure),
std::move(was_run), expected);
}
......
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