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

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

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

Powered by Google App Engine
This is Rietveld 408576698