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

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

Issue 2808513003: Add SafeClamp(), which accepts args of different types (Closed)
Patch Set: Created 3 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/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index bf549248b7b51cbf36b285d442b68277f3b8e6d3..4a466f5599ad582ad6ef1c55a4fdc0628a25fb1d 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(MINIMUM_RTT, MAXIMUM_RTT, 2 * rtt);
}
// Weighting of the old rtt value to new data.

Powered by Google App Engine
This is Rietveld 408576698