Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/ssl/client_key_store.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 | |
| 9 #include "base/memory/singleton.h" | |
| 10 #include "net/cert/x509_certificate.h" | |
| 11 #include "net/ssl/ssl_private_key.h" | |
| 12 | |
| 13 namespace net { | |
| 14 | |
| 15 ClientKeyStore::ClientKeyStore() {} | |
| 16 | |
| 17 ClientKeyStore::~ClientKeyStore() {} | |
| 18 | |
| 19 // static | |
| 20 ClientKeyStore* ClientKeyStore::GetInstance() { | |
| 21 return Singleton<ClientKeyStore, LeakySingletonTraits<ClientKeyStore>>::get(); | |
| 22 } | |
| 23 | |
| 24 void ClientKeyStore::AddProvider(scoped_ptr<CertKeyProvider> provider) { | |
| 25 base::AutoLock auto_lock(lock_); | |
| 26 providers_.push_back(provider.Pass()); | |
| 27 } | |
| 28 | |
| 29 void ClientKeyStore::RemoveProvider(const CertKeyProvider* provider) { | |
| 30 base::AutoLock auto_lock(lock_); | |
| 31 | |
| 32 const auto& it = std::find(providers_.begin(), providers_.end(), provider); | |
| 33 if (it != providers_.end()) | |
| 34 providers_.erase(it); | |
| 35 } | |
| 36 | |
| 37 scoped_ptr<SSLPrivateKey> ClientKeyStore::FetchClientCertPrivateKey( | |
| 38 const X509Certificate& certificate) { | |
| 39 base::AutoLock auto_lock(lock_); | |
| 40 | |
| 41 for (const auto& provider : providers_) { | |
| 42 scoped_ptr<SSLPrivateKey> key; | |
| 43 if (provider->GetCertificateKey(certificate, &key)) | |
|
davidben
2015/08/14 22:16:48
Calling a virtual function inside a lock makes me
pneubeck (no reviews)
2015/08/17 14:34:19
I'm not sure what you're nervous about. Is it beca
| |
| 44 return key.Pass(); | |
| 45 } | |
| 46 return nullptr; | |
| 47 } | |
| 48 | |
| 49 } // namespace net | |
| OLD | NEW |