| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_QUIC_TEST_TOOLS_DELAYED_VERIFY_STRIKE_REGISTER_CLIENT_H_ | 5 #ifndef NET_QUIC_TEST_TOOLS_DELAYED_VERIFY_STRIKE_REGISTER_CLIENT_H_ |
| 6 #define NET_QUIC_TEST_TOOLS_DELAYED_VERIFY_STRIKE_REGISTER_CLIENT_H_ | 6 #define NET_QUIC_TEST_TOOLS_DELAYED_VERIFY_STRIKE_REGISTER_CLIENT_H_ |
| 7 | 7 |
| 8 #include <cstdint> | 8 #include <cstdint> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/string_piece.h" | |
| 14 #include "net/quic/core/crypto/local_strike_register_client.h" | 13 #include "net/quic/core/crypto/local_strike_register_client.h" |
| 14 #include "net/quic/platform/api/quic_string_piece.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 namespace test { | 17 namespace test { |
| 18 | 18 |
| 19 // Test helper that allows delaying execution of nonce verification | 19 // Test helper that allows delaying execution of nonce verification |
| 20 // callbacks until a later time. | 20 // callbacks until a later time. |
| 21 class DelayedVerifyStrikeRegisterClient : public LocalStrikeRegisterClient { | 21 class DelayedVerifyStrikeRegisterClient : public LocalStrikeRegisterClient { |
| 22 public: | 22 public: |
| 23 DelayedVerifyStrikeRegisterClient(unsigned max_entries, | 23 DelayedVerifyStrikeRegisterClient(unsigned max_entries, |
| 24 uint32_t current_time_external, | 24 uint32_t current_time_external, |
| 25 uint32_t window_secs, | 25 uint32_t window_secs, |
| 26 const uint8_t orbit[8], | 26 const uint8_t orbit[8], |
| 27 StrikeRegister::StartupType startup); | 27 StrikeRegister::StartupType startup); |
| 28 ~DelayedVerifyStrikeRegisterClient() override; | 28 ~DelayedVerifyStrikeRegisterClient() override; |
| 29 | 29 |
| 30 void VerifyNonceIsValidAndUnique(base::StringPiece nonce, | 30 void VerifyNonceIsValidAndUnique(QuicStringPiece nonce, |
| 31 QuicWallTime now, | 31 QuicWallTime now, |
| 32 ResultCallback* cb) override; | 32 ResultCallback* cb) override; |
| 33 | 33 |
| 34 // Start queueing verifications instead of executing them immediately. | 34 // Start queueing verifications instead of executing them immediately. |
| 35 void StartDelayingVerification() { delay_verifications_ = true; } | 35 void StartDelayingVerification() { delay_verifications_ = true; } |
| 36 // Number of verifications that are queued. | 36 // Number of verifications that are queued. |
| 37 int PendingVerifications() const; | 37 int PendingVerifications() const; |
| 38 // Run all pending verifications. | 38 // Run all pending verifications. |
| 39 void RunPendingVerifications(); | 39 void RunPendingVerifications(); |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 struct VerifyArgs { | 42 struct VerifyArgs { |
| 43 VerifyArgs(base::StringPiece in_nonce, | 43 VerifyArgs(QuicStringPiece in_nonce, |
| 44 QuicWallTime in_now, | 44 QuicWallTime in_now, |
| 45 ResultCallback* in_cb) | 45 ResultCallback* in_cb) |
| 46 : nonce(in_nonce.as_string()), now(in_now), cb(in_cb) {} | 46 : nonce(in_nonce.as_string()), now(in_now), cb(in_cb) {} |
| 47 | 47 |
| 48 std::string nonce; | 48 std::string nonce; |
| 49 QuicWallTime now; | 49 QuicWallTime now; |
| 50 ResultCallback* cb; | 50 ResultCallback* cb; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 bool delay_verifications_; | 53 bool delay_verifications_; |
| 54 std::vector<VerifyArgs> pending_verifications_; | 54 std::vector<VerifyArgs> pending_verifications_; |
| 55 | 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(DelayedVerifyStrikeRegisterClient); | 56 DISALLOW_COPY_AND_ASSIGN(DelayedVerifyStrikeRegisterClient); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 } // namespace test | 59 } // namespace test |
| 60 } // namespace net | 60 } // namespace net |
| 61 | 61 |
| 62 #endif // NET_QUIC_TEST_TOOLS_DELAYED_VERIFY_STRIKE_REGISTER_CLIENT_H_ | 62 #endif // NET_QUIC_TEST_TOOLS_DELAYED_VERIFY_STRIKE_REGISTER_CLIENT_H_ |
| OLD | NEW |