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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.h

Issue 2369963004: Ping the premier connection on each network with higher priority. (Closed)
Patch Set: Add TODO for re-thinking prioritizing connections for ping requests. Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 25 matching lines...) Expand all
36 #include "webrtc/base/asyncpacketsocket.h" 36 #include "webrtc/base/asyncpacketsocket.h"
37 #include "webrtc/base/sigslot.h" 37 #include "webrtc/base/sigslot.h"
38 38
39 namespace cricket { 39 namespace cricket {
40 40
41 // Enum for UMA metrics, used to record whether the channel is 41 // Enum for UMA metrics, used to record whether the channel is
42 // connected/connecting/disconnected when ICE restart happens. 42 // connected/connecting/disconnected when ICE restart happens.
43 enum class IceRestartState { CONNECTING, CONNECTED, DISCONNECTED, MAX_VALUE }; 43 enum class IceRestartState { CONNECTING, CONNECTED, DISCONNECTED, MAX_VALUE };
44 44
45 extern const int WEAK_PING_INTERVAL; 45 extern const int WEAK_PING_INTERVAL;
46 extern const int STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL; 46 extern const int WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL;
47 extern const int STABLE_WRITABLE_CONNECTION_PING_INTERVAL; 47 extern const int STRONG_AND_STABLE_WRITABLE_CONNECTION_PING_INTERVAL;
48 static const int MIN_PINGS_AT_WEAK_PING_INTERVAL = 3; 48 static const int MIN_PINGS_AT_WEAK_PING_INTERVAL = 3;
49 49
50 // Adds the port on which the candidate originated. 50 // Adds the port on which the candidate originated.
51 class RemoteCandidate : public Candidate { 51 class RemoteCandidate : public Candidate {
52 public: 52 public:
53 RemoteCandidate(const Candidate& c, PortInterface* origin_port) 53 RemoteCandidate(const Candidate& c, PortInterface* origin_port)
54 : Candidate(c), origin_port_(origin_port) {} 54 : Candidate(c), origin_port_(origin_port) {}
55 55
56 PortInterface* origin_port() { return origin_port_; } 56 PortInterface* origin_port() { return origin_port_; }
57 57
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 bool CreateConnection(PortInterface* port, 254 bool CreateConnection(PortInterface* port,
255 const Candidate& remote_candidate, 255 const Candidate& remote_candidate,
256 PortInterface* origin_port); 256 PortInterface* origin_port);
257 bool FindConnection(cricket::Connection* connection) const; 257 bool FindConnection(cricket::Connection* connection) const;
258 258
259 uint32_t GetRemoteCandidateGeneration(const Candidate& candidate); 259 uint32_t GetRemoteCandidateGeneration(const Candidate& candidate);
260 bool IsDuplicateRemoteCandidate(const Candidate& candidate); 260 bool IsDuplicateRemoteCandidate(const Candidate& candidate);
261 void RememberRemoteCandidate(const Candidate& remote_candidate, 261 void RememberRemoteCandidate(const Candidate& remote_candidate,
262 PortInterface* origin_port); 262 PortInterface* origin_port);
263 bool IsPingable(const Connection* conn, int64_t now) const; 263 bool IsPingable(const Connection* conn, int64_t now) const;
264 bool IsSelectedConnectionPingable(int64_t now); 264 // Whether a premier connection is pingable, where a premier connection is
265 // the top-ranked connection on each network.
266 bool IsPremierConnectionPingable(Connection* premier_conn, int64_t now);
265 int CalculateActiveWritablePingInterval(const Connection* conn, 267 int CalculateActiveWritablePingInterval(const Connection* conn,
266 int64_t now) const; 268 int64_t now) const;
267 void PingConnection(Connection* conn); 269 void PingConnection(Connection* conn);
268 void AddAllocatorSession(std::unique_ptr<PortAllocatorSession> session); 270 void AddAllocatorSession(std::unique_ptr<PortAllocatorSession> session);
269 void AddConnection(Connection* connection); 271 void AddConnection(Connection* connection);
270 272
271 void OnPortReady(PortAllocatorSession *session, PortInterface* port); 273 void OnPortReady(PortAllocatorSession *session, PortInterface* port);
272 void OnPortsPruned(PortAllocatorSession* session, 274 void OnPortsPruned(PortAllocatorSession* session,
273 const std::vector<PortInterface*>& ports); 275 const std::vector<PortInterface*>& ports);
274 void OnCandidatesReady(PortAllocatorSession *session, 276 void OnCandidatesReady(PortAllocatorSession *session,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // Returns true if we should switch to the new connection. 312 // Returns true if we should switch to the new connection.
311 // sets |missed_receiving_unchanged_threshold| to true if either 313 // sets |missed_receiving_unchanged_threshold| to true if either
312 // the selected connection or the new connection missed its 314 // the selected connection or the new connection missed its
313 // receiving-unchanged-threshold. 315 // receiving-unchanged-threshold.
314 bool ShouldSwitchSelectedConnection( 316 bool ShouldSwitchSelectedConnection(
315 Connection* new_connection, 317 Connection* new_connection,
316 bool* missed_receiving_unchanged_threshold) const; 318 bool* missed_receiving_unchanged_threshold) const;
317 // Returns true if the new_connection is selected for transmission. 319 // Returns true if the new_connection is selected for transmission.
318 bool MaybeSwitchSelectedConnection(Connection* new_connection, 320 bool MaybeSwitchSelectedConnection(Connection* new_connection,
319 const std::string& reason); 321 const std::string& reason);
320 322 // Gets all premier connections on all networks.
323 std::map<rtc::Network*, Connection*> GetPremierConnectionsByNetwork() const;
321 void PruneConnections(); 324 void PruneConnections();
322 bool IsBackupConnection(const Connection* conn) const; 325 bool IsBackupConnection(const Connection* conn) const;
323 326
324 Connection* FindConnectionToPing(int64_t now); 327 Connection* FindConnectionToPing(int64_t now);
325 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now); 328 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now);
329 // Finds the best premier connection for pinging.
pthatcher1 2016/10/24 20:49:05 I find this confusing since "best" and "premier" a
honghaiz3 2016/10/24 23:35:09 Removed this method base on another suggestion.
330 Connection* FindBestPremierConnectionToPing(int64_t now);
326 // Between |conn1| and |conn2|, this function returns the one which should 331 // Between |conn1| and |conn2|, this function returns the one which should
327 // be pinged first. 332 // be pinged first.
328 Connection* SelectMostPingableConnection(Connection* conn1, 333 Connection* SelectMostPingableConnection(Connection* conn1,
329 Connection* conn2); 334 Connection* conn2);
330 // Select the connection which is Relay/Relay. If both of them are, 335 // Select the connection which is Relay/Relay. If both of them are,
331 // UDP relay protocol takes precedence. 336 // UDP relay protocol takes precedence.
332 Connection* MostLikelyToWork(Connection* conn1, Connection* conn2); 337 Connection* MostLikelyToWork(Connection* conn1, Connection* conn2);
333 // Compare the last_ping_sent time and return the one least recently pinged. 338 // Compare the last_ping_sent time and return the one least recently pinged.
334 Connection* LeastRecentlyPinged(Connection* conn1, Connection* conn2); 339 Connection* LeastRecentlyPinged(Connection* conn1, Connection* conn2);
335 340
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 uint32_t nomination_ = 0; 405 uint32_t nomination_ = 0;
401 406
402 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; 407 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr;
403 408
404 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); 409 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel);
405 }; 410 };
406 411
407 } // namespace cricket 412 } // namespace cricket
408 413
409 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ 414 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698