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

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

Issue 1668073002: Add network cost as part of the connection comparison. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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/candidate.h
diff --git a/webrtc/p2p/base/candidate.h b/webrtc/p2p/base/candidate.h
index ac7acabf057cdd06fa4beb915989bc49d65f04ec..a4335f838b51a024e08828dc6f87761319595ab5 100644
--- a/webrtc/p2p/base/candidate.h
+++ b/webrtc/p2p/base/candidate.h
@@ -27,6 +27,8 @@
namespace cricket {
+const uint32_t kMaxNetworkCost = 0xFFFF;
pthatcher1 2016/02/12 00:07:12 Can we make it something that is going to look rea
honghaiz3 2016/02/12 19:28:43 Changed to 999. (digit 9 is a better convention to
pthatcher1 2016/02/12 20:05:26 Sounds good.
+
// Candidate for ICE based connection discovery.
class Candidate {
@@ -138,6 +140,15 @@ class Candidate {
ist >> generation_;
}
+ // |network_cost| measures the cost/penalty of using this candidate. A network
+ // cost of 0 indicates this candidate can be used freely. A value of
+ // |kMaxNetworkCost| indicates it should be used only as the last resort.
+ void set_network_cost(uint32_t network_cost) {
+ ASSERT(network_cost <= kMaxNetworkCost);
+ network_cost_ = network_cost;
+ }
+ uint32_t network_cost() const { return network_cost_; }
+
const std::string& foundation() const {
return foundation_;
}
@@ -211,10 +222,10 @@ class Candidate {
std::ostringstream ost;
std::string address = sensitive ? address_.ToSensitiveString() :
address_.ToString();
- ost << "Cand[" << foundation_ << ":" << component_ << ":"
- << protocol_ << ":" << priority_ << ":"
- << address << ":" << type_ << ":" << related_address_ << ":"
- << username_ << ":" << password_ << "]";
+ ost << "Cand[" << foundation_ << ":" << component_ << ":" << protocol_
+ << ":" << priority_ << ":" << address << ":" << type_ << ":"
+ << related_address_ << ":" << username_ << ":" << password_ << ":"
+ << network_cost_ << "]";
return ost.str();
}
@@ -233,6 +244,7 @@ class Candidate {
std::string foundation_;
rtc::SocketAddress related_address_;
std::string tcptype_;
+ uint32_t network_cost_ = 0;
};
// Used during parsing and writing to map component to channel name

Powered by Google App Engine
This is Rietveld 408576698