Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / net / quic / test_tools / delayed_verify_strike_register_client.cc
blobb14a11802969f9a6ebeb7787c229e3dd582e225b
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
3 // found in the LICENSE file.
5 #include "net/quic/test_tools/delayed_verify_strike_register_client.h"
7 using base::StringPiece;
8 using std::string;
9 using std::vector;
11 namespace net {
12 namespace test {
14 DelayedVerifyStrikeRegisterClient::DelayedVerifyStrikeRegisterClient(
15 unsigned max_entries,
16 uint32 current_time_external,
17 uint32 window_secs,
18 const uint8 orbit[8],
19 StrikeRegister::StartupType startup)
20 : LocalStrikeRegisterClient(max_entries, current_time_external,
21 window_secs, orbit, startup),
22 delay_verifications_(false) {
25 DelayedVerifyStrikeRegisterClient::~DelayedVerifyStrikeRegisterClient() {}
27 void DelayedVerifyStrikeRegisterClient::VerifyNonceIsValidAndUnique(
28 StringPiece nonce,
29 QuicWallTime now,
30 ResultCallback* cb) {
31 if (delay_verifications_) {
32 pending_verifications_.push_back(VerifyArgs(nonce, now, cb));
33 } else {
34 LocalStrikeRegisterClient::VerifyNonceIsValidAndUnique(nonce, now, cb);
38 int DelayedVerifyStrikeRegisterClient::PendingVerifications() const {
39 return pending_verifications_.size();
42 void DelayedVerifyStrikeRegisterClient::RunPendingVerifications() {
43 vector<VerifyArgs> pending;
44 pending_verifications_.swap(pending);
45 for (vector<VerifyArgs>::const_iterator it = pending.begin(),
46 end = pending.end(); it != end; ++it) {
47 LocalStrikeRegisterClient::VerifyNonceIsValidAndUnique(
48 it->nonce, it->now, it->cb);
52 } // namespace test
53 } // namespace net