Chromium Code Reviews| Index: chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc |
| diff --git a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc |
| index 29b91ffb7be7255fee5d61f82100c73c5a2433b0..bbaa1120bbea9b77b01f320bc9c55e9a16e595ac 100644 |
| --- a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc |
| +++ b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc |
| @@ -65,19 +65,14 @@ bool IsOwnerInTests(const std::string& user_id) { |
| return static_cast<const base::Value*>(value)->GetString() == user_id; |
| } |
| -void LoadPrivateKeyByPublicKey( |
| +void LoadPrivateKeyByPublicKeyOnWorkerThread( |
| const scoped_refptr<OwnerKeyUtil>& owner_key_util, |
| scoped_refptr<PublicKey> public_key, |
| - const std::string& username_hash, |
| + crypto::ScopedPK11Slot public_slot, |
| + crypto::ScopedPK11Slot private_slot, |
| const base::Callback<void(const scoped_refptr<PublicKey>& public_key, |
| const scoped_refptr<PrivateKey>& private_key)>& |
| callback) { |
|
Daniel Erat
2017/03/22 14:47:18
can you DCHECK that this is running on the right t
Shuhei Takahashi
2017/03/23 05:04:11
Done.
|
| - crypto::EnsureNSSInit(); |
| - crypto::ScopedPK11Slot public_slot = |
| - crypto::GetPublicSlotForChromeOSUser(username_hash); |
| - crypto::ScopedPK11Slot private_slot = crypto::GetPrivateSlotForChromeOSUser( |
| - username_hash, base::Callback<void(crypto::ScopedPK11Slot)>()); |
| - |
| // If private slot is already available, this will check it. If not, we'll get |
| // called again later when the TPM Token is ready, and the slot will be |
| // available then. FindPrivateKeyInSlot internally checks for a null slot if |
| @@ -98,6 +93,32 @@ void LoadPrivateKeyByPublicKey( |
| base::Bind(callback, public_key, private_key)); |
| } |
| +void LoadPrivateKeyByPublicKey( |
| + const scoped_refptr<OwnerKeyUtil>& owner_key_util, |
| + scoped_refptr<PublicKey> public_key, |
| + const std::string& username_hash, |
| + const base::Callback<void(const scoped_refptr<PublicKey>& public_key, |
| + const scoped_refptr<PrivateKey>& private_key)>& |
| + callback) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + |
| + crypto::EnsureNSSInit(); |
| + crypto::ScopedPK11Slot public_slot = |
| + crypto::GetPublicSlotForChromeOSUser(username_hash); |
| + crypto::ScopedPK11Slot private_slot = crypto::GetPrivateSlotForChromeOSUser( |
| + username_hash, base::Callback<void(crypto::ScopedPK11Slot)>()); |
| + |
| + // This task interacts with the TPM, so use the blocking pool. |
| + scoped_refptr<base::TaskRunner> task_runner = |
| + BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
| + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| + task_runner->PostTask( |
| + FROM_HERE, |
| + base::Bind(&LoadPrivateKeyByPublicKeyOnWorkerThread, owner_key_util, |
| + public_key, base::Passed(std::move(public_slot)), |
| + base::Passed(std::move(private_slot)), callback)); |
| +} |
| + |
| void LoadPrivateKey( |
| const scoped_refptr<OwnerKeyUtil>& owner_key_util, |
| const std::string username_hash, |