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

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

Issue 2143653005: Dampening connection switch. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 int generation); 583 int generation);
584 584
585 // If |remote_candidate_| is peer reflexive and is equivalent to 585 // If |remote_candidate_| is peer reflexive and is equivalent to
586 // |new_candidate| except the type, update |remote_candidate_| to 586 // |new_candidate| except the type, update |remote_candidate_| to
587 // |new_candidate|. 587 // |new_candidate|.
588 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate); 588 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate);
589 589
590 // Returns the last received time of any data, stun request, or stun 590 // Returns the last received time of any data, stun request, or stun
591 // response in milliseconds 591 // response in milliseconds
592 int64_t last_received() const; 592 int64_t last_received() const;
593 // Returns the last time when the connection changed its receiving state.
594 int64_t receiving_unchanged_since() const {
595 return receiving_unchanged_since_;
596 }
593 597
594 bool stable(int64_t now) const; 598 bool stable(int64_t now) const;
595 599
596 protected: 600 protected:
597 enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE }; 601 enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE };
598 602
599 // Constructs a new connection to the given remote port. 603 // Constructs a new connection to the given remote port.
600 Connection(Port* port, size_t index, const Candidate& candidate); 604 Connection(Port* port, size_t index, const Candidate& candidate);
601 605
602 // Called back when StunRequestManager has a stun packet to send 606 // Called back when StunRequestManager has a stun packet to send
603 void OnSendStunPacket(const void* data, size_t size, StunRequest* req); 607 void OnSendStunPacket(const void* data, size_t size, StunRequest* req);
604 608
605 // Callbacks from ConnectionRequest 609 // Callbacks from ConnectionRequest
606 virtual void OnConnectionRequestResponse(ConnectionRequest* req, 610 virtual void OnConnectionRequestResponse(ConnectionRequest* req,
607 StunMessage* response); 611 StunMessage* response);
608 void OnConnectionRequestErrorResponse(ConnectionRequest* req, 612 void OnConnectionRequestErrorResponse(ConnectionRequest* req,
609 StunMessage* response); 613 StunMessage* response);
610 void OnConnectionRequestTimeout(ConnectionRequest* req); 614 void OnConnectionRequestTimeout(ConnectionRequest* req);
611 void OnConnectionRequestSent(ConnectionRequest* req); 615 void OnConnectionRequestSent(ConnectionRequest* req);
612 616
613 bool rtt_converged() const; 617 bool rtt_converged() const;
614 618
615 // If the response is not received within 2 * RTT, the response is assumed to 619 // If the response is not received within 2 * RTT, the response is assumed to
616 // be missing. 620 // be missing.
617 bool missing_responses(int64_t now) const; 621 bool missing_responses(int64_t now) const;
618 622
619 // Changes the state and signals if necessary. 623 // Changes the state and signals if necessary.
620 void set_write_state(WriteState value); 624 void set_write_state(WriteState value);
621 void set_receiving(bool value); 625 void UpdateReceiving(int64_t now);
622 void set_state(State state); 626 void set_state(State state);
623 void set_connected(bool value); 627 void set_connected(bool value);
624 628
625 void OnMessage(rtc::Message *pmsg); 629 void OnMessage(rtc::Message *pmsg);
626 630
627 Port* port_; 631 Port* port_;
628 size_t local_candidate_index_; 632 size_t local_candidate_index_;
629 Candidate remote_candidate_; 633 Candidate remote_candidate_;
630 WriteState write_state_; 634 WriteState write_state_;
631 bool receiving_; 635 bool receiving_;
632 bool connected_; 636 bool connected_;
633 bool pruned_; 637 bool pruned_;
634 // By default |use_candidate_attr_| flag will be true, 638 // By default |use_candidate_attr_| flag will be true,
635 // as we will be using aggressive nomination. 639 // as we will be using aggressive nomination.
636 // But when peer is ice-lite, this flag "must" be initialized to false and 640 // But when peer is ice-lite, this flag "must" be initialized to false and
637 // turn on when connection becomes "best connection". 641 // turn on when connection becomes "best connection".
638 bool use_candidate_attr_; 642 bool use_candidate_attr_;
639 // Whether this connection has been nominated by the controlling side via 643 // Whether this connection has been nominated by the controlling side via
640 // the use_candidate attribute. 644 // the use_candidate attribute.
641 bool nominated_; 645 bool nominated_;
642 IceMode remote_ice_mode_; 646 IceMode remote_ice_mode_;
643 StunRequestManager requests_; 647 StunRequestManager requests_;
644 int rtt_; 648 int rtt_;
645 int rtt_samples_ = 0; 649 int rtt_samples_ = 0;
646 int64_t last_ping_sent_; // last time we sent a ping to the other side 650 int64_t last_ping_sent_; // last time we sent a ping to the other side
647 int64_t last_ping_received_; // last time we received a ping from the other 651 int64_t last_ping_received_; // last time we received a ping from the other
648 // side 652 // side
649 int64_t last_data_received_; 653 int64_t last_data_received_;
650 int64_t last_ping_response_received_; 654 int64_t last_ping_response_received_;
655 int64_t receiving_unchanged_since_ = 0;
651 std::vector<SentPing> pings_since_last_response_; 656 std::vector<SentPing> pings_since_last_response_;
652 657
653 rtc::RateTracker recv_rate_tracker_; 658 rtc::RateTracker recv_rate_tracker_;
654 rtc::RateTracker send_rate_tracker_; 659 rtc::RateTracker send_rate_tracker_;
655 660
656 ConnectionInfo stats_; 661 ConnectionInfo stats_;
657 662
658 private: 663 private:
659 void MaybeAddPrflxCandidate(ConnectionRequest* request, 664 void MaybeAddPrflxCandidate(ConnectionRequest* request,
660 StunMessage* response); 665 StunMessage* response);
(...skipping 19 matching lines...) Expand all
680 const rtc::PacketOptions& options) override; 685 const rtc::PacketOptions& options) override;
681 int GetError() override { return error_; } 686 int GetError() override { return error_; }
682 687
683 private: 688 private:
684 int error_ = 0; 689 int error_ = 0;
685 }; 690 };
686 691
687 } // namespace cricket 692 } // namespace cricket
688 693
689 #endif // WEBRTC_P2P_BASE_PORT_H_ 694 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698