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

Unified Diff: webrtc/p2p/base/stunport.h

Issue 1976683003: Update the type and cost of existing networks if its type is found later by network monitor (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Minor changes Created 4 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/port_unittest.cc ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/stunport.h
diff --git a/webrtc/p2p/base/stunport.h b/webrtc/p2p/base/stunport.h
index cd844aa273ed2f7b3fbfc2109820c20bbf364356..82be6fae2ae6714ac5c2c6269d42474fe2ae24e6 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 GetStunKeepaliveLifetime() {
+ return (network_cost() >= rtc::kNetworkCostHigh)
+ ? HIGH_COST_PORT_KEEPALIVE_LIFETIME
+ : INFINITE_LIFETIME;
+ }
+
ServerAddresses server_addresses_;
ServerAddresses bind_request_succeeded_servers_;
ServerAddresses bind_request_failed_servers_;
@@ -228,7 +244,7 @@ class UDPPort : public Port {
std::unique_ptr<AddressResolver> resolver_;
bool ready_;
int stun_keepalive_delay_;
- int stun_keepalive_lifetime_;
+ int stun_keepalive_lifetime_ = INFINITE_LIFETIME;
// This is true by default and false when
// PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE is specified.
« no previous file with comments | « webrtc/p2p/base/port_unittest.cc ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698