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_TEST_HELPERS_H_ | 5 #ifndef NET_CERT_INTERNAL_TRUST_STORE_TEST_HELPERS_H_ |
6 #define NET_CERT_INTERNAL_TRUST_STORE_TEST_HELPERS_H_ | 6 #define NET_CERT_INTERNAL_TRUST_STORE_TEST_HELPERS_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "net/cert/internal/trust_store.h" | 10 #include "net/cert/internal/trust_store.h" |
11 #include "net/cert/internal/trust_store_in_memory.h" | 11 #include "net/cert/internal/trust_store_in_memory.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 // Deletes the Request owned by |*req_owner|, then calls done_callback. Intended | 15 // Deletes the Request owned by |*req_owner|, then calls done_callback. Intended |
16 // to be passed as the TrustAnchorsCallback to FindTrustAnchorsForCert to test | 16 // to be passed as the TrustAnchorsCallback to FindTrustAnchorsForCert to test |
17 // deleting the Request during the request callback. | 17 // deleting the Request during the request callback. |
18 void TrustStoreRequestDeleter(std::unique_ptr<TrustStore::Request>* req_owner, | 18 void TrustStoreRequestDeleter(std::unique_ptr<TrustStore::Request>* req_owner, |
19 const base::Closure& done_callback, | 19 const base::Closure& done_callback, |
20 std::unique_ptr<TrustAnchors> anchors); | 20 TrustAnchors anchors); |
21 | 21 |
22 // Helper to record async results from a FindTrustAnchorsForCert call. | 22 // Helper to record async results from a FindTrustAnchorsForCert call. |
23 class TrustAnchorResultRecorder { | 23 class TrustAnchorResultRecorder { |
24 public: | 24 public: |
25 TrustAnchorResultRecorder(); | 25 TrustAnchorResultRecorder(); |
26 ~TrustAnchorResultRecorder(); | 26 ~TrustAnchorResultRecorder(); |
27 | 27 |
28 TrustStore::TrustAnchorsCallback Callback(); | 28 TrustStore::TrustAnchorsCallback Callback(); |
29 | 29 |
30 void Run() { run_loop_.Run(); } | 30 void Run() { run_loop_.Run(); } |
(...skipping 15 matching lines...) Expand all Loading... |
46 ~TrustStoreInMemoryAsync() override; | 46 ~TrustStoreInMemoryAsync() override; |
47 | 47 |
48 // Adds |anchor| to the set of results that will be returned synchronously. | 48 // Adds |anchor| to the set of results that will be returned synchronously. |
49 void AddSyncTrustAnchor(scoped_refptr<TrustAnchor> anchor); | 49 void AddSyncTrustAnchor(scoped_refptr<TrustAnchor> anchor); |
50 | 50 |
51 // Adds |anchor| to the set of results that will be returned asynchronously. | 51 // Adds |anchor| to the set of results that will be returned asynchronously. |
52 void AddAsyncTrustAnchor(scoped_refptr<TrustAnchor> anchor); | 52 void AddAsyncTrustAnchor(scoped_refptr<TrustAnchor> anchor); |
53 | 53 |
54 // TrustStore implementation: | 54 // TrustStore implementation: |
55 void FindTrustAnchorsForCert( | 55 void FindTrustAnchorsForCert( |
56 const ParsedCertificate* cert, | 56 const scoped_refptr<ParsedCertificate>& cert, |
57 const TrustAnchorsCallback& callback, | 57 const TrustAnchorsCallback& callback, |
58 TrustAnchors* synchronous_matches, | 58 TrustAnchors* synchronous_matches, |
59 std::unique_ptr<Request>* out_req) const override; | 59 std::unique_ptr<Request>* out_req) const override; |
60 | 60 |
61 private: | 61 private: |
62 TrustStoreInMemory sync_store_; | 62 TrustStoreInMemory sync_store_; |
63 TrustStoreInMemory async_store_; | 63 TrustStoreInMemory async_store_; |
64 }; | 64 }; |
65 | 65 |
66 } // namespace net | 66 } // namespace net |
67 | 67 |
68 #endif // NET_CERT_INTERNAL_TRUST_STORE_TEST_HELPERS_H_ | 68 #endif // NET_CERT_INTERNAL_TRUST_STORE_TEST_HELPERS_H_ |
OLD | NEW |