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

Side by Side Diff: net/cert/internal/cert_issuer_source.h

Issue 2030693002: Add CertIssuerSource interface and CertIssuerSourceStatic implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert-parsing-base
Patch Set: update and re-run net/data/update_net_gypi.py Created 4 years, 6 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
« no previous file with comments | « no previous file | net/cert/internal/cert_issuer_source_static.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 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 #ifndef NET_CERT_INTERNAL_CERT_ISSUER_SOURCE_H_
6 #define NET_CERT_INTERNAL_CERT_ISSUER_SOURCE_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "net/base/net_export.h"
13 #include "net/cert/internal/completion_status.h"
14
15 namespace net {
16
17 class ParsedCertificate;
18
19 // Interface for looking up issuers of a certificate during path building.
20 // Provides a synchronous and asynchronous method for retrieving issuers, so the
21 // path builder can try to complete synchronously first. The caller is expected
22 // to call SyncGetIssuersOf first, see if it can make progress with those
23 // results, and if not, then fall back to calling AsyncGetIssuersOf.
24 // An implementations may choose to return results from either one of the Get
25 // methods, or from both.
26 class NET_EXPORT CertIssuerSource {
27 public:
28 class NET_EXPORT Request {
29 public:
30 Request() = default;
31 // Destruction of the Request cancels it.
32 virtual ~Request() = default;
33
34 // Retrieves the next issuer.
35 //
36 // If one is available it will be stored in |out_cert| and SYNC will be
37 // returned. GetNext should be called again to retrieve any remaining
38 // issuers.
39 //
40 // If no issuers are currently available, |out_cert| will be cleared and the
41 // return value will indicate if the Request is exhausted. If the return
42 // value is ASYNC, the |issuers_callback| that was passed to
43 // AsyncGetIssuersOf will be called again (unless the Request is destroyed
44 // first). If the return value is SYNC, the Request is complete and the
45 // |issuers_callback| will not be called again.
46 virtual CompletionStatus GetNext(
47 scoped_refptr<ParsedCertificate>* out_cert) = 0;
48
49 private:
50 DISALLOW_COPY_AND_ASSIGN(Request);
51 };
52
53 using IssuerCallback = base::Callback<void(Request*)>;
54
55 virtual ~CertIssuerSource() = default;
56
57 // Finds certificates whose Subject matches |cert|'s Issuer.
58 // Matches are appended to |issuers|. Any existing contents of |issuers| will
59 // not be modified. If the implementation does not support synchronous
60 // lookups, or if there are no matches, |issuers| is not modified.
61 virtual void SyncGetIssuersOf(
62 const ParsedCertificate* cert,
63 std::vector<scoped_refptr<ParsedCertificate>>* issuers) = 0;
64
65 // Finds certificates whose Subject matches |cert|'s Issuer.
66 // If an async callback will be made |*out_req| is filled with a Request
67 // object which may be destroyed to cancel the callback. If the implementation
68 // does not support asynchronous lookups or can determine synchronously that
69 // it would return no results, |*out_req| will be set to nullptr.
70 //
71 // When matches are available or the request is complete, |issuers_callback|
72 // will be called with a pointer to the same Request. The Request::GetNext
73 // method may then be used to iterate through the retrieved issuers. Note that
74 // |issuers_callback| may be called multiple times. See the documentation for
75 // Request::GetNext for more details.
76 virtual void AsyncGetIssuersOf(const ParsedCertificate* cert,
77 const IssuerCallback& issuers_callback,
78 std::unique_ptr<Request>* out_req) = 0;
79 };
80
81 } // namespace net
82
83 #endif // NET_CERT_INTERNAL_CERT_ISSUER_SOURCE_H_
OLDNEW
« no previous file with comments | « no previous file | net/cert/internal/cert_issuer_source_static.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698