OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 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 // CertVerifierCachePersister maintains an in memory database containing the | |
6 // list of hosts whose cerificates have been verified. This singleton object | |
7 // deals with writing that data out to disk as needed and loading it at startup. | |
8 // | |
9 // At startup we need to load the certificate verification results from the | |
10 // disk and we deserialize the data and then pouplate | |
11 // MultiThreadedCertVerifier's cache. | |
12 // | |
13 // At shutdown, we serialize MultiThreadedCertVerifier's cache and then write | |
14 // that data to disk. | |
15 | |
16 #ifndef NET_CERT_CERT_VERIFIER_CACHE_PERSISTER_H_ | |
17 #define NET_CERT_CERT_VERIFIER_CACHE_PERSISTER_H_ | |
18 | |
19 #include <string> | |
20 | |
21 #include "base/compiler_specific.h" | |
22 #include "net/base/net_export.h" | |
23 #include "net/cert/multi_threaded_cert_verifier.h" | |
24 | |
25 namespace net { | |
26 | |
27 class CertVerificationRequestParams; | |
28 class CertVerificationCachedResult; | |
29 class CertVerificationCacheValidityPeriod; | |
30 | |
31 class NET_EXPORT_PRIVATE CertVerifierCachePersister { | |
32 public: | |
33 CertVerifierCachePersister(MultiThreadedCertVerifier* verifier); | |
34 ~CertVerifierCachePersister(); | |
35 | |
36 // Recursively iterate over this |verifier_|'s |cache_| and all children and | |
37 // write the hierarchical structure into |data|. | |
38 void SerializeCache(std::string* data); | |
39 | |
40 // Populates MultiThreadedCertVerifier's |cache_|. Returns true if the |data| | |
41 // is deserialized correctly. | |
42 bool LoadCache(const std::string& data); | |
43 | |
44 private: | |
45 // Update |proto_request_param| with data from |verifier_->cache_|'s | |
Ryan Sleevi
2016/04/16 00:36:15
Doesn't seem like you need these as private method
ramant (doing other things)
2016/04/21 16:41:54
Done.
| |
46 // RequestParams. | |
47 void SerializeRequestParams( | |
48 MultiThreadedCertVerifier::CertVerifierCacheIterator& cache_iterator, | |
49 CertVerificationRequestParams* proto_request_param); | |
50 | |
51 // Update |proto_cached_result| with data from |verifier_->cache_|'s | |
52 // CachedResult. | |
53 void SerializeCachedResult( | |
54 MultiThreadedCertVerifier::CertVerifierCacheIterator& cache_iterator, | |
55 CertVerificationCachedResult* proto_cached_result); | |
56 | |
57 // Update |proto_cache_validity_period| with data from |verifier_->cache_|'s | |
58 // ValidityPeriod. | |
59 void SerializeValidityPeriod( | |
60 MultiThreadedCertVerifier::CertVerifierCacheIterator& cache_iterator, | |
61 CertVerificationCacheValidityPeriod* proto_cache_validity_period); | |
62 | |
63 // Updates |request_params| with data from |proto_request_params|. Returns | |
64 // true if it is deserialized correctly. | |
65 bool DeserializeRequestParams( | |
66 const CertVerificationRequestParams& proto_request_params, | |
67 MultiThreadedCertVerifier::RequestParams* request_params); | |
68 | |
69 // Updates |expiration| with data from |proto_cache_validity_period|. Returns | |
70 // true if it is deserialized correctly. | |
71 bool DeserializeValidityPeriod( | |
72 const CertVerificationCacheValidityPeriod& proto_cache_validity_period, | |
73 const std::string& hostname, | |
74 MultiThreadedCertVerifier::CacheValidityPeriod* expiration); | |
75 | |
76 // Updates |request_params| with data from |proto_request_params|. Returns | |
77 // true if it is deserialized correctly. | |
78 bool DeserializeCachedResult( | |
79 const CertVerificationCachedResult& proto_cached_result, | |
80 const std::string& hostname, | |
81 MultiThreadedCertVerifier::CachedResult* cached_result); | |
82 | |
83 // |verifier_| whose |cache_| will be serialized/deserialized. | |
84 MultiThreadedCertVerifier* verifier_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(CertVerifierCachePersister); | |
87 }; | |
88 | |
89 } // namespace net | |
90 | |
91 #endif // NET_CERT_CERT_VERIFIER_CACHE_PERSISTER_H_ | |
OLD | NEW |