OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_CERT_INTERNAL_TRUST_STORE_COLLECTION_H_ | 5 #ifndef NET_CERT_INTERNAL_TRUST_STORE_COLLECTION_H_ |
6 #define NET_CERT_INTERNAL_TRUST_STORE_COLLECTION_H_ | 6 #define NET_CERT_INTERNAL_TRUST_STORE_COLLECTION_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" |
10 #include "net/cert/internal/trust_store.h" | 10 #include "net/cert/internal/trust_store.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class TaskRunner; | 13 class TaskRunner; |
14 } | 14 } |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 // TrustStoreCollection is an implementation of TrustStore which combines the | 18 // TrustStoreCollection is an implementation of TrustStore which combines the |
19 // results from multiple TrustStores. | 19 // results from multiple TrustStores. |
20 // | 20 // |
21 // The synchronous matches will be in order from the primary store, and then | 21 // The order of the matches will correspond to a concatenation of matches in |
22 // from the secondary stores in the order they were added to the | 22 // the order the stores were added. |
23 // TrustStoreCollection. | |
24 // | |
25 // Currently only one "primary" store can be added that supports async queries, | |
26 // any number of additional, synchronous-only stores can be used. (The | |
27 // assumption is that the async one would be useful for OS integration, while | |
28 // the sync only stores can be used for supplying additional anchors. If | |
29 // multiple async stores are desired, it might be worth changing the | |
30 // FindTrustAnchorsForCert interface so that it can return async results in | |
31 // multiple batches.) | |
32 class NET_EXPORT TrustStoreCollection : public TrustStore { | 23 class NET_EXPORT TrustStoreCollection : public TrustStore { |
33 public: | 24 public: |
34 TrustStoreCollection(); | 25 TrustStoreCollection(); |
35 ~TrustStoreCollection() override; | 26 ~TrustStoreCollection() override; |
36 | 27 |
37 // Includes results from |store| in the combined output. Both sync and async | 28 // Includes results from |store| in the combined output. |store| must |
38 // queries to |store| will be allowed. |store| must outlive the | 29 // outlive the TrustStoreCollection. |
39 // TrustStoreCollection. | 30 void AddTrustStore(TrustStore* store); |
40 void SetPrimaryTrustStore(TrustStore* store); | |
41 | |
42 // Includes results from |store| in the combined output. |store| will only be | |
43 // queried synchronously. |store| must outlive the TrustStoreCollection. | |
44 void AddTrustStoreSynchronousOnly(TrustStore* store); | |
45 | 31 |
46 // TrustStore implementation: | 32 // TrustStore implementation: |
47 void FindTrustAnchorsForCert( | 33 void FindTrustAnchorsForCert(const scoped_refptr<ParsedCertificate>& cert, |
48 const scoped_refptr<ParsedCertificate>& cert, | 34 TrustAnchors* matches) const override; |
49 const TrustAnchorsCallback& callback, | |
50 TrustAnchors* synchronous_matches, | |
51 std::unique_ptr<Request>* out_req) const override; | |
52 | 35 |
53 private: | 36 private: |
54 TrustStore* primary_store_ = nullptr; | 37 std::vector<TrustStore*> stores_; |
55 std::vector<TrustStore*> sync_only_stores_; | |
56 | 38 |
57 DISALLOW_COPY_AND_ASSIGN(TrustStoreCollection); | 39 DISALLOW_COPY_AND_ASSIGN(TrustStoreCollection); |
58 }; | 40 }; |
59 | 41 |
60 } // namespace net | 42 } // namespace net |
61 | 43 |
62 #endif // NET_CERT_INTERNAL_TRUST_STORE_COLLECTION_H_ | 44 #endif // NET_CERT_INTERNAL_TRUST_STORE_COLLECTION_H_ |
OLD | NEW |