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

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: Get network type from name matching only on IOS or Android. 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
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_;

Powered by Google App Engine
This is Rietveld 408576698