Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
|
eroman
2016/06/01 23:30:23
i think the interface may need more specificity fo
mattm
2016/06/01 23:48:33
ack.
| |
| 25 // methods, or from both. | |
| 26 class NET_EXPORT CertIssuerSource { | |
| 27 public: | |
| 28 class NET_EXPORT Request { | |
| 29 public: | |
| 30 // Destruction of the Request cancels it. | |
| 31 virtual ~Request() = default; | |
| 32 | |
| 33 // Retrieves the next issuer. | |
| 34 // | |
| 35 // If one is available it will be stored in |out_cert| and SYNC will be | |
| 36 // returned. GetNext should be called again to retrieve any remaining | |
| 37 // issuers. | |
| 38 // | |
| 39 // If no issuers are currently available, |out_cert| will be cleared and the | |
| 40 // return value will indicate if the Request is exhausted. If the return | |
| 41 // value is ASYNC, the |issuers_callback| that was passed to | |
| 42 // AsyncGetIssuersOf will be called again (unless the Request is destroyed | |
| 43 // first). If the return value is SYNC, the Request is complete and the | |
| 44 // |issuers_callback| will not be called again. | |
| 45 virtual CompletionStatus GetNext( | |
| 46 scoped_refptr<ParsedCertificate>* out_cert) = 0; | |
| 47 | |
| 48 private: | |
| 49 DISALLOW_COPY_AND_ASSIGN(Request); | |
| 50 }; | |
| 51 | |
| 52 using IssuerCallback = base::Callback<void(Request*)>; | |
| 53 | |
| 54 virtual ~CertIssuerSource() = default; | |
| 55 | |
| 56 // Finds certificates whose Subject matches |cert|'s Issuer. | |
| 57 // Matches are appended to |issuers|. Any existing contents of |issuers| will | |
| 58 // not be modified. If the implementation does not support synchronous | |
| 59 // lookups, or if there are no matches, |issuers| is not modified. | |
| 60 virtual void SyncGetIssuersOf( | |
| 61 const ParsedCertificate* cert, | |
| 62 std::vector<scoped_refptr<ParsedCertificate>>* issuers) = 0; | |
| 63 | |
| 64 // Finds certificates whose Subject matches |cert|'s Issuer. | |
| 65 // If an async callback will be made |*out_req| is filled with a Request | |
| 66 // object which may be destroyed to cancel the callback. If the implementation | |
| 67 // does not support asynchronous lookups or can determine synchronously that | |
| 68 // it would return no results, |*out_req| will be set to nullptr. | |
| 69 // | |
| 70 // When matches are available or the request is complete, |issuers_callback| | |
| 71 // will be called with a pointer to the same Request. The Request::GetNext | |
| 72 // method may then be used to iterate through the retrieved issuers. Note that | |
| 73 // |issuers_callback| may be called multiple times. See the documentation for | |
| 74 // Request::GetNext for more details. | |
| 75 virtual void AsyncGetIssuersOf(const ParsedCertificate* cert, | |
| 76 const IssuerCallback& issuers_callback, | |
| 77 std::unique_ptr<Request>* out_req) = 0; | |
| 78 }; | |
| 79 | |
| 80 } // namespace net | |
| 81 | |
| 82 #endif // NET_CERT_INTERNAL_CERT_ISSUER_SOURCE_H_ | |
| OLD | NEW |