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

Side by Side Diff: net/quic/port_suggester.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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
« no previous file with comments | « net/quic/port_suggester.h ('k') | net/quic/port_suggester_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/port_suggester.h" 5 #include "net/quic/port_suggester.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/base/host_port_pair.h" 8 #include "net/base/host_port_pair.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 PortSuggester::PortSuggester(const HostPortPair& server, uint64 seed) 12 PortSuggester::PortSuggester(const HostPortPair& server, uint64_t seed)
13 : call_count_(0), previous_suggestion_(-1) { 13 : call_count_(0), previous_suggestion_(-1) {
14 unsigned char hash_bytes[base::kSHA1Length]; 14 unsigned char hash_bytes[base::kSHA1Length];
15 base::SHA1HashBytes( 15 base::SHA1HashBytes(
16 reinterpret_cast<const unsigned char*>(server.host().data()), 16 reinterpret_cast<const unsigned char*>(server.host().data()),
17 server.host().length(), hash_bytes); 17 server.host().length(), hash_bytes);
18 static_assert(sizeof(seed_) < sizeof(hash_bytes), "seed larger than hash"); 18 static_assert(sizeof(seed_) < sizeof(hash_bytes), "seed larger than hash");
19 memcpy(&seed_, hash_bytes, sizeof(seed_)); 19 memcpy(&seed_, hash_bytes, sizeof(seed_));
20 seed_ ^= seed ^ server.port(); 20 seed_ ^= seed ^ server.port();
21 } 21 }
22 22
(...skipping 16 matching lines...) Expand all
39 previous_suggestion_ = static_cast<int>(seed_ % range) + min; 39 previous_suggestion_ = static_cast<int>(seed_ % range) + min;
40 return previous_suggestion_; 40 return previous_suggestion_;
41 } 41 }
42 42
43 int PortSuggester::previous_suggestion() const { 43 int PortSuggester::previous_suggestion() const {
44 DCHECK_LT(0u, call_count_); 44 DCHECK_LT(0u, call_count_);
45 return previous_suggestion_; 45 return previous_suggestion_;
46 } 46 }
47 47
48 } // namespace net 48 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/port_suggester.h ('k') | net/quic/port_suggester_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698