Index: webrtc/p2p/base/p2ptransportchannel.h |
diff --git a/webrtc/p2p/base/p2ptransportchannel.h b/webrtc/p2p/base/p2ptransportchannel.h |
index ada3ecfb8bb2deeb6bc5d9120eb1647d7cd1a1da..7f492537ddef2928b66baa8dc6c9df375fade9ad 100644 |
--- a/webrtc/p2p/base/p2ptransportchannel.h |
+++ b/webrtc/p2p/base/p2ptransportchannel.h |
@@ -115,7 +115,7 @@ class P2PTransportChannel : public TransportChannelImpl, |
int GetError() override { return error_; } |
bool GetStats(std::vector<ConnectionInfo>* stats) override; |
- const Connection* best_connection() const { return best_connection_; } |
+ const Connection* selected_connection() const { return selected_connection_; } |
void set_incoming_only(bool value) { incoming_only_ = value; } |
// Note: This is only for testing purpose. |
@@ -208,7 +208,7 @@ class P2PTransportChannel : public TransportChannelImpl, |
void UpdateConnectionStates(); |
void RequestSort(); |
void SortConnections(); |
- void SwitchBestConnectionTo(Connection* conn); |
+ void SwitchSelectedConnection(Connection* conn); |
void UpdateState(); |
void HandleAllTimedOut(); |
void MaybeStopPortAllocatorSessions(); |
@@ -258,8 +258,24 @@ class P2PTransportChannel : public TransportChannelImpl, |
void OnSort(); |
void OnCheckAndPing(); |
+ // Compares two connections based on the connection states |
+ // (writable/receiving/connected), nomination states, last data received time, |
+ // and static preferences. Does not include latency. Used by both sorting |
+ // and ShouldSwitchConnection(). |
+ // Returns a positive value if |a| is better than |b|. |
+ int CompareConnections(const cricket::Connection* a, |
+ const cricket::Connection* b) const; |
+ // This is similar to CompareConnections but excludes the connection states |
+ // from the comparison criteria. It is used when determining whether a |
+ // connection need to be pruned. |
pthatcher1
2016/06/21 07:16:53
need to be => needs to be
honghaiz3
2016/06/22 08:03:16
Done.
|
+ // Returns a positive value if |a| is better than |b| |
Taylor Brandstetter
2016/06/21 18:33:26
Missing period.
honghaiz3
2016/06/22 08:03:16
Done.
|
+ int CompareConnectionsBase(const cricket::Connection* a, |
Taylor Brandstetter
2016/06/21 18:33:26
I think this method can be removed. But if it's ke
honghaiz3
2016/06/22 08:03:16
Done.
|
+ const cricket::Connection* b) const; |
+ // Returns true if the new_connection should be selected for transmission. |
+ bool ShouldSwitchConnection(Connection* new_connection) const; |
+ |
void PruneConnections(); |
- Connection* best_nominated_connection() const; |
+ Connection* selected_nominated_connection() const; |
bool IsBackupConnection(Connection* conn) const; |
Connection* FindConnectionToPing(int64_t now); |
@@ -300,7 +316,7 @@ class P2PTransportChannel : public TransportChannelImpl, |
std::vector<PortInterface *> ports_; |
// |connections_| is a sorted list with the first one always be the |
- // |best_connection_| when it's not nullptr. The combination of |
+ // |selected_connection_| when it's not nullptr. The combination of |
// |pinged_connections_| and |unpinged_connections_| has the same |
// connections as |connections_|. These 2 sets maintain whether a |
// connection should be pinged next or not. |
@@ -308,11 +324,8 @@ class P2PTransportChannel : public TransportChannelImpl, |
std::set<Connection*> pinged_connections_; |
std::set<Connection*> unpinged_connections_; |
- Connection* best_connection_; |
+ Connection* selected_connection_ = nullptr; |
- // Connection selected by the controlling agent. This should be used only |
- // at controlled side when protocol type is RFC5245. |
- Connection* pending_best_connection_; |
std::vector<RemoteCandidate> remote_candidates_; |
bool sort_dirty_; // indicates whether another sort is needed right now |
bool had_connection_ = false; // if connections_ has ever been nonempty |