Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: net/base/openssl_private_key_store_memory.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToT Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/message_pump/handle_watcher.cc ('k') | net/cert/cert_database.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Defines an in-memory private key store, primarily used for testing. 5 // Defines an in-memory private key store, primarily used for testing.
6 6
7 #include "net/base/openssl_private_key_store.h" 7 #include "net/base/openssl_private_key_store.h"
8 8
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 namespace { 17 namespace {
18 18
19 // A small in-memory store for public/private key pairs held in 19 // A small in-memory store for public/private key pairs held in
20 // a single EVP_PKEY object. This is intentionally distinct from 20 // a single EVP_PKEY object. This is intentionally distinct from
21 // net::SSLClientKeyStore. 21 // net::SSLClientKeyStore.
22 class MemoryKeyPairStore { 22 class MemoryKeyPairStore {
23 public: 23 public:
24 MemoryKeyPairStore() {} 24 MemoryKeyPairStore() {}
25 25
26 static MemoryKeyPairStore* GetInstance() { 26 static MemoryKeyPairStore* GetInstance() {
27 return Singleton<MemoryKeyPairStore>::get(); 27 return base::Singleton<MemoryKeyPairStore>::get();
28 } 28 }
29 29
30 ~MemoryKeyPairStore() { 30 ~MemoryKeyPairStore() {
31 base::AutoLock lock(lock_); 31 base::AutoLock lock(lock_);
32 for (std::vector<EVP_PKEY*>::iterator it = keys_.begin(); 32 for (std::vector<EVP_PKEY*>::iterator it = keys_.begin();
33 it != keys_.end(); ++it) { 33 it != keys_.end(); ++it) {
34 EVP_PKEY_free(*it); 34 EVP_PKEY_free(*it);
35 } 35 }
36 } 36 }
37 37
(...skipping 27 matching lines...) Expand all
65 EVP_PKEY* pkey) { 65 EVP_PKEY* pkey) {
66 return MemoryKeyPairStore::GetInstance()->StoreKeyPair(pkey); 66 return MemoryKeyPairStore::GetInstance()->StoreKeyPair(pkey);
67 } 67 }
68 68
69 bool OpenSSLPrivateKeyStore::HasPrivateKey(EVP_PKEY* pub_key) { 69 bool OpenSSLPrivateKeyStore::HasPrivateKey(EVP_PKEY* pub_key) {
70 return MemoryKeyPairStore::GetInstance()->HasPrivateKey(pub_key); 70 return MemoryKeyPairStore::GetInstance()->HasPrivateKey(pub_key);
71 } 71 }
72 72
73 } // namespace net 73 } // namespace net
74 74
OLDNEW
« no previous file with comments | « mojo/message_pump/handle_watcher.cc ('k') | net/cert/cert_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698