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

Unified Diff: webrtc/p2p/base/port.cc

Issue 2808513003: Add SafeClamp(), which accepts args of different types (Closed)
Patch Set: rebase Created 3 years, 6 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/modules/rtp_rtcp/source/rtp_sender.cc ('k') | webrtc/p2p/base/pseudotcp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index bf549248b7b51cbf36b285d442b68277f3b8e6d3..e657125869c74812f1a4c52c05a785b8af31f958 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -21,6 +21,7 @@
#include "webrtc/base/messagedigest.h"
#include "webrtc/base/network.h"
#include "webrtc/base/ptr_util.h"
+#include "webrtc/base/safe_minmax.h"
#include "webrtc/base/stringencode.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/p2p/base/common.h"
@@ -69,7 +70,7 @@ const int DEFAULT_RTT = 3000; // 3 seconds
// Computes our estimate of the RTT given the current estimate.
inline int ConservativeRTTEstimate(int rtt) {
- return std::max(MINIMUM_RTT, std::min(MAXIMUM_RTT, 2 * rtt));
+ return rtc::SafeClamp(2 * rtt, MINIMUM_RTT, MAXIMUM_RTT);
}
// Weighting of the old rtt value to new data.
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.cc ('k') | webrtc/p2p/base/pseudotcp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698