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

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

Issue 2069493002: Do not switch best connection on the controlled side too frequently (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge with head Created 4 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
Index: webrtc/p2p/base/p2ptransportchannel.h
diff --git a/webrtc/p2p/base/p2ptransportchannel.h b/webrtc/p2p/base/p2ptransportchannel.h
index 3f0191e83d520ae367ddeefc6ee10ad76585e6c4..22abcb68bc7465987852cfaa59304c2f5acc29da 100644
--- a/webrtc/p2p/base/p2ptransportchannel.h
+++ b/webrtc/p2p/base/p2ptransportchannel.h
@@ -117,7 +117,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.
@@ -210,7 +210,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();
@@ -229,7 +229,7 @@ class P2PTransportChannel : public TransportChannelImpl,
void RememberRemoteCandidate(const Candidate& remote_candidate,
PortInterface* origin_port);
bool IsPingable(Connection* conn, int64_t now);
- bool IsBestConnectionPingable(int64_t now);
+ bool IsSelectedConnectionPingable(int64_t now);
int CalculateActiveWritablePingInterval(Connection* conn, int64_t now);
void PingConnection(Connection* conn);
void AddAllocatorSession(std::unique_ptr<PortAllocatorSession> session);
@@ -262,8 +262,17 @@ 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 ShouldSwitchSelectedConnection().
+ // Returns a positive value if |a| is better than |b|.
+ int CompareConnections(const cricket::Connection* a,
+ const cricket::Connection* b) const;
+ // Returns true if the new_connection should be selected for transmission.
+ bool ShouldSwitchSelectedConnection(Connection* new_connection) const;
+
void PruneConnections();
- Connection* best_nominated_connection() const;
bool IsBackupConnection(Connection* conn) const;
Connection* FindConnectionToPing(int64_t now);
@@ -311,7 +320,7 @@ class P2PTransportChannel : public TransportChannelImpl,
std::vector<PortInterface*> removed_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.
@@ -319,11 +328,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
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel.cc » ('j') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698