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

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

Issue 2369963004: Ping the premier connection on each network with higher priority. (Closed)
Patch Set: . Created 4 years, 2 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 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 bool CreateConnection(PortInterface* port, 249 bool CreateConnection(PortInterface* port,
250 const Candidate& remote_candidate, 250 const Candidate& remote_candidate,
251 PortInterface* origin_port); 251 PortInterface* origin_port);
252 bool FindConnection(cricket::Connection* connection) const; 252 bool FindConnection(cricket::Connection* connection) const;
253 253
254 uint32_t GetRemoteCandidateGeneration(const Candidate& candidate); 254 uint32_t GetRemoteCandidateGeneration(const Candidate& candidate);
255 bool IsDuplicateRemoteCandidate(const Candidate& candidate); 255 bool IsDuplicateRemoteCandidate(const Candidate& candidate);
256 void RememberRemoteCandidate(const Candidate& remote_candidate, 256 void RememberRemoteCandidate(const Candidate& remote_candidate,
257 PortInterface* origin_port); 257 PortInterface* origin_port);
258 bool IsPingable(const Connection* conn, int64_t now) const; 258 bool IsPingable(const Connection* conn, int64_t now) const;
259 bool IsSelectedConnectionPingable(int64_t now); 259 bool IsPremierConnectionPingable(Connection* conn, int64_t now);
Taylor Brandstetter 2016/10/04 02:08:10 Can you explain in a comment somewhere what's mean
honghaiz3 2016/10/20 23:47:58 Done.
260 int CalculateActiveWritablePingInterval(const Connection* conn, 260 int CalculateActiveWritablePingInterval(const Connection* conn,
261 int64_t now) const; 261 int64_t now) const;
262 void PingConnection(Connection* conn); 262 void PingConnection(Connection* conn);
263 void AddAllocatorSession(std::unique_ptr<PortAllocatorSession> session); 263 void AddAllocatorSession(std::unique_ptr<PortAllocatorSession> session);
264 void AddConnection(Connection* connection); 264 void AddConnection(Connection* connection);
265 265
266 void OnPortReady(PortAllocatorSession *session, PortInterface* port); 266 void OnPortReady(PortAllocatorSession *session, PortInterface* port);
267 void OnPortsPruned(PortAllocatorSession* session, 267 void OnPortsPruned(PortAllocatorSession* session,
268 const std::vector<PortInterface*>& ports); 268 const std::vector<PortInterface*>& ports);
269 void OnCandidatesReady(PortAllocatorSession *session, 269 void OnCandidatesReady(PortAllocatorSession *session,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // Returns true if we should switch to the new connection. 305 // Returns true if we should switch to the new connection.
306 // sets |missed_receiving_unchanged_threshold| to true if either 306 // sets |missed_receiving_unchanged_threshold| to true if either
307 // the selected connection or the new connection missed its 307 // the selected connection or the new connection missed its
308 // receiving-unchanged-threshold. 308 // receiving-unchanged-threshold.
309 bool ShouldSwitchSelectedConnection( 309 bool ShouldSwitchSelectedConnection(
310 Connection* new_connection, 310 Connection* new_connection,
311 bool* missed_receiving_unchanged_threshold) const; 311 bool* missed_receiving_unchanged_threshold) const;
312 // Returns true if the new_connection is selected for transmission. 312 // Returns true if the new_connection is selected for transmission.
313 bool MaybeSwitchSelectedConnection(Connection* new_connection, 313 bool MaybeSwitchSelectedConnection(Connection* new_connection,
314 const std::string& reason); 314 const std::string& reason);
315 315 // Updates the premier connection for each network name. This method is
316 // called every time after connections are sorted.
317 void UpdatePremierConnections();
316 void PruneConnections(); 318 void PruneConnections();
317 bool IsBackupConnection(const Connection* conn) const; 319 bool IsBackupConnection(const Connection* conn) const;
318 320
319 Connection* FindConnectionToPing(int64_t now); 321 Connection* FindConnectionToPing(int64_t now);
320 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now); 322 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now);
323 // Finds the best premier connection for pinging.
324 Connection* FindBestPremierConnectionToPing(int64_t now);
321 // Between |conn1| and |conn2|, this function returns the one which should 325 // Between |conn1| and |conn2|, this function returns the one which should
322 // be pinged first. 326 // be pinged first.
323 Connection* SelectMostPingableConnection(Connection* conn1, 327 Connection* SelectMostPingableConnection(Connection* conn1,
324 Connection* conn2); 328 Connection* conn2);
325 // Select the connection which is Relay/Relay. If both of them are, 329 // Select the connection which is Relay/Relay. If both of them are,
326 // UDP relay protocol takes precedence. 330 // UDP relay protocol takes precedence.
327 Connection* MostLikelyToWork(Connection* conn1, Connection* conn2); 331 Connection* MostLikelyToWork(Connection* conn1, Connection* conn2);
328 // Compare the last_ping_sent time and return the one least recently pinged. 332 // Compare the last_ping_sent time and return the one least recently pinged.
329 Connection* LeastRecentlyPinged(Connection* conn1, Connection* conn2); 333 Connection* LeastRecentlyPinged(Connection* conn1, Connection* conn2);
330 334
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // |connections_| is a sorted list with the first one always be the 367 // |connections_| is a sorted list with the first one always be the
364 // |selected_connection_| when it's not nullptr. The combination of 368 // |selected_connection_| when it's not nullptr. The combination of
365 // |pinged_connections_| and |unpinged_connections_| has the same 369 // |pinged_connections_| and |unpinged_connections_| has the same
366 // connections as |connections_|. These 2 sets maintain whether a 370 // connections as |connections_|. These 2 sets maintain whether a
367 // connection should be pinged next or not. 371 // connection should be pinged next or not.
368 std::vector<Connection *> connections_; 372 std::vector<Connection *> connections_;
369 std::set<Connection*> pinged_connections_; 373 std::set<Connection*> pinged_connections_;
370 std::set<Connection*> unpinged_connections_; 374 std::set<Connection*> unpinged_connections_;
371 375
372 Connection* selected_connection_ = nullptr; 376 Connection* selected_connection_ = nullptr;
377 // The top-ranked connection for each network interface, identified by the
378 // interface name.
379 std::map<std::string, Connection*> premier_connection_by_network_name_;
Taylor Brandstetter 2016/10/04 02:08:10 Can't this be determined algorithmically from conn
honghaiz3 2016/10/20 23:47:58 Done.
373 380
374 std::vector<RemoteCandidate> remote_candidates_; 381 std::vector<RemoteCandidate> remote_candidates_;
375 bool sort_dirty_; // indicates whether another sort is needed right now 382 bool sort_dirty_; // indicates whether another sort is needed right now
376 bool had_connection_ = false; // if connections_ has ever been nonempty 383 bool had_connection_ = false; // if connections_ has ever been nonempty
377 typedef std::map<rtc::Socket::Option, int> OptionMap; 384 typedef std::map<rtc::Socket::Option, int> OptionMap;
378 OptionMap options_; 385 OptionMap options_;
379 IceParameters ice_parameters_; 386 IceParameters ice_parameters_;
380 std::vector<IceParameters> remote_ice_parameters_; 387 std::vector<IceParameters> remote_ice_parameters_;
381 IceMode remote_ice_mode_; 388 IceMode remote_ice_mode_;
382 IceRole ice_role_; 389 IceRole ice_role_;
(...skipping 10 matching lines...) Expand all
393 // The value put in the "nomination" attribute for the next nominated 400 // The value put in the "nomination" attribute for the next nominated
394 // connection. A zero-value indicates the connection will not be nominated. 401 // connection. A zero-value indicates the connection will not be nominated.
395 uint32_t nomination_ = 0; 402 uint32_t nomination_ = 0;
396 403
397 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); 404 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel);
398 }; 405 };
399 406
400 } // namespace cricket 407 } // namespace cricket
401 408
402 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ 409 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698