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

Unified Diff: net/quic/test_tools/fake_proof_source.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/fake_proof_source.h ('k') | net/quic/test_tools/quic_session_peer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/test_tools/fake_proof_source.cc
diff --git a/net/quic/test_tools/fake_proof_source.cc b/net/quic/test_tools/fake_proof_source.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a19c97a148282fb25e204d30b6c143f2558a00e4
--- /dev/null
+++ b/net/quic/test_tools/fake_proof_source.cc
@@ -0,0 +1,103 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/quic/test_tools/fake_proof_source.h"
+#include "net/quic/test_tools/crypto_test_utils.h"
+
+using std::string;
+
+namespace net {
+namespace test {
+
+FakeProofSource::FakeProofSource()
+ : delegate_(CryptoTestUtils::ProofSourceForTesting()) {}
+
+FakeProofSource::~FakeProofSource() {}
+
+FakeProofSource::Params::Params(const IPAddress& server_ip,
+ std::string hostname,
+ std::string server_config,
+ QuicVersion quic_version,
+ std::string chlo_hash,
+ std::unique_ptr<ProofSource::Callback> callback)
+ : server_ip(server_ip),
+ hostname(hostname),
+ server_config(server_config),
+ quic_version(quic_version),
+ chlo_hash(chlo_hash),
+ callback(std::move(callback)) {}
+
+FakeProofSource::Params::~Params() {}
+
+FakeProofSource::Params::Params(FakeProofSource::Params&& other) = default;
+
+FakeProofSource::Params& FakeProofSource::Params::operator=(
+ FakeProofSource::Params&& other) = default;
+
+void FakeProofSource::Activate() {
+ active_ = true;
+}
+
+bool FakeProofSource::GetProof(const IPAddress& server_ip,
+ const string& hostname,
+ const string& server_config,
+ QuicVersion quic_version,
+ StringPiece chlo_hash,
+ scoped_refptr<ProofSource::Chain>* out_chain,
+ string* out_signature,
+ string* out_leaf_cert_sct) {
+ LOG(WARNING) << "Synchronous GetProof called";
+ return delegate_->GetProof(server_ip, hostname, server_config, quic_version,
+ chlo_hash, out_chain, out_signature,
+ out_leaf_cert_sct);
+}
+
+void FakeProofSource::GetProof(
+ const IPAddress& server_ip,
+ const string& hostname,
+ const string& server_config,
+ QuicVersion quic_version,
+ StringPiece chlo_hash,
+ std::unique_ptr<ProofSource::Callback> callback) {
+ if (!active_) {
+ scoped_refptr<Chain> chain;
+ string signature;
+ string leaf_cert_sct;
+ const bool ok = GetProof(server_ip, hostname, server_config, quic_version,
+ chlo_hash, &chain, &signature, &leaf_cert_sct);
+ callback->Run(ok, chain, signature, leaf_cert_sct,
+ /* details = */ nullptr);
+ return;
+ }
+
+ LOG(WARNING) << "Asynchronous GetProof called";
+ params_.push_back(Params{server_ip, hostname, server_config, quic_version,
+ chlo_hash.as_string(), std::move(callback)});
+}
+
+int FakeProofSource::NumPendingCallbacks() const {
+ return params_.size();
+}
+
+void FakeProofSource::InvokePendingCallback(int n) {
+ CHECK(NumPendingCallbacks() > n);
+
+ const Params& params = params_[n];
+
+ scoped_refptr<ProofSource::Chain> chain;
+ string signature;
+ string leaf_cert_sct;
+ const bool ok =
+ delegate_->GetProof(params.server_ip, params.hostname,
+ params.server_config, params.quic_version,
+ params.chlo_hash, &chain, &signature, &leaf_cert_sct);
+
+ params.callback->Run(ok, chain, signature, leaf_cert_sct,
+ /* details = */ nullptr);
+ auto it = params_.begin() + n;
+ params_.erase(it);
+}
+
+} // namespace test
+} // namespace net
« no previous file with comments | « net/quic/test_tools/fake_proof_source.h ('k') | net/quic/test_tools/quic_session_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698