Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
wtc
2013/12/06 23:36:44
Nit: this should say 2013. And "(c)" is now not ne
jar (doing other things)
2013/12/07 00:47:58
Done.
| |
| 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 "base/basictypes.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/sha1.h" | |
| 11 #include "net/base/host_port_pair.h" | |
|
wtc
2013/12/06 23:36:44
Nit: you may be able to get by with a forward decl
jar (doing other things)
2013/12/07 00:47:58
Done.
| |
| 12 | |
| 13 namespace net { | |
| 14 | |
| 15 // We provide a pseudo-random number generator that is always seeded the same | |
| 16 // way for a given destination host-port pair. The generator is used to | |
| 17 // consistently suggest (for that host-port pair) an ephemeral source port, | |
| 18 // and hence increase the likelihood that a server's load balancer will direct | |
| 19 // a repeated connection to the same server (with QUIC, further increasing the | |
| 20 // chance of connection establishment with 0-RTT). | |
| 21 class NET_EXPORT PortSuggester | |
| 22 : public base::RefCountedThreadSafe<PortSuggester> { | |
| 23 public: | |
| 24 // |per_profile_randomness| is used to prevent (reduce probability of) one | |
| 25 // profile's suggestions from matching that of another. | |
| 26 PortSuggester(const HostPortPair& hostport, uint64 per_profile_randomness); | |
|
wtc
2013/12/06 23:36:44
Nit: you should explain whose host and port |hostp
jar (doing other things)
2013/12/07 00:47:58
Done (switched to |server|)
| |
| 27 | |
| 28 // Generate a pseudo-random int in the given range. Will (probably) return | |
|
wtc
2013/12/06 23:36:44
Nit: please specify whether the range is inclusive
jar (doing other things)
2013/12/07 00:47:58
Done.
| |
| 29 // different numbers when called repeatedly. | |
| 30 int SuggestPort(int min, int max); | |
| 31 | |
| 32 private: | |
| 33 friend class base::RefCountedThreadSafe<PortSuggester>; | |
| 34 | |
| 35 virtual ~PortSuggester(); | |
| 36 | |
| 37 unsigned char seed_[base::kSHA1Length]; | |
| 38 int count_; // Number of suggestions made. | |
| 39 | |
| 40 DISALLOW_COPY_AND_ASSIGN(PortSuggester); | |
| 41 }; | |
| 42 | |
| 43 } // namespace net | |
| 44 | |
| 45 #endif // NET_QUIC_PORT_SUGGESTER_H_ | |
| OLD | NEW |