X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fnet%2Fquic%2Ftest_tools%2Fcrypto_test_utils.h;h=643550e87ccfef8e8568ad7281648e09c459c485;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=a226c85ad9c2ec12d95a2eba3651c27b92e591cb;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/net/quic/test_tools/crypto_test_utils.h b/src/net/quic/test_tools/crypto_test_utils.h index a226c85..643550e 100644 --- a/src/net/quic/test_tools/crypto_test_utils.h +++ b/src/net/quic/test_tools/crypto_test_utils.h @@ -38,6 +38,20 @@ class PacketSavingConnection; class CryptoTestUtils { public: + // An interface for a source of callbacks. This is used for invoking + // callbacks asynchronously. + // + // Call the RunPendingCallbacks method regularly to run the callbacks from + // this source. + class CallbackSource { + public: + virtual ~CallbackSource() {} + + // Runs pending callbacks from this source. If there is no pending + // callback, does nothing. + virtual void RunPendingCallbacks() = 0; + }; + // FakeClientOptions bundles together a number of options for configuring // HandshakeWithFakeClient. struct FakeClientOptions { @@ -50,6 +64,10 @@ class CryptoTestUtils { // If channel_id_enabled is true then the client will attempt to send a // ChannelID. bool channel_id_enabled; + + // If channel_id_source_async is true then the client will use an async + // ChannelIDSource for testing. Ignored if channel_id_enabled is false. + bool channel_id_source_async; }; // returns: the number of client hellos that the client sent. @@ -76,6 +94,17 @@ class CryptoTestUtils { PacketSavingConnection* b_conn, QuicCryptoStream* b); + // CommunicateHandshakeMessagesAndRunCallbacks moves messages from |a| to |b| + // and back until |a|'s handshake has completed. If |callback_source| is not + // NULL, CommunicateHandshakeMessagesAndRunCallbacks also runs callbacks from + // |callback_source| between processing messages. + static void CommunicateHandshakeMessagesAndRunCallbacks( + PacketSavingConnection* a_conn, + QuicCryptoStream* a, + PacketSavingConnection* b_conn, + QuicCryptoStream* b, + CallbackSource* callback_source); + // AdvanceHandshake attempts to moves messages from |a| to |b| and |b| to |a|. // Returns the number of messages moved. static std::pair AdvanceHandshake( @@ -100,6 +129,15 @@ class CryptoTestUtils { // returned by |ProofVerifierForTesting|. static ProofVerifyContext* ProofVerifyContextForTesting(); + // These functions return a fake |ProofSource|, |ProofVerifier|, or + // |ProofVerifyContext| that works with each other. These are suitable for + // unit tests that aren't concerned with |ProofSource| and |ProofVerifier|. + // TODO(wtc): delete these when Chromium has a working + // ProofSourceForTesting(). + static ProofSource* FakeProofSourceForTesting(); + static ProofVerifier* FakeProofVerifierForTesting(); + static ProofVerifyContext* FakeProofVerifyContextForTesting(); + // MockCommonCertSets returns a CommonCertSets that contains a single set with // hash |hash|, consisting of the certificate |cert| at index |index|. static CommonCertSets* MockCommonCertSets(base::StringPiece cert,