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

Convert callbacks in //chrome/browser/chromeos/platform_keys

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

Bug: 1148570
Change-Id: I05f66512de80ac0fd0ac21cd941a408e17190fd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644074
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Omar Morsi <omorsi@google.com>
Reviewed-by: default avatarOmar Morsi <omorsi@google.com>
Cr-Commit-Position: refs/heads/master@{#846134}
parent e5553504
......@@ -47,7 +47,7 @@ class ExtensionPlatformKeysService : public KeyedService {
// can happen by exposing UI to let the user select.
class SelectDelegate {
public:
using CertificateSelectedCallback = base::Callback<void(
using CertificateSelectedCallback = base::OnceCallback<void(
const scoped_refptr<net::X509Certificate>& selection)>;
SelectDelegate();
......@@ -94,8 +94,8 @@ class ExtensionPlatformKeysService : public KeyedService {
// DER encoding of the SubjectPublicKeyInfo of the generated key. If it
// failed, |public_key_spki_der| will be empty.
using GenerateKeyCallback =
base::Callback<void(const std::string& public_key_spki_der,
platform_keys::Status status)>;
base::OnceCallback<void(const std::string& public_key_spki_der,
platform_keys::Status status)>;
// Generates an RSA key pair with |modulus_length_bits| and registers the key
// to allow a single sign operation by the given extension. |token_id|
......@@ -106,7 +106,7 @@ class ExtensionPlatformKeysService : public KeyedService {
void GenerateRSAKey(platform_keys::TokenId token_id,
unsigned int modulus_length_bits,
const std::string& extension_id,
const GenerateKeyCallback& callback);
GenerateKeyCallback callback);
// Generates an EC key pair with |named_curve| and registers the key to allow
// a single sign operation by the given extension. |token_id| specifies the
......@@ -117,7 +117,7 @@ class ExtensionPlatformKeysService : public KeyedService {
void GenerateECKey(platform_keys::TokenId token_id,
const std::string& named_curve,
const std::string& extension_id,
const GenerateKeyCallback& callback);
GenerateKeyCallback callback);
// Gets the current profile using the BrowserContext object and returns
// whether the current profile is a sign in profile with
......@@ -171,8 +171,8 @@ class ExtensionPlatformKeysService : public KeyedService {
// contain the list of matching certificates (maybe empty). If an error
// occurred, |matches| will be null.
using SelectCertificatesCallback =
base::Callback<void(std::unique_ptr<net::CertificateList> matches,
platform_keys::Status status)>;
base::OnceCallback<void(std::unique_ptr<net::CertificateList> matches,
platform_keys::Status status)>;
// Returns a list of certificates matching |request|.
// 1) all certificates that match the request (like being rooted in one of the
......@@ -193,7 +193,7 @@ class ExtensionPlatformKeysService : public KeyedService {
std::unique_ptr<net::CertificateList> client_certificates,
bool interactive,
const std::string& extension_id,
const SelectCertificatesCallback& callback,
SelectCertificatesCallback callback,
content::WebContents* web_contents);
private:
......
......@@ -105,8 +105,7 @@ std::string StatusToString(Status status) {
void IntersectCertificates(
const net::CertificateList& certs1,
const net::CertificateList& certs2,
const base::Callback<void(std::unique_ptr<net::CertificateList>)>&
callback) {
base::OnceCallback<void(std::unique_ptr<net::CertificateList>)> callback) {
std::unique_ptr<net::CertificateList> intersection(new net::CertificateList);
net::CertificateList* const intersection_ptr = intersection.get();
......@@ -119,7 +118,7 @@ void IntersectCertificates(
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&IntersectOnWorkerThread, certs1, certs2,
intersection_ptr),
base::BindOnce(callback, base::Passed(&intersection)));
base::BindOnce(std::move(callback), std::move(intersection)));
}
GetPublicKeyAndAlgorithmOutput::GetPublicKeyAndAlgorithmOutput() = default;
......
......@@ -78,8 +78,7 @@ std::string GetSubjectPublicKeyInfo(
void IntersectCertificates(
const net::CertificateList& certs1,
const net::CertificateList& certs2,
const base::Callback<void(std::unique_ptr<net::CertificateList>)>&
callback);
base::OnceCallback<void(std::unique_ptr<net::CertificateList>)> callback);
// The output for GetPublicKeyAndAlgorithm.
struct GetPublicKeyAndAlgorithmOutput {
......
......@@ -235,10 +235,9 @@ class PlatformKeysServiceBrowserTestBase
}
private:
void SetUserSlot(const base::Closure& done_callback,
net::NSSCertDatabase* db) {
void SetUserSlot(base::OnceClosure done_callback, net::NSSCertDatabase* db) {
user_slot_ = db->GetPrivateSlot();
done_callback.Run();
std::move(done_callback).Run();
}
const AccountId test_user_account_id_ = AccountId::FromUserEmailGaiaId(
......
......@@ -51,7 +51,7 @@ void GetCertDatabaseOnIoThread(
base::RepeatingCallback<void(net::NSSCertDatabase*)> on_got_on_io_thread =
base::BindRepeating(&DidGetCertDbOnIoThread, origin_task_runner,
base::AdaptCallbackForRepeating(std::move(callback)));
base::Passed(&callback));
net::NSSCertDatabase* cert_db =
GetNSSCertDatabaseForResourceContext(context, on_got_on_io_thread);
......
......@@ -1873,7 +1873,7 @@ void PlatformKeysServiceImpl::GetTokens(GetTokensCallback callback) {
// Get the pointer to |state| before base::Passed releases |state|.
NSSOperationState* state_ptr = state.get();
GetCertDatabase(/*token_id=*/base::nullopt /* don't get any specific slot */,
base::Bind(&GetTokensWithDB, base::Passed(&state)),
base::BindOnce(&GetTokensWithDB, std::move(state)),
delegate_.get(), state_ptr);
}
......@@ -1891,7 +1891,7 @@ void PlatformKeysServiceImpl::GetKeyLocations(
GetCertDatabase(
/*token_id=*/base::nullopt /* don't get any specific slot */,
base::BindRepeating(&GetKeyLocationsWithDB, base::Passed(&state)),
base::BindOnce(&GetKeyLocationsWithDB, base::Passed(&state)),
delegate_.get(), state_ptr);
}
......
......@@ -38,11 +38,11 @@ class ExecutionWaiter {
// Returns the callback to be passed to the PlatformKeysService operation
// invocation.
base::RepeatingCallback<void(ResultCallbackArgs... result_callback_args,
Status status)>
base::OnceCallback<void(ResultCallbackArgs... result_callback_args,
Status status)>
GetCallback() {
return base::BindRepeating(&ExecutionWaiter::OnExecutionDone,
weak_ptr_factory_.GetWeakPtr());
return base::BindOnce(&ExecutionWaiter::OnExecutionDone,
weak_ptr_factory_.GetWeakPtr());
}
// Waits until the callback returned by GetCallback() has been called.
......
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