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