Commit 27477af7 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[base] Apply BindOnceRewriter in //chrome/browser/chromeos/attestation

This change applies the BindOnceRewriter in //chrome/browser/chromeos/attestation.
This rewriter replaces calls to base::Bind and base::BindRepeating with
calls to base::BindOnce, in case the result is immediately assigned to a
base::OnceCallback. Given that base::RepeatingCallback is implicitly
convertible to base::OnceCallback, there is no change in functionality.

Steps:
  1. run_tool.py --tool base_bind_rewriters \
                 --tool-arg='--rewriter=bind_to_bind_once'
  2. git cl format

This CL was uploaded by git cl split.

R=emaxx@chromium.org

Bug: 714018
Change-Id: Iebee9bd19db9cd252dffa538ea34ebb1d169df62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132253
Auto-Submit: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755394}
parent 97aeb037
......@@ -98,8 +98,7 @@ class AttestationCAClientTest : public ::testing::Test {
TEST_F(AttestationCAClientTest, EnrollRequest) {
AttestationCAClient client;
client.SendEnrollRequest(
"enroll",
base::Bind(&AttestationCAClientTest::DataCallback,
"enroll", base::BindOnce(&AttestationCAClientTest::DataCallback,
base::Unretained(this)));
CheckURLAndSendResponse(GURL("https://chromeos-ca.gstatic.com/enroll"),
net::OK, net::HTTP_OK);
......@@ -112,8 +111,7 @@ TEST_F(AttestationCAClientTest, EnrollRequest) {
TEST_F(AttestationCAClientTest, CertificateRequest) {
AttestationCAClient client;
client.SendCertificateRequest(
"certificate",
base::Bind(&AttestationCAClientTest::DataCallback,
"certificate", base::BindOnce(&AttestationCAClientTest::DataCallback,
base::Unretained(this)));
CheckURLAndSendResponse(GURL("https://chromeos-ca.gstatic.com/sign"), net::OK,
net::HTTP_OK);
......@@ -126,8 +124,7 @@ TEST_F(AttestationCAClientTest, CertificateRequest) {
TEST_F(AttestationCAClientTest, CertificateRequestNetworkFailure) {
AttestationCAClient client;
client.SendCertificateRequest(
"certificate",
base::Bind(&AttestationCAClientTest::DataCallback,
"certificate", base::BindOnce(&AttestationCAClientTest::DataCallback,
base::Unretained(this)));
SendResponse(net::ERR_FAILED, net::HTTP_OK);
......@@ -139,8 +136,7 @@ TEST_F(AttestationCAClientTest, CertificateRequestNetworkFailure) {
TEST_F(AttestationCAClientTest, CertificateRequestHttpError) {
AttestationCAClient client;
client.SendCertificateRequest(
"certificate",
base::Bind(&AttestationCAClientTest::DataCallback,
"certificate", base::BindOnce(&AttestationCAClientTest::DataCallback,
base::Unretained(this)));
SendResponse(net::OK, net::HTTP_NOT_FOUND);
......@@ -153,9 +149,8 @@ TEST_F(AttestationCAClientTest, DeleteOnCallback) {
AttestationCAClient* client = new AttestationCAClient();
client->SendCertificateRequest(
"certificate",
base::Bind(&AttestationCAClientTest::DeleteClientDataCallback,
base::Unretained(this),
client));
base::BindOnce(&AttestationCAClientTest::DeleteClientDataCallback,
base::Unretained(this), client));
SendResponse(net::OK, net::HTTP_OK);
EXPECT_EQ(1, num_invocations_);
......@@ -170,8 +165,8 @@ TEST_F(AttestationCAClientAttestationServerTest, DefaultEnrollRequest) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
chromeos::switches::kAttestationServer, "default");
AttestationCAClient client;
client.SendEnrollRequest("enroll",
base::Bind(&AttestationCAClientTest::DataCallback,
client.SendEnrollRequest(
"enroll", base::BindOnce(&AttestationCAClientTest::DataCallback,
base::Unretained(this)));
CheckURLAndSendResponse(GURL("https://chromeos-ca.gstatic.com/enroll"),
net::OK, net::HTTP_OK);
......@@ -186,7 +181,7 @@ TEST_F(AttestationCAClientAttestationServerTest, DefaultCertificateRequest) {
chromeos::switches::kAttestationServer, "default");
AttestationCAClient client;
client.SendCertificateRequest(
"certificate", base::Bind(&AttestationCAClientTest::DataCallback,
"certificate", base::BindOnce(&AttestationCAClientTest::DataCallback,
base::Unretained(this)));
CheckURLAndSendResponse(GURL("https://chromeos-ca.gstatic.com/sign"), net::OK,
net::HTTP_OK);
......@@ -200,8 +195,8 @@ TEST_F(AttestationCAClientAttestationServerTest, TestEnrollRequest) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
chromeos::switches::kAttestationServer, "test");
AttestationCAClient client;
client.SendEnrollRequest("enroll",
base::Bind(&AttestationCAClientTest::DataCallback,
client.SendEnrollRequest(
"enroll", base::BindOnce(&AttestationCAClientTest::DataCallback,
base::Unretained(this)));
CheckURLAndSendResponse(GURL("https://asbestos-qa.corp.google.com/enroll"),
net::OK, net::HTTP_OK);
......@@ -216,7 +211,7 @@ TEST_F(AttestationCAClientAttestationServerTest, TestCertificateRequest) {
chromeos::switches::kAttestationServer, "test");
AttestationCAClient client;
client.SendCertificateRequest(
"certificate", base::Bind(&AttestationCAClientTest::DataCallback,
"certificate", base::BindOnce(&AttestationCAClientTest::DataCallback,
base::Unretained(this)));
CheckURLAndSendResponse(GURL("https://asbestos-qa.corp.google.com/sign"),
net::OK, net::HTTP_OK);
......
......@@ -119,7 +119,7 @@ void EnrollmentCertificateUploaderImpl::GetCertificate() {
std::string(), // Not used.
false, // Do not force a new key to be generated.
std::string(), // Leave key name empty to generate a default name.
base::BindRepeating(
base::BindOnce(
[](const base::RepeatingCallback<void(const std::string&)> on_success,
const base::RepeatingCallback<void(AttestationStatus)> on_failure,
const base::Location& from_here, AttestationStatus status,
......@@ -140,7 +140,7 @@ void EnrollmentCertificateUploaderImpl::UploadCertificate(
const std::string& pem_certificate_chain) {
policy_client_->UploadEnterpriseEnrollmentCertificate(
pem_certificate_chain,
base::BindRepeating(&EnrollmentCertificateUploaderImpl::OnUploadComplete,
base::BindOnce(&EnrollmentCertificateUploaderImpl::OnUploadComplete,
weak_factory_.GetWeakPtr()));
}
......
......@@ -152,8 +152,7 @@ void EnrollmentPolicyObserver::HandleEnrollmentId(
" obtained is empty.";
}
policy_client_->UploadEnterpriseEnrollmentId(
enrollment_id,
base::BindRepeating(&EnrollmentPolicyObserver::OnUploadComplete,
enrollment_id, base::BindOnce(&EnrollmentPolicyObserver::OnUploadComplete,
weak_factory_.GetWeakPtr(), enrollment_id));
}
......
......@@ -204,7 +204,7 @@ void MachineCertificateUploaderImpl::GetNewCertificate() {
std::string(), // Not used.
true, // Force a new key to be generated.
std::string(), // Leave key name empty to generate a default name.
base::BindRepeating(
base::BindOnce(
[](const base::RepeatingCallback<void(const std::string&)> on_success,
const base::RepeatingCallback<void(AttestationStatus)> on_failure,
const base::Location& from_here, AttestationStatus status,
......@@ -226,7 +226,7 @@ void MachineCertificateUploaderImpl::GetExistingCertificate() {
KEY_DEVICE,
cryptohome::AccountIdentifier(), // Not used.
kEnterpriseMachineKey,
base::BindRepeating(
base::BindOnce(
DBusStringCallback,
base::BindRepeating(
&MachineCertificateUploaderImpl::CheckCertificateExpiry,
......@@ -279,7 +279,7 @@ void MachineCertificateUploaderImpl::UploadCertificate(
const std::string& pem_certificate_chain) {
policy_client_->UploadEnterpriseMachineCertificate(
pem_certificate_chain,
base::BindRepeating(&MachineCertificateUploaderImpl::OnUploadComplete,
base::BindOnce(&MachineCertificateUploaderImpl::OnUploadComplete,
weak_factory_.GetWeakPtr()));
}
......@@ -302,7 +302,7 @@ void MachineCertificateUploaderImpl::GetKeyPayload(
KEY_DEVICE,
cryptohome::AccountIdentifier(), // Not used.
kEnterpriseMachineKey,
base::BindRepeating(DBusStringCallback, callback, on_failure, FROM_HERE));
base::BindOnce(DBusStringCallback, callback, on_failure, FROM_HERE));
}
void MachineCertificateUploaderImpl::OnUploadComplete(bool status) {
......@@ -331,7 +331,7 @@ void MachineCertificateUploaderImpl::MarkAsUploaded(
KEY_DEVICE,
cryptohome::AccountIdentifier(), // Not used.
kEnterpriseMachineKey, new_payload,
base::BindRepeating(DBusBoolRedirectCallback, base::RepeatingClosure(),
base::BindOnce(DBusBoolRedirectCallback, base::RepeatingClosure(),
base::RepeatingClosure(), base::RepeatingClosure(),
FROM_HERE));
}
......@@ -346,9 +346,8 @@ void MachineCertificateUploaderImpl::HandleGetCertificateFailure(
void MachineCertificateUploaderImpl::Reschedule() {
if (++num_retries_ < retry_limit_) {
base::PostDelayedTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindRepeating(&MachineCertificateUploaderImpl::Start,
base::PostDelayedTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&MachineCertificateUploaderImpl::Start,
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(retry_delay_));
} else {
......
......@@ -300,9 +300,8 @@ void TpmChallengeKeySubtleImpl::GetDeviceAttestationEnabled(
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CrosSettings* settings = CrosSettings::Get();
CrosSettingsProvider::TrustedStatus status =
settings->PrepareTrustedValues(base::BindRepeating(
&TpmChallengeKeySubtleImpl::GetDeviceAttestationEnabled,
CrosSettingsProvider::TrustedStatus status = settings->PrepareTrustedValues(
base::BindOnce(&TpmChallengeKeySubtleImpl::GetDeviceAttestationEnabled,
weak_factory_.GetWeakPtr(), callback));
bool value = false;
......@@ -369,7 +368,7 @@ void TpmChallengeKeySubtleImpl::IsAttestationPreparedCallback(
std::string(), // Not used.
true, // Force a new key to be generated.
key_name_for_spkac_,
base::BindRepeating(&TpmChallengeKeySubtleImpl::GetCertificateCallback,
base::BindOnce(&TpmChallengeKeySubtleImpl::GetCertificateCallback,
weak_factory_.GetWeakPtr()));
return;
}
......@@ -379,7 +378,7 @@ void TpmChallengeKeySubtleImpl::IsAttestationPreparedCallback(
key_type_,
cryptohome::CreateAccountIdentifierFromAccountId(GetAccountId()),
key_name_,
base::BindRepeating(&TpmChallengeKeySubtleImpl::DoesKeyExistCallback,
base::BindOnce(&TpmChallengeKeySubtleImpl::DoesKeyExistCallback,
weak_factory_.GetWeakPtr()));
}
......@@ -453,7 +452,7 @@ void TpmChallengeKeySubtleImpl::AskForUserConsentCallback(bool result) {
std::string(), // Not used.
true, // Force a new key to be generated.
key_name_,
base::BindRepeating(&TpmChallengeKeySubtleImpl::GetCertificateCallback,
base::BindOnce(&TpmChallengeKeySubtleImpl::GetCertificateCallback,
weak_factory_.GetWeakPtr()));
}
......@@ -513,7 +512,7 @@ void TpmChallengeKeySubtleImpl::StartSignChallengeStep(
include_signed_public_key ? CHALLENGE_INCLUDE_SIGNED_PUBLIC_KEY
: CHALLENGE_OPTION_NONE,
challenge, key_name_for_spkac_,
base::BindRepeating(&TpmChallengeKeySubtleImpl::SignChallengeCallback,
base::BindOnce(&TpmChallengeKeySubtleImpl::SignChallengeCallback,
weak_factory_.GetWeakPtr()));
}
......@@ -541,7 +540,7 @@ void TpmChallengeKeySubtleImpl::StartRegisterKeyStep(
cryptohome::AsyncMethodCaller::GetInstance()->TpmAttestationRegisterKey(
key_type_, cryptohome::Identification(GetAccountId()),
GetKeyNameForRegister(),
base::BindRepeating(&TpmChallengeKeySubtleImpl::RegisterKeyCallback,
base::BindOnce(&TpmChallengeKeySubtleImpl::RegisterKeyCallback,
weak_factory_.GetWeakPtr()));
}
......
......@@ -243,8 +243,9 @@ class TpmChallengeKeyTestBase : public BrowserWithTestWindowTest {
base::RunLoop loop;
challenge_key_impl_->BuildResponse(
key_type_, GetProfile(), base::Bind(callback, loop.QuitClosure(), res),
challenge, register_key, key_name_for_spkac);
key_type_, GetProfile(),
base::BindOnce(callback, loop.QuitClosure(), res), challenge,
register_key, key_name_for_spkac);
loop.Run();
}
......
......@@ -28,7 +28,7 @@ void TpmChallengeKeyWithTimeout::BuildResponse(
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&TpmChallengeKeyWithTimeout::ResolveCallback,
base::BindOnce(&TpmChallengeKeyWithTimeout::ResolveCallback,
weak_factory_.GetWeakPtr(),
TpmChallengeKeyResult::MakeError(
TpmChallengeKeyResultCode::kTimeoutError)),
......
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