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

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

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/p2p/quic_p2p_stream.h ('k') | net/quic/port_suggester.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 #ifndef NET_QUIC_PORT_SUGGESTER_H_ 5 #ifndef NET_QUIC_PORT_SUGGESTER_H_
6 #define NET_QUIC_PORT_SUGGESTER_H_ 6 #define NET_QUIC_PORT_SUGGESTER_H_
7 7
8 #include "base/basictypes.h" 8 #include <stdint.h>
9
10 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/sha1.h" 12 #include "base/sha1.h"
11 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
12 14
13 namespace net { 15 namespace net {
14 16
15 class HostPortPair; 17 class HostPortPair;
16 18
17 // We provide a pseudo-random number generator that is always seeded the same 19 // We provide a pseudo-random number generator that is always seeded the same
18 // way for a given destination host-port pair. The generator is used to 20 // way for a given destination host-port pair. The generator is used to
19 // consistently suggest (for that host-port pair) an ephemeral source port, 21 // consistently suggest (for that host-port pair) an ephemeral source port,
20 // and hence increase the likelihood that a server's load balancer will direct 22 // and hence increase the likelihood that a server's load balancer will direct
21 // a repeated connection to the same server (with QUIC, further increasing the 23 // a repeated connection to the same server (with QUIC, further increasing the
22 // chance of connection establishment with 0-RTT). 24 // chance of connection establishment with 0-RTT).
23 class NET_EXPORT_PRIVATE PortSuggester 25 class NET_EXPORT_PRIVATE PortSuggester
24 : public base::RefCounted<PortSuggester> { 26 : public base::RefCounted<PortSuggester> {
25 public: 27 public:
26 PortSuggester(const HostPortPair& server, uint64 seed); 28 PortSuggester(const HostPortPair& server, uint64_t seed);
27 29
28 // Generate a pseudo-random int in the inclusive range from |min| to |max|. 30 // Generate a pseudo-random int in the inclusive range from |min| to |max|.
29 // Will (probably) return different numbers when called repeatedly. 31 // Will (probably) return different numbers when called repeatedly.
30 int SuggestPort(int min, int max); 32 int SuggestPort(int min, int max);
31 33
32 uint32 call_count() const { return call_count_; } 34 uint32_t call_count() const { return call_count_; }
33 int previous_suggestion() const; 35 int previous_suggestion() const;
34 36
35 private: 37 private:
36 friend class base::RefCounted<PortSuggester>; 38 friend class base::RefCounted<PortSuggester>;
37 39
38 virtual ~PortSuggester() {} 40 virtual ~PortSuggester() {}
39 41
40 // We maintain the first 8 bytes of a hash as our seed_ state. 42 // We maintain the first 8 bytes of a hash as our seed_ state.
41 uint64 seed_; 43 uint64_t seed_;
42 uint32 call_count_; // Number of suggestions made. 44 uint32_t call_count_; // Number of suggestions made.
43 int previous_suggestion_; 45 int previous_suggestion_;
44 46
45 DISALLOW_COPY_AND_ASSIGN(PortSuggester); 47 DISALLOW_COPY_AND_ASSIGN(PortSuggester);
46 }; 48 };
47 49
48 } // namespace net 50 } // namespace net
49 51
50 #endif // NET_QUIC_PORT_SUGGESTER_H_ 52 #endif // NET_QUIC_PORT_SUGGESTER_H_
OLDNEW
« no previous file with comments | « net/quic/p2p/quic_p2p_stream.h ('k') | net/quic/port_suggester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698