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

Side by Side Diff: net/base/multi_threaded_cert_verifier.h

Issue 9584041: Create stubs for system certificate validation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Exclude CertVerifyProcNSS for non-NSS-only systems, for now Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
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 NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_ 5 #ifndef NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_
6 #define NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_ 6 #define NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
16 #include "net/base/cert_database.h" 17 #include "net/base/cert_database.h"
17 #include "net/base/cert_verifier.h" 18 #include "net/base/cert_verifier.h"
18 #include "net/base/cert_verify_result.h" 19 #include "net/base/cert_verify_result.h"
19 #include "net/base/completion_callback.h" 20 #include "net/base/completion_callback.h"
20 #include "net/base/expiring_cache.h" 21 #include "net/base/expiring_cache.h"
21 #include "net/base/net_export.h" 22 #include "net/base/net_export.h"
22 #include "net/base/x509_cert_types.h" 23 #include "net/base/x509_cert_types.h"
23 24
24 namespace net { 25 namespace net {
25 26
26 // MultiThreadedCertVerifier is a CertVerifier implementation that runs 27 // MultiThreadedCertVerifier is a CertVerifier implementation that runs
27 // synchronous CertVerifier implementations on worker threads. 28 // synchronous CertVerifier implementations on worker threads.
28 class NET_EXPORT MultiThreadedCertVerifier : 29 class MultiThreadedCertVerifier :
29 public CertVerifier, 30 public CertVerifier,
30 NON_EXPORTED_BASE(public base::NonThreadSafe), 31 NON_EXPORTED_BASE(public base::NonThreadSafe),
wtc 2012/03/06 23:10:14 Maybe NON_EXPORTED_BASE can be removed now?
Ryan Sleevi 2012/03/10 03:09:12 The removal of NET_EXPORT was a mistake. It should
31 public CertDatabase::Observer { 32 public CertDatabase::Observer {
32 public: 33 public:
33 MultiThreadedCertVerifier(); 34 // Class to perform the actual certificate validation on a worker thread.
35 // This class MUST be thread-safe, as it will be called concurrently on
36 // multiple worker threads.
37 // Note: Because these worker threads run within a worker pool, VerifyProc
38 // implementations must be careful about using other objects, such as
39 // MessageLoops, Singletons, etc, as these objects may no longer exist
40 // during shutdown.
41 class VerifyProc : public base::RefCountedThreadSafe<VerifyProc> {
wtc 2012/03/06 23:10:14 Why does VerifyProc need to be a class? Isn't it
Ryan Sleevi 2012/03/10 03:09:12 Using function pointers outside of PPAPI and unitt
42 public:
43 // Performs a synchronous verification of |cert| for the specified
44 // |hostname|.
45 // The arguments mirror those of CertVerifier::Verify().
46 // Note: Multiple calls to Verify() may be running in parallel, so
47 // any state inside of |this| should not mutate.
48 virtual int Verify(X509Certificate* cert,
49 const std::string& hostname,
50 int flags,
51 CRLSet* crl_set,
52 CertVerifyResult* verify_result) = 0;
53
54 protected:
55 friend class base::RefCountedThreadSafe<VerifyProc>;
56
57 virtual ~VerifyProc() {}
58 };
59
60 explicit MultiThreadedCertVerifier(VerifyProc* verifier);
34 61
35 // When the verifier is destroyed, all certificate verifications requests are 62 // When the verifier is destroyed, all certificate verifications requests are
36 // canceled, and their completion callbacks will not be called. 63 // canceled, and their completion callbacks will not be called.
37 virtual ~MultiThreadedCertVerifier(); 64 virtual ~MultiThreadedCertVerifier();
38 65
39 // CertVerifier implementation 66 // CertVerifier implementation
40 virtual int Verify(X509Certificate* cert, 67 virtual int Verify(X509Certificate* cert,
41 const std::string& hostname, 68 const std::string& hostname,
42 int flags, 69 int flags,
43 CRLSet* crl_set, 70 CRLSet* crl_set,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 uint64 inflight_joins() const { return inflight_joins_; } 146 uint64 inflight_joins() const { return inflight_joins_; }
120 147
121 // cache_ maps from a request to a cached result. 148 // cache_ maps from a request to a cached result.
122 typedef ExpiringCache<RequestParams, CachedResult> CertVerifierCache; 149 typedef ExpiringCache<RequestParams, CachedResult> CertVerifierCache;
123 CertVerifierCache cache_; 150 CertVerifierCache cache_;
124 151
125 // inflight_ maps from a request to an active verification which is taking 152 // inflight_ maps from a request to an active verification which is taking
126 // place. 153 // place.
127 std::map<RequestParams, CertVerifierJob*> inflight_; 154 std::map<RequestParams, CertVerifierJob*> inflight_;
128 155
156 scoped_refptr<VerifyProc> verifier_;
wtc 2012/03/06 23:10:14 Please name this member verify_proc_. verifier_ s
157
129 uint64 requests_; 158 uint64 requests_;
130 uint64 cache_hits_; 159 uint64 cache_hits_;
131 uint64 inflight_joins_; 160 uint64 inflight_joins_;
132 161
133 DISALLOW_COPY_AND_ASSIGN(MultiThreadedCertVerifier); 162 DISALLOW_COPY_AND_ASSIGN(MultiThreadedCertVerifier);
134 }; 163 };
135 164
136 } // namespace net 165 } // namespace net
137 166
138 #endif // NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_ 167 #endif // NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698