OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_CERT_STORE_IMPL_H_ | |
6 #define CONTENT_BROWSER_CERT_STORE_IMPL_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/singleton.h" | |
11 #include "content/browser/renderer_data_memoizing_store.h" | |
12 #include "content/public/browser/cert_store.h" | |
13 #include "net/base/hash_value.h" | |
14 #include "net/cert/x509_certificate.h" | |
15 | |
16 namespace content { | |
17 | |
18 class CertStoreImpl : public CertStore { | |
19 public: | |
20 // Returns the singleton instance of the CertStore. | |
21 static CertStoreImpl* GetInstance(); | |
22 | |
23 // CertStore implementation: | |
24 int StoreCert(net::X509Certificate* cert, | |
25 int render_process_host_id) override; | |
26 bool RetrieveCert(int cert_id, | |
27 scoped_refptr<net::X509Certificate>* cert) override; | |
28 | |
29 protected: | |
30 CertStoreImpl(); | |
31 ~CertStoreImpl() override; | |
32 | |
33 private: | |
34 friend struct base::DefaultSingletonTraits<CertStoreImpl>; | |
35 | |
36 // Utility structure that allows memoization to be based on the | |
37 // hash of |cert|'s certificate chain, to avoid needing to compare | |
38 // every certificate individually. This is purely an optimization. | |
39 class HashAndCert : public base::RefCountedThreadSafe<HashAndCert> { | |
40 public: | |
41 HashAndCert(); | |
42 | |
43 // Comparator for RendererDataMemoizingStore. | |
44 struct LessThan { | |
45 bool operator()(const scoped_refptr<HashAndCert>& lhs, | |
46 const scoped_refptr<HashAndCert>& rhs) const; | |
47 }; | |
48 | |
49 net::SHA256HashValue chain_hash; | |
50 scoped_refptr<net::X509Certificate> cert; | |
51 | |
52 private: | |
53 friend class base::RefCountedThreadSafe<HashAndCert>; | |
54 | |
55 ~HashAndCert(); | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(HashAndCert); | |
58 }; | |
59 RendererDataMemoizingStore<HashAndCert> store_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(CertStoreImpl); | |
62 }; | |
63 | |
64 } // namespace content | |
65 | |
66 #endif // CONTENT_BROWSER_CERT_STORE_IMPL_H_ | |
OLD | NEW |