Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: net/quic/core/crypto/local_strike_register_client.cc

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/core/crypto/local_strike_register_client.h" 5 #include "net/quic/core/crypto/local_strike_register_client.h"
6 6
7 #include "net/quic/core/crypto/crypto_protocol.h" 7 #include "net/quic/core/crypto/crypto_protocol.h"
8 8
9 using base::StringPiece;
10 using std::string; 9 using std::string;
11 10
12 namespace net { 11 namespace net {
13 12
14 LocalStrikeRegisterClient::LocalStrikeRegisterClient( 13 LocalStrikeRegisterClient::LocalStrikeRegisterClient(
15 unsigned max_entries, 14 unsigned max_entries,
16 uint32_t current_time_external, 15 uint32_t current_time_external,
17 uint32_t window_secs, 16 uint32_t window_secs,
18 const uint8_t orbit[8], 17 const uint8_t orbit[8],
19 StrikeRegister::StartupType startup) 18 StrikeRegister::StartupType startup)
20 : strike_register_(max_entries, 19 : strike_register_(max_entries,
21 current_time_external, 20 current_time_external,
22 window_secs, 21 window_secs,
23 orbit, 22 orbit,
24 startup) {} 23 startup) {}
25 24
26 bool LocalStrikeRegisterClient::IsKnownOrbit(StringPiece orbit) const { 25 bool LocalStrikeRegisterClient::IsKnownOrbit(QuicStringPiece orbit) const {
27 QuicWriterMutexLock lock(&m_); 26 QuicWriterMutexLock lock(&m_);
28 if (orbit.length() != kOrbitSize) { 27 if (orbit.length() != kOrbitSize) {
29 return false; 28 return false;
30 } 29 }
31 return memcmp(orbit.data(), strike_register_.orbit(), kOrbitSize) == 0; 30 return memcmp(orbit.data(), strike_register_.orbit(), kOrbitSize) == 0;
32 } 31 }
33 32
34 void LocalStrikeRegisterClient::VerifyNonceIsValidAndUnique( 33 void LocalStrikeRegisterClient::VerifyNonceIsValidAndUnique(
35 StringPiece nonce, 34 QuicStringPiece nonce,
36 QuicWallTime now, 35 QuicWallTime now,
37 ResultCallback* cb) { 36 ResultCallback* cb) {
38 InsertStatus nonce_error; 37 InsertStatus nonce_error;
39 if (nonce.length() != kNonceSize) { 38 if (nonce.length() != kNonceSize) {
40 nonce_error = NONCE_INVALID_FAILURE; 39 nonce_error = NONCE_INVALID_FAILURE;
41 } else { 40 } else {
42 QuicWriterMutexLock lock(&m_); 41 QuicWriterMutexLock lock(&m_);
43 nonce_error = 42 nonce_error =
44 strike_register_.Insert(reinterpret_cast<const uint8_t*>(nonce.data()), 43 strike_register_.Insert(reinterpret_cast<const uint8_t*>(nonce.data()),
45 static_cast<uint32_t>(now.ToUNIXSeconds())); 44 static_cast<uint32_t>(now.ToUNIXSeconds()));
46 } 45 }
47 46
48 // m_ must not be held when the ResultCallback runs. 47 // m_ must not be held when the ResultCallback runs.
49 cb->Run((nonce_error == NONCE_OK), nonce_error); 48 cb->Run((nonce_error == NONCE_OK), nonce_error);
50 } 49 }
51 50
52 } // namespace net 51 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/local_strike_register_client.h ('k') | net/quic/core/crypto/local_strike_register_client_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698