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