Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: ios/web/net/cert_verification_cache.h

Issue 1357773002: WKWebView: Implemented recoverable SSL interstitials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lock_coloring
Patch Set: Merged with parent CL Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_VERIFICATION_CACHE_H_
6 #define IOS_WEB_NET_CERT_VERIFICATION_CACHE_H_
7
8 #include <map>
9 #include <string>
10
11 #include "net/cert/x509_certificate.h"
12
13 namespace web {
14
15 // Allows caching cert verification data. Key is cert-host pair, value is
16 // a template param.
17 template <typename ValueType>
stuartmorgan 2015/09/23 17:36:09 Why templated? The actual code only stores one val
Eugene But (OOO till 7-30) 2015/09/23 20:40:47 Because ValueType (CertStatus, is_recoverable flag
18 class CertVerificationCache {
19 public:
20 CertVerificationCache() {}
21 ~CertVerificationCache() {}
22
23 // Retrieves |value| for the given cert-host pair. |cert| cannot be null.
24 // Returns true on success.
25 bool get(const scoped_refptr<net::X509Certificate>& cert,
26 const std::string& host,
27 ValueType* value) const {
28 auto it = map_.find(KeyType(cert, host));
29 if (it == map_.end())
30 return false;
31
32 *value = it->second;
33 return true;
34 }
35
36 // Adds |value| for the given cert-host pair. |cert| cannot be null.
37 void set(const scoped_refptr<net::X509Certificate>& cert,
38 const std::string& host,
39 const ValueType& value) {
40 DCHECK(cert);
41 map_[KeyType(cert, host)] = value;
42 }
43
44 // Clears the cache.
45 void reset() { map_.clear(); }
46
47 private:
48 // Holds cert-host pair and provides less-than comparator.
49 struct KeyType {
50 KeyType(const scoped_refptr<net::X509Certificate>& cert,
51 const std::string& host)
52 : cert(cert), host(host) {}
53
54 bool operator<(const KeyType& other) const {
55 if (host == other.host)
56 return cert_comparator(cert, other.cert);
57 return host < other.host;
58 }
59
60 scoped_refptr<net::X509Certificate> cert;
61 std::string host;
62
63 private:
64 net::X509Certificate::LessThan cert_comparator;
65 };
66
67 std::map<KeyType, ValueType> map_;
68 };
69
70 } // namespace web
71
72 #endif // IOS_WEB_NET_CERT_VERIFICATION_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698