Chromium Code Reviews| Index: webrtc/p2p/base/stunport.h | 
| diff --git a/webrtc/p2p/base/stunport.h b/webrtc/p2p/base/stunport.h | 
| index cd844aa273ed2f7b3fbfc2109820c20bbf364356..0daf38c6dea769737a41e9d0d0f3920d4dfaaac0 100644 | 
| --- a/webrtc/p2p/base/stunport.h | 
| +++ b/webrtc/p2p/base/stunport.h | 
| @@ -26,6 +26,11 @@ class SignalThread; | 
| namespace cricket { | 
| +// Lifetime chosen for STUN ports on low-cost networks. | 
| +static const int INFINITE_LIFETIME = -1; | 
| +// Lifetime for STUN ports on high-cost networks: 2 minutes | 
| +static const int HIGH_COST_PORT_KEEPALIVE_LIFETIME = 2 * 60 * 1000; | 
| + | 
| // Communicates using the address on the outside of a NAT. | 
| class UDPPort : public Port { | 
| public: | 
| @@ -145,6 +150,8 @@ class UDPPort : public Port { | 
| const rtc::PacketOptions& options, | 
| bool payload); | 
| + virtual void UpdateNetworkCost(); | 
| + | 
| void OnLocalAddressReady(rtc::AsyncPacketSocket* socket, | 
| const rtc::SocketAddress& address); | 
| void OnReadPacket(rtc::AsyncPacketSocket* socket, | 
| @@ -219,6 +226,15 @@ class UDPPort : public Port { | 
| bool HasCandidateWithAddress(const rtc::SocketAddress& addr) const; | 
| + // If this is a low-cost network, it will keep on sending STUN binding | 
| + // requests indefinitely to keep the NAT binding alive. Otherwise, stop | 
| + // sending STUN binding requests after HIGH_COST_PORT_KEEPALIVE_LIFETIME. | 
| + int GetStunKeepaliveLifetimeFromNetworkCost() { | 
| 
 
pthatcher1
2016/05/17 21:23:11
GetStunKeepaliveLifetime() is probably sufficient.
 
honghaiz3
2016/05/18 07:41:47
Done.
 
 | 
| + return (network_cost() == rtc::kMaxNetworkCost) | 
| 
 
pthatcher1
2016/05/17 21:23:11
We should probably make this network_cost() > rtc:
 
honghaiz3
2016/05/18 07:41:47
Done >=
 
 | 
| + ? HIGH_COST_PORT_KEEPALIVE_LIFETIME | 
| + : INFINITE_LIFETIME; | 
| + } | 
| + | 
| ServerAddresses server_addresses_; | 
| ServerAddresses bind_request_succeeded_servers_; | 
| ServerAddresses bind_request_failed_servers_; |