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

Side by Side Diff: net/quic/test_tools/fake_proof_source.h

Issue 2430973004: Landing Recent QUIC changes until 10:38 AM, Oct 17, 2016 UTC-4 (Closed)
Patch Set: Improving flagsaver logging Created 4 years, 2 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 | « net/quic/core/reliable_quic_stream.h ('k') | net/quic/test_tools/fake_proof_source.cc » ('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 (c) 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_QUIC_TEST_TOOLS_FAKE_PROOF_SOURCE_H_
6 #define NET_QUIC_TEST_TOOLS_FAKE_PROOF_SOURCE_H_
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "net/quic/core/crypto/proof_source.h"
13
14 namespace net {
15 namespace test {
16
17 // Implementation of ProofSource which delegates to a ProofSourceForTesting,
18 // except that when the async GetProof is called, it captures the call and
19 // allows tests to see that a call is pending, which they can then cause to
20 // complete at a time of their choosing.
21 class FakeProofSource : public ProofSource {
22 public:
23 FakeProofSource();
24 ~FakeProofSource() override;
25
26 // Before this object is "active", all calls to GetProof will be delegated
27 // immediately. Once "active", the async ones will be intercepted. This
28 // distinction is necessary to ensure that GetProof can be called without
29 // interference during test case setup.
30 void Activate();
31
32 // ProofSource interface
33 bool GetProof(const IPAddress& server_ip,
34 const std::string& hostname,
35 const std::string& server_config,
36 QuicVersion quic_version,
37 base::StringPiece chlo_hash,
38 scoped_refptr<ProofSource::Chain>* out_chain,
39 std::string* out_signature,
40 std::string* out_leaf_cert_sct) override;
41 void GetProof(const IPAddress& server_ip,
42 const std::string& hostname,
43 const std::string& server_config,
44 QuicVersion quic_version,
45 base::StringPiece chlo_hash,
46 std::unique_ptr<ProofSource::Callback> callback) override;
47
48 // Get the number of callbacks which are pending
49 int NumPendingCallbacks() const;
50
51 // Invoke a pending callback. The index refers to the position in params_ of
52 // the callback to be completed.
53 void InvokePendingCallback(int n);
54
55 private:
56 std::unique_ptr<ProofSource> delegate_;
57 bool active_ = false;
58
59 struct Params {
60 Params(const IPAddress& server_ip,
61 std::string hostname,
62 std::string server_config,
63 QuicVersion quic_version,
64 std::string chlo_hash,
65 std::unique_ptr<ProofSource::Callback> callback);
66 ~Params();
67 Params(Params&& other);
68 Params& operator=(Params&& other);
69
70 IPAddress server_ip;
71 std::string hostname;
72 std::string server_config;
73 QuicVersion quic_version;
74 std::string chlo_hash;
75 std::unique_ptr<ProofSource::Callback> callback;
76 };
77
78 std::vector<Params> params_;
79 };
80
81 } // namespace test
82 } // namespace net
83
84 #endif // NET_QUIC_TEST_TOOLS_FAKE_PROOF_SOURCE_H_
OLDNEW
« no previous file with comments | « net/quic/core/reliable_quic_stream.h ('k') | net/quic/test_tools/fake_proof_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698