Index: net/cert/cert_verifier_cache_persister.h |
diff --git a/net/cert/cert_verifier_cache_persister.h b/net/cert/cert_verifier_cache_persister.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d578cac4fb2b4c95fd76a4bc714dbc1f8aeb4c5f |
--- /dev/null |
+++ b/net/cert/cert_verifier_cache_persister.h |
@@ -0,0 +1,91 @@ |
+// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// CertVerifierCachePersister maintains an in memory database containing the |
+// list of hosts whose cerificates have been verified. This singleton object |
+// deals with writing that data out to disk as needed and loading it at startup. |
+// |
+// At startup we need to load the certificate verification results from the |
+// disk and we deserialize the data and then pouplate |
+// MultiThreadedCertVerifier's cache. |
+// |
+// At shutdown, we serialize MultiThreadedCertVerifier's cache and then write |
+// that data to disk. |
+ |
+#ifndef NET_CERT_CERT_VERIFIER_CACHE_PERSISTER_H_ |
+#define NET_CERT_CERT_VERIFIER_CACHE_PERSISTER_H_ |
+ |
+#include <string> |
+ |
+#include "base/compiler_specific.h" |
+#include "net/base/net_export.h" |
+#include "net/cert/multi_threaded_cert_verifier.h" |
+ |
+namespace net { |
+ |
+class CertVerificationRequestParams; |
+class CertVerificationCachedResult; |
+class CertVerificationCacheValidityPeriod; |
+ |
+class NET_EXPORT_PRIVATE CertVerifierCachePersister { |
+ public: |
+ CertVerifierCachePersister(MultiThreadedCertVerifier* verifier); |
+ ~CertVerifierCachePersister(); |
+ |
+ // Recursively iterate over this |verifier_|'s |cache_| and all children and |
+ // write the hierarchical structure into |data|. |
+ void SerializeCache(std::string* data); |
+ |
+ // Populates MultiThreadedCertVerifier's |cache_|. Returns true if the |data| |
+ // is deserialized correctly. |
+ bool LoadCache(const std::string& data); |
+ |
+ private: |
+ // 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.
|
+ // RequestParams. |
+ void SerializeRequestParams( |
+ MultiThreadedCertVerifier::CertVerifierCacheIterator& cache_iterator, |
+ CertVerificationRequestParams* proto_request_param); |
+ |
+ // Update |proto_cached_result| with data from |verifier_->cache_|'s |
+ // CachedResult. |
+ void SerializeCachedResult( |
+ MultiThreadedCertVerifier::CertVerifierCacheIterator& cache_iterator, |
+ CertVerificationCachedResult* proto_cached_result); |
+ |
+ // Update |proto_cache_validity_period| with data from |verifier_->cache_|'s |
+ // ValidityPeriod. |
+ void SerializeValidityPeriod( |
+ MultiThreadedCertVerifier::CertVerifierCacheIterator& cache_iterator, |
+ CertVerificationCacheValidityPeriod* proto_cache_validity_period); |
+ |
+ // Updates |request_params| with data from |proto_request_params|. Returns |
+ // true if it is deserialized correctly. |
+ bool DeserializeRequestParams( |
+ const CertVerificationRequestParams& proto_request_params, |
+ MultiThreadedCertVerifier::RequestParams* request_params); |
+ |
+ // Updates |expiration| with data from |proto_cache_validity_period|. Returns |
+ // true if it is deserialized correctly. |
+ bool DeserializeValidityPeriod( |
+ const CertVerificationCacheValidityPeriod& proto_cache_validity_period, |
+ const std::string& hostname, |
+ MultiThreadedCertVerifier::CacheValidityPeriod* expiration); |
+ |
+ // Updates |request_params| with data from |proto_request_params|. Returns |
+ // true if it is deserialized correctly. |
+ bool DeserializeCachedResult( |
+ const CertVerificationCachedResult& proto_cached_result, |
+ const std::string& hostname, |
+ MultiThreadedCertVerifier::CachedResult* cached_result); |
+ |
+ // |verifier_| whose |cache_| will be serialized/deserialized. |
+ MultiThreadedCertVerifier* verifier_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CertVerifierCachePersister); |
+}; |
+ |
+} // namespace net |
+ |
+#endif // NET_CERT_CERT_VERIFIER_CACHE_PERSISTER_H_ |