OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_BROWSER_CERT_STORE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_CERT_STORE_IMPL_H_ |
6 #define CONTENT_BROWSER_CERT_STORE_IMPL_H_ | 6 #define CONTENT_BROWSER_CERT_STORE_IMPL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
10 #include "content/browser/renderer_data_memoizing_store.h" | 11 #include "content/browser/renderer_data_memoizing_store.h" |
11 #include "content/public/browser/cert_store.h" | 12 #include "content/public/browser/cert_store.h" |
13 #include "net/base/hash_value.h" | |
12 #include "net/cert/x509_certificate.h" | 14 #include "net/cert/x509_certificate.h" |
13 | 15 |
14 namespace content { | 16 namespace content { |
15 | 17 |
16 class CertStoreImpl : public CertStore { | 18 class CertStoreImpl : public CertStore { |
17 public: | 19 public: |
18 // Returns the singleton instance of the CertStore. | 20 // Returns the singleton instance of the CertStore. |
19 static CertStoreImpl* GetInstance(); | 21 static CertStoreImpl* GetInstance(); |
20 | 22 |
21 // CertStore implementation: | 23 // CertStore implementation: |
22 int StoreCert(net::X509Certificate* cert, | 24 int StoreCert(net::X509Certificate* cert, |
23 int render_process_host_id) override; | 25 int render_process_host_id) override; |
24 bool RetrieveCert(int cert_id, | 26 bool RetrieveCert(int cert_id, |
25 scoped_refptr<net::X509Certificate>* cert) override; | 27 scoped_refptr<net::X509Certificate>* cert) override; |
26 | 28 |
27 protected: | 29 protected: |
28 CertStoreImpl(); | 30 CertStoreImpl(); |
29 ~CertStoreImpl() override; | 31 ~CertStoreImpl() override; |
30 | 32 |
31 private: | 33 private: |
32 friend struct base::DefaultSingletonTraits<CertStoreImpl>; | 34 friend struct base::DefaultSingletonTraits<CertStoreImpl>; |
33 | 35 |
34 RendererDataMemoizingStore<net::X509Certificate> store_; | 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 }; | |
jochen (gone - plz use gerrit)
2016/06/16 22:32:16
disallow copy & assign?
| |
57 RendererDataMemoizingStore<HashAndCert> store_; | |
35 | 58 |
36 DISALLOW_COPY_AND_ASSIGN(CertStoreImpl); | 59 DISALLOW_COPY_AND_ASSIGN(CertStoreImpl); |
37 }; | 60 }; |
38 | 61 |
39 } // namespace content | 62 } // namespace content |
40 | 63 |
41 #endif // CONTENT_BROWSER_CERT_STORE_IMPL_H_ | 64 #endif // CONTENT_BROWSER_CERT_STORE_IMPL_H_ |
OLD | NEW |