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 #include "net/cert/internal/trust_store_test_helpers.h" | 5 #include "net/cert/internal/trust_store_test_helpers.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 TrustStore::TrustAnchorsCallback callback_; | 36 TrustStore::TrustAnchorsCallback callback_; |
37 base::WeakPtrFactory<TrustStoreInMemoryAsyncRequest> weak_ptr_factory_; | 37 base::WeakPtrFactory<TrustStoreInMemoryAsyncRequest> weak_ptr_factory_; |
38 }; | 38 }; |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 void TrustStoreRequestDeleter(std::unique_ptr<TrustStore::Request>* req_owner, | 42 void TrustStoreRequestDeleter(std::unique_ptr<TrustStore::Request>* req_owner, |
43 const base::Closure& done_callback, | 43 const base::Closure& done_callback, |
44 std::unique_ptr<TrustAnchors> anchors) { | 44 TrustAnchors anchors) { |
45 req_owner->reset(); | 45 req_owner->reset(); |
46 done_callback.Run(); | 46 done_callback.Run(); |
47 } | 47 } |
48 | 48 |
49 TrustAnchorResultRecorder::TrustAnchorResultRecorder() = default; | 49 TrustAnchorResultRecorder::TrustAnchorResultRecorder() = default; |
50 TrustAnchorResultRecorder::~TrustAnchorResultRecorder() = default; | 50 TrustAnchorResultRecorder::~TrustAnchorResultRecorder() = default; |
51 | 51 |
52 TrustStore::TrustAnchorsCallback TrustAnchorResultRecorder::Callback() { | 52 TrustStore::TrustAnchorsCallback TrustAnchorResultRecorder::Callback() { |
53 return base::Bind(&TrustAnchorResultRecorder::OnGotAnchors, | 53 return base::Bind(&TrustAnchorResultRecorder::OnGotAnchors, |
54 base::Unretained(this)); | 54 base::Unretained(this)); |
(...skipping 11 matching lines...) Expand all Loading... |
66 scoped_refptr<TrustAnchor> anchor) { | 66 scoped_refptr<TrustAnchor> anchor) { |
67 sync_store_.AddTrustAnchor(std::move(anchor)); | 67 sync_store_.AddTrustAnchor(std::move(anchor)); |
68 } | 68 } |
69 | 69 |
70 void TrustStoreInMemoryAsync::AddAsyncTrustAnchor( | 70 void TrustStoreInMemoryAsync::AddAsyncTrustAnchor( |
71 scoped_refptr<TrustAnchor> anchor) { | 71 scoped_refptr<TrustAnchor> anchor) { |
72 async_store_.AddTrustAnchor(std::move(anchor)); | 72 async_store_.AddTrustAnchor(std::move(anchor)); |
73 } | 73 } |
74 | 74 |
75 void TrustStoreInMemoryAsync::FindTrustAnchorsForCert( | 75 void TrustStoreInMemoryAsync::FindTrustAnchorsForCert( |
76 const ParsedCertificate* cert, | 76 const scoped_refptr<ParsedCertificate>& cert, |
77 const TrustAnchorsCallback& callback, | 77 const TrustAnchorsCallback& callback, |
78 TrustAnchors* synchronous_matches, | 78 TrustAnchors* synchronous_matches, |
79 std::unique_ptr<Request>* out_req) const { | 79 std::unique_ptr<Request>* out_req) const { |
80 sync_store_.FindTrustAnchorsForCert(cert, TrustAnchorsCallback(), | 80 sync_store_.FindTrustAnchorsForCert(cert, TrustAnchorsCallback(), |
81 synchronous_matches, nullptr); | 81 synchronous_matches, nullptr); |
82 if (!callback.is_null()) { | 82 if (!callback.is_null()) { |
83 TrustAnchors async_matches; | 83 TrustAnchors async_matches; |
84 async_store_.FindTrustAnchorsForCert(cert, TrustAnchorsCallback(), | 84 async_store_.FindTrustAnchorsForCert(cert, TrustAnchorsCallback(), |
85 &async_matches, nullptr); | 85 &async_matches, nullptr); |
86 | 86 |
87 std::unique_ptr<TrustStoreInMemoryAsyncRequest> req( | 87 std::unique_ptr<TrustStoreInMemoryAsyncRequest> req( |
88 base::MakeUnique<TrustStoreInMemoryAsyncRequest>(callback)); | 88 base::MakeUnique<TrustStoreInMemoryAsyncRequest>(callback)); |
89 req->PostTrustCallback(std::move(async_matches)); | 89 req->PostTrustCallback(std::move(async_matches)); |
90 | 90 |
91 *out_req = std::move(req); | 91 *out_req = std::move(req); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 } // namespace net | 95 } // namespace net |
OLD | NEW |