Chromium Code Reviews| 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 "net/quic/crypto/crypto_protocol.h" | 7 #include "net/quic/crypto/crypto_protocol.h" |
| 8 | 8 |
| 9 using base::StringPiece; | 9 using base::StringPiece; |
| 10 using std::string; | 10 using std::string; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 bool LocalStrikeRegisterClient::IsKnownOrbit(StringPiece orbit) const { | 24 bool LocalStrikeRegisterClient::IsKnownOrbit(StringPiece orbit) const { |
| 25 base::AutoLock lock(m_); | 25 base::AutoLock lock(m_); |
| 26 if (orbit.length() != kOrbitSize) { | 26 if (orbit.length() != kOrbitSize) { |
| 27 return false; | 27 return false; |
| 28 } | 28 } |
| 29 return memcmp(orbit.data(), strike_register_.orbit(), kOrbitSize) == 0; | 29 return memcmp(orbit.data(), strike_register_.orbit(), kOrbitSize) == 0; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void LocalStrikeRegisterClient::VerifyNonceIsValidAndUnique( | 32 void LocalStrikeRegisterClient::VerifyNonceIsValidAndUnique( |
| 33 StringPiece nonce, QuicWallTime now, ResultCallback* cb) { | 33 StringPiece nonce, |
| 34 bool nonce_is_valid_and_unique; | 34 QuicWallTime now, |
| 35 ResultCallback* cb) { | |
| 36 InsertStatus nonce_error; | |
| 35 if (nonce.length() != kNonceSize) { | 37 if (nonce.length() != kNonceSize) { |
| 36 nonce_is_valid_and_unique = false; | 38 nonce_error = NONCE_INVALID_FAILURE; |
| 37 } else { | 39 } else { |
| 38 base::AutoLock lock(m_); | 40 base::AutoLock lock(m_); |
| 39 nonce_is_valid_and_unique = strike_register_.Insert( | 41 nonce_error = strike_register_.Insert( |
| 40 reinterpret_cast<const uint8*>(nonce.data()), | 42 reinterpret_cast<const uint8*>(nonce.data()), |
| 41 static_cast<uint32>(now.ToUNIXSeconds())); | 43 static_cast<uint32>(now.ToUNIXSeconds())); |
| 42 } | 44 } |
| 43 | 45 |
| 44 // m_ must not be held when the ResultCallback runs. | 46 // m_ must not be held when the ResultCallback runs. |
| 45 cb->Run(nonce_is_valid_and_unique); | 47 cb->Run((nonce_error == net::NONCE_OK), nonce_error); |
|
wtc
2014/07/14 21:52:28
Remove net::
ramant (doing other things)
2014/07/14 22:16:06
Done.
| |
| 46 } | 48 } |
| 47 | 49 |
| 48 } // namespace net | 50 } // namespace net |
| OLD | NEW |