| 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 #include "net/quic/crypto/local_strike_register_client.h" | 5 #include "net/quic/crypto/local_strike_register_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 11 #include "base/sys_byteorder.h" | 11 #include "base/sys_byteorder.h" |
| 12 #include "net/quic/crypto/crypto_protocol.h" | 12 #include "net/quic/crypto/crypto_protocol.h" |
| 13 #include "net/quic/quic_time.h" | 13 #include "net/quic/quic_time.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 using base::StringPiece; | 16 using base::StringPiece; |
| 17 using std::string; | 17 using std::string; |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 namespace test { | 20 namespace test { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class RecordResultCallback : public StrikeRegisterClient::ResultCallback { | 23 class RecordResultCallback : public StrikeRegisterClient::ResultCallback { |
| 24 public: | 24 public: |
| 25 // RecordResultCallback stores the argument to RunImpl in | 25 // RecordResultCallback stores the argument to RunImpl in |
| 26 // |*saved_value| and sets |*called| to true. The callback is self | 26 // |*saved_value| and sets |*called| to true. The callback is self |
| 27 // deleting. | 27 // deleting. |
| 28 RecordResultCallback(bool* called, bool* saved_value) | 28 RecordResultCallback(bool* called, bool* saved_value) |
| 29 : called_(called), saved_value_(saved_value) { | 29 : called_(called), |
| 30 saved_value_(saved_value) { |
| 30 *called_ = false; | 31 *called_ = false; |
| 31 } | 32 } |
| 32 | 33 |
| 33 protected: | 34 protected: |
| 34 virtual void RunImpl(bool nonce_is_valid_and_unique) OVERRIDE { | 35 virtual void RunImpl(bool nonce_is_valid_and_unique) OVERRIDE { |
| 35 *called_ = true; | 36 *called_ = true; |
| 36 *saved_value_ = nonce_is_valid_and_unique; | 37 *saved_value_ = nonce_is_valid_and_unique; |
| 37 } | 38 } |
| 38 | 39 |
| 39 private: | 40 private: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 QuicWallTime::FromUNIXSeconds(kCurrentTimeExternalSecs), | 117 QuicWallTime::FromUNIXSeconds(kCurrentTimeExternalSecs), |
| 117 new RecordResultCallback(&called, &is_valid)); | 118 new RecordResultCallback(&called, &is_valid)); |
| 118 EXPECT_TRUE(called); | 119 EXPECT_TRUE(called); |
| 119 EXPECT_TRUE(is_valid); | 120 EXPECT_TRUE(is_valid); |
| 120 } | 121 } |
| 121 } | 122 } |
| 122 | 123 |
| 123 } // namespace | 124 } // namespace |
| 124 } // namespace test | 125 } // namespace test |
| 125 } // namespace net | 126 } // namespace net |
| OLD | NEW |