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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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/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;
11 11
12 namespace net { 12 namespace net {
13 13
14 LocalStrikeRegisterClient::LocalStrikeRegisterClient( 14 LocalStrikeRegisterClient::LocalStrikeRegisterClient(
15 unsigned max_entries, 15 unsigned max_entries,
16 uint32 current_time_external, 16 uint32 current_time_external,
17 uint32 window_secs, 17 uint32 window_secs,
18 const uint8 orbit[8], 18 const uint8 orbit[8],
19 StrikeRegister::StartupType startup) 19 StrikeRegister::StartupType startup)
20 : strike_register_(max_entries, current_time_external, window_secs, 20 : strike_register_(max_entries,
21 orbit, startup) { 21 current_time_external,
22 window_secs,
23 orbit,
24 startup) {
22 } 25 }
23 26
24 bool LocalStrikeRegisterClient::IsKnownOrbit(StringPiece orbit) const { 27 bool LocalStrikeRegisterClient::IsKnownOrbit(StringPiece orbit) const {
25 base::AutoLock lock(m_); 28 base::AutoLock lock(m_);
26 if (orbit.length() != kOrbitSize) { 29 if (orbit.length() != kOrbitSize) {
27 return false; 30 return false;
28 } 31 }
29 return memcmp(orbit.data(), strike_register_.orbit(), kOrbitSize) == 0; 32 return memcmp(orbit.data(), strike_register_.orbit(), kOrbitSize) == 0;
30 } 33 }
31 34
32 void LocalStrikeRegisterClient::VerifyNonceIsValidAndUnique( 35 void LocalStrikeRegisterClient::VerifyNonceIsValidAndUnique(
33 StringPiece nonce, QuicWallTime now, ResultCallback* cb) { 36 StringPiece nonce,
37 QuicWallTime now,
38 ResultCallback* cb) {
34 bool nonce_is_valid_and_unique; 39 bool nonce_is_valid_and_unique;
35 if (nonce.length() != kNonceSize) { 40 if (nonce.length() != kNonceSize) {
36 nonce_is_valid_and_unique = false; 41 nonce_is_valid_and_unique = false;
37 } else { 42 } else {
38 base::AutoLock lock(m_); 43 base::AutoLock lock(m_);
39 nonce_is_valid_and_unique = strike_register_.Insert( 44 nonce_is_valid_and_unique =
40 reinterpret_cast<const uint8*>(nonce.data()), 45 strike_register_.Insert(reinterpret_cast<const uint8*>(nonce.data()),
41 static_cast<uint32>(now.ToUNIXSeconds())); 46 static_cast<uint32>(now.ToUNIXSeconds()));
42 } 47 }
43 48
44 // m_ must not be held when the ResultCallback runs. 49 // m_ must not be held when the ResultCallback runs.
45 cb->Run(nonce_is_valid_and_unique); 50 cb->Run(nonce_is_valid_and_unique);
46 } 51 }
47 52
48 } // namespace net 53 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698