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

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

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 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
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.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 12 matching lines...) Expand all
23 namespace { 23 namespace {
24 24
25 // messages for queuing up work for ourselves 25 // messages for queuing up work for ourselves
26 enum { MSG_SORT = 1, MSG_CHECK_AND_PING }; 26 enum { MSG_SORT = 1, MSG_CHECK_AND_PING };
27 27
28 // When the socket is unwritable, we will use 10 Kbps (ignoring IP+UDP headers) 28 // When the socket is unwritable, we will use 10 Kbps (ignoring IP+UDP headers)
29 // for pinging. When the socket is writable, we will use only 1 Kbps because 29 // for pinging. When the socket is writable, we will use only 1 Kbps because
30 // we don't want to degrade the quality on a modem. These numbers should work 30 // we don't want to degrade the quality on a modem. These numbers should work
31 // well on a 28.8K modem, which is the slowest connection on which the voice 31 // well on a 28.8K modem, which is the slowest connection on which the voice
32 // quality is reasonable at all. 32 // quality is reasonable at all.
33 static const uint32 PING_PACKET_SIZE = 60 * 8; 33 static const uint32_t PING_PACKET_SIZE = 60 * 8;
34 // STRONG_PING_DELAY (480ms) is applied when the best connection is both 34 // STRONG_PING_DELAY (480ms) is applied when the best connection is both
35 // writable and receiving. 35 // writable and receiving.
36 static const uint32 STRONG_PING_DELAY = 1000 * PING_PACKET_SIZE / 1000; 36 static const uint32_t STRONG_PING_DELAY = 1000 * PING_PACKET_SIZE / 1000;
37 // WEAK_PING_DELAY (48ms) is applied when the best connection is either not 37 // WEAK_PING_DELAY (48ms) is applied when the best connection is either not
38 // writable or not receiving. 38 // writable or not receiving.
39 static const uint32 WEAK_PING_DELAY = 1000 * PING_PACKET_SIZE / 10000; 39 static const uint32_t WEAK_PING_DELAY = 1000 * PING_PACKET_SIZE / 10000;
40 40
41 // If the current best connection is both writable and receiving, then we will 41 // If the current best connection is both writable and receiving, then we will
42 // also try hard to make sure it is pinged at this rate (a little less than 42 // also try hard to make sure it is pinged at this rate (a little less than
43 // 2 * STRONG_PING_DELAY). 43 // 2 * STRONG_PING_DELAY).
44 static const uint32 MAX_CURRENT_STRONG_DELAY = 900; 44 static const uint32_t MAX_CURRENT_STRONG_DELAY = 900;
45 45
46 static const int MIN_CHECK_RECEIVING_DELAY = 50; // ms 46 static const int MIN_CHECK_RECEIVING_DELAY = 50; // ms
47 47
48 // The minimum improvement in RTT that justifies a switch. 48 // The minimum improvement in RTT that justifies a switch.
49 static const double kMinImprovement = 10; 49 static const double kMinImprovement = 10;
50 50
51 cricket::PortInterface::CandidateOrigin GetOrigin(cricket::PortInterface* port, 51 cricket::PortInterface::CandidateOrigin GetOrigin(cricket::PortInterface* port,
52 cricket::PortInterface* origin_port) { 52 cricket::PortInterface* origin_port) {
53 if (!origin_port) 53 if (!origin_port)
54 return cricket::PortInterface::ORIGIN_MESSAGE; 54 return cricket::PortInterface::ORIGIN_MESSAGE;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 ice_role_(ICEROLE_UNKNOWN), 218 ice_role_(ICEROLE_UNKNOWN),
219 tiebreaker_(0), 219 tiebreaker_(0),
220 remote_candidate_generation_(0), 220 remote_candidate_generation_(0),
221 gathering_state_(kIceGatheringNew), 221 gathering_state_(kIceGatheringNew),
222 check_receiving_delay_(MIN_CHECK_RECEIVING_DELAY * 5), 222 check_receiving_delay_(MIN_CHECK_RECEIVING_DELAY * 5),
223 receiving_timeout_(MIN_CHECK_RECEIVING_DELAY * 50) {} 223 receiving_timeout_(MIN_CHECK_RECEIVING_DELAY * 50) {}
224 224
225 P2PTransportChannel::~P2PTransportChannel() { 225 P2PTransportChannel::~P2PTransportChannel() {
226 ASSERT(worker_thread_ == rtc::Thread::Current()); 226 ASSERT(worker_thread_ == rtc::Thread::Current());
227 227
228 for (uint32 i = 0; i < allocator_sessions_.size(); ++i) 228 for (size_t i = 0; i < allocator_sessions_.size(); ++i)
229 delete allocator_sessions_[i]; 229 delete allocator_sessions_[i];
230 } 230 }
231 231
232 // Add the allocator session to our list so that we know which sessions 232 // Add the allocator session to our list so that we know which sessions
233 // are still active. 233 // are still active.
234 void P2PTransportChannel::AddAllocatorSession(PortAllocatorSession* session) { 234 void P2PTransportChannel::AddAllocatorSession(PortAllocatorSession* session) {
235 session->set_generation(static_cast<uint32>(allocator_sessions_.size())); 235 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size()));
236 allocator_sessions_.push_back(session); 236 allocator_sessions_.push_back(session);
237 237
238 // We now only want to apply new candidates that we receive to the ports 238 // We now only want to apply new candidates that we receive to the ports
239 // created by this new session because these are replacing those of the 239 // created by this new session because these are replacing those of the
240 // previous sessions. 240 // previous sessions.
241 ports_.clear(); 241 ports_.clear();
242 242
243 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady); 243 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady);
244 session->SignalCandidatesReady.connect( 244 session->SignalCandidatesReady.connect(
245 this, &P2PTransportChannel::OnCandidatesReady); 245 this, &P2PTransportChannel::OnCandidatesReady);
(...skipping 22 matching lines...) Expand all
268 ASSERT(worker_thread_ == rtc::Thread::Current()); 268 ASSERT(worker_thread_ == rtc::Thread::Current());
269 if (ice_role_ != ice_role) { 269 if (ice_role_ != ice_role) {
270 ice_role_ = ice_role; 270 ice_role_ = ice_role;
271 for (std::vector<PortInterface *>::iterator it = ports_.begin(); 271 for (std::vector<PortInterface *>::iterator it = ports_.begin();
272 it != ports_.end(); ++it) { 272 it != ports_.end(); ++it) {
273 (*it)->SetIceRole(ice_role); 273 (*it)->SetIceRole(ice_role);
274 } 274 }
275 } 275 }
276 } 276 }
277 277
278 void P2PTransportChannel::SetIceTiebreaker(uint64 tiebreaker) { 278 void P2PTransportChannel::SetIceTiebreaker(uint64_t tiebreaker) {
279 ASSERT(worker_thread_ == rtc::Thread::Current()); 279 ASSERT(worker_thread_ == rtc::Thread::Current());
280 if (!ports_.empty()) { 280 if (!ports_.empty()) {
281 LOG(LS_ERROR) 281 LOG(LS_ERROR)
282 << "Attempt to change tiebreaker after Port has been allocated."; 282 << "Attempt to change tiebreaker after Port has been allocated.";
283 return; 283 return;
284 } 284 }
285 285
286 tiebreaker_ = tiebreaker; 286 tiebreaker_ = tiebreaker;
287 } 287 }
288 288
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 // existing remote candidates, it represents a new peer reflexive remote 546 // existing remote candidates, it represents a new peer reflexive remote
547 // candidate. 547 // candidate.
548 remote_candidate = 548 remote_candidate =
549 Candidate(component(), ProtoToString(proto), address, 0, 549 Candidate(component(), ProtoToString(proto), address, 0,
550 remote_username, remote_password, PRFLX_PORT_TYPE, 0U, ""); 550 remote_username, remote_password, PRFLX_PORT_TYPE, 0U, "");
551 551
552 // From RFC 5245, section-7.2.1.3: 552 // From RFC 5245, section-7.2.1.3:
553 // The foundation of the candidate is set to an arbitrary value, different 553 // The foundation of the candidate is set to an arbitrary value, different
554 // from the foundation for all other remote candidates. 554 // from the foundation for all other remote candidates.
555 remote_candidate.set_foundation( 555 remote_candidate.set_foundation(
556 rtc::ToString<uint32>(rtc::ComputeCrc32(remote_candidate.id()))); 556 rtc::ToString<uint32_t>(rtc::ComputeCrc32(remote_candidate.id())));
557 557
558 remote_candidate.set_priority(remote_candidate_priority); 558 remote_candidate.set_priority(remote_candidate_priority);
559 } 559 }
560 560
561 // RFC5245, the agent constructs a pair whose local candidate is equal to 561 // RFC5245, the agent constructs a pair whose local candidate is equal to
562 // the transport address on which the STUN request was received, and a 562 // the transport address on which the STUN request was received, and a
563 // remote candidate equal to the source transport address where the 563 // remote candidate equal to the source transport address where the
564 // request came from. 564 // request came from.
565 565
566 // There shouldn't be an existing connection with this remote address. 566 // There shouldn't be an existing connection with this remote address.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } else { 631 } else {
632 LOG(LS_INFO) << "Not switching the best connection on controlled side yet," 632 LOG(LS_INFO) << "Not switching the best connection on controlled side yet,"
633 << " because it's not writable: " << conn->ToString(); 633 << " because it's not writable: " << conn->ToString();
634 pending_best_connection_ = conn; 634 pending_best_connection_ = conn;
635 } 635 }
636 } 636 }
637 637
638 void P2PTransportChannel::AddRemoteCandidate(const Candidate& candidate) { 638 void P2PTransportChannel::AddRemoteCandidate(const Candidate& candidate) {
639 ASSERT(worker_thread_ == rtc::Thread::Current()); 639 ASSERT(worker_thread_ == rtc::Thread::Current());
640 640
641 uint32 generation = candidate.generation(); 641 uint32_t generation = candidate.generation();
642 // Network may not guarantee the order of the candidate delivery. If a 642 // Network may not guarantee the order of the candidate delivery. If a
643 // remote candidate with an older generation arrives, drop it. 643 // remote candidate with an older generation arrives, drop it.
644 if (generation != 0 && generation < remote_candidate_generation_) { 644 if (generation != 0 && generation < remote_candidate_generation_) {
645 LOG(LS_WARNING) << "Dropping a remote candidate because its generation " 645 LOG(LS_WARNING) << "Dropping a remote candidate because its generation "
646 << generation 646 << generation
647 << " is lower than the current remote generation " 647 << " is lower than the current remote generation "
648 << remote_candidate_generation_; 648 << remote_candidate_generation_;
649 return; 649 return;
650 } 650 }
651 651
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 return true; 758 return true;
759 } 759 }
760 760
761 bool P2PTransportChannel::FindConnection( 761 bool P2PTransportChannel::FindConnection(
762 cricket::Connection* connection) const { 762 cricket::Connection* connection) const {
763 std::vector<Connection*>::const_iterator citer = 763 std::vector<Connection*>::const_iterator citer =
764 std::find(connections_.begin(), connections_.end(), connection); 764 std::find(connections_.begin(), connections_.end(), connection);
765 return citer != connections_.end(); 765 return citer != connections_.end();
766 } 766 }
767 767
768 uint32 P2PTransportChannel::GetRemoteCandidateGeneration( 768 uint32_t P2PTransportChannel::GetRemoteCandidateGeneration(
769 const Candidate& candidate) { 769 const Candidate& candidate) {
770 // We need to keep track of the remote ice restart so newer 770 // We need to keep track of the remote ice restart so newer
771 // connections are prioritized over the older. 771 // connections are prioritized over the older.
772 ASSERT(candidate.generation() == 0 || 772 ASSERT(candidate.generation() == 0 ||
773 candidate.generation() == remote_candidate_generation_); 773 candidate.generation() == remote_candidate_generation_);
774 return remote_candidate_generation_; 774 return remote_candidate_generation_;
775 } 775 }
776 776
777 // Check if remote candidate is already cached. 777 // Check if remote candidate is already cached.
778 bool P2PTransportChannel::IsDuplicateRemoteCandidate( 778 bool P2PTransportChannel::IsDuplicateRemoteCandidate(
779 const Candidate& candidate) { 779 const Candidate& candidate) {
780 for (uint32 i = 0; i < remote_candidates_.size(); ++i) { 780 for (size_t i = 0; i < remote_candidates_.size(); ++i) {
781 if (remote_candidates_[i].IsEquivalent(candidate)) { 781 if (remote_candidates_[i].IsEquivalent(candidate)) {
782 return true; 782 return true;
783 } 783 }
784 } 784 }
785 return false; 785 return false;
786 } 786 }
787 787
788 // Maintain our remote candidate list, adding this new remote one. 788 // Maintain our remote candidate list, adding this new remote one.
789 void P2PTransportChannel::RememberRemoteCandidate( 789 void P2PTransportChannel::RememberRemoteCandidate(
790 const Candidate& remote_candidate, PortInterface* origin_port) { 790 const Candidate& remote_candidate, PortInterface* origin_port) {
791 // Remove any candidates whose generation is older than this one. The 791 // Remove any candidates whose generation is older than this one. The
792 // presence of a new generation indicates that the old ones are not useful. 792 // presence of a new generation indicates that the old ones are not useful.
793 uint32 i = 0; 793 size_t i = 0;
794 while (i < remote_candidates_.size()) { 794 while (i < remote_candidates_.size()) {
795 if (remote_candidates_[i].generation() < remote_candidate.generation()) { 795 if (remote_candidates_[i].generation() < remote_candidate.generation()) {
796 LOG(INFO) << "Pruning candidate from old generation: " 796 LOG(INFO) << "Pruning candidate from old generation: "
797 << remote_candidates_[i].address().ToSensitiveString(); 797 << remote_candidates_[i].address().ToSensitiveString();
798 remote_candidates_.erase(remote_candidates_.begin() + i); 798 remote_candidates_.erase(remote_candidates_.begin() + i);
799 } else { 799 } else {
800 i += 1; 800 i += 1;
801 } 801 }
802 } 802 }
803 803
(...skipping 13 matching lines...) Expand all
817 ASSERT(worker_thread_ == rtc::Thread::Current()); 817 ASSERT(worker_thread_ == rtc::Thread::Current());
818 OptionMap::iterator it = options_.find(opt); 818 OptionMap::iterator it = options_.find(opt);
819 if (it == options_.end()) { 819 if (it == options_.end()) {
820 options_.insert(std::make_pair(opt, value)); 820 options_.insert(std::make_pair(opt, value));
821 } else if (it->second == value) { 821 } else if (it->second == value) {
822 return 0; 822 return 0;
823 } else { 823 } else {
824 it->second = value; 824 it->second = value;
825 } 825 }
826 826
827 for (uint32 i = 0; i < ports_.size(); ++i) { 827 for (size_t i = 0; i < ports_.size(); ++i) {
828 int val = ports_[i]->SetOption(opt, value); 828 int val = ports_[i]->SetOption(opt, value);
829 if (val < 0) { 829 if (val < 0) {
830 // Because this also occurs deferred, probably no point in reporting an 830 // Because this also occurs deferred, probably no point in reporting an
831 // error 831 // error
832 LOG(WARNING) << "SetOption(" << opt << ", " << value << ") failed: " 832 LOG(WARNING) << "SetOption(" << opt << ", " << value << ") failed: "
833 << ports_[i]->GetError(); 833 << ports_[i]->GetError();
834 } 834 }
835 } 835 }
836 return 0; 836 return 0;
837 } 837 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 rtc::DiffServCodePoint P2PTransportChannel::DefaultDscpValue() const { 904 rtc::DiffServCodePoint P2PTransportChannel::DefaultDscpValue() const {
905 OptionMap::const_iterator it = options_.find(rtc::Socket::OPT_DSCP); 905 OptionMap::const_iterator it = options_.find(rtc::Socket::OPT_DSCP);
906 if (it == options_.end()) { 906 if (it == options_.end()) {
907 return rtc::DSCP_NO_CHANGE; 907 return rtc::DSCP_NO_CHANGE;
908 } 908 }
909 return static_cast<rtc::DiffServCodePoint> (it->second); 909 return static_cast<rtc::DiffServCodePoint> (it->second);
910 } 910 }
911 911
912 // Monitor connection states. 912 // Monitor connection states.
913 void P2PTransportChannel::UpdateConnectionStates() { 913 void P2PTransportChannel::UpdateConnectionStates() {
914 uint32 now = rtc::Time(); 914 uint32_t now = rtc::Time();
915 915
916 // We need to copy the list of connections since some may delete themselves 916 // We need to copy the list of connections since some may delete themselves
917 // when we call UpdateState. 917 // when we call UpdateState.
918 for (uint32 i = 0; i < connections_.size(); ++i) 918 for (size_t i = 0; i < connections_.size(); ++i)
919 connections_[i]->UpdateState(now); 919 connections_[i]->UpdateState(now);
920 } 920 }
921 921
922 // Prepare for best candidate sorting. 922 // Prepare for best candidate sorting.
923 void P2PTransportChannel::RequestSort() { 923 void P2PTransportChannel::RequestSort() {
924 if (!sort_dirty_) { 924 if (!sort_dirty_) {
925 worker_thread_->Post(this, MSG_SORT); 925 worker_thread_->Post(this, MSG_SORT);
926 sort_dirty_ = true; 926 sort_dirty_ = true;
927 } 927 }
928 } 928 }
(...skipping 11 matching lines...) Expand all
940 sort_dirty_ = false; 940 sort_dirty_ = false;
941 941
942 // Find the best alternative connection by sorting. It is important to note 942 // Find the best alternative connection by sorting. It is important to note
943 // that amongst equal preference, writable connections, this will choose the 943 // that amongst equal preference, writable connections, this will choose the
944 // one whose estimated latency is lowest. So it is the only one that we 944 // one whose estimated latency is lowest. So it is the only one that we
945 // need to consider switching to. 945 // need to consider switching to.
946 ConnectionCompare cmp; 946 ConnectionCompare cmp;
947 std::stable_sort(connections_.begin(), connections_.end(), cmp); 947 std::stable_sort(connections_.begin(), connections_.end(), cmp);
948 LOG(LS_VERBOSE) << "Sorting " << connections_.size() 948 LOG(LS_VERBOSE) << "Sorting " << connections_.size()
949 << " available connections:"; 949 << " available connections:";
950 for (uint32 i = 0; i < connections_.size(); ++i) { 950 for (size_t i = 0; i < connections_.size(); ++i) {
951 LOG(LS_VERBOSE) << connections_[i]->ToString(); 951 LOG(LS_VERBOSE) << connections_[i]->ToString();
952 } 952 }
953 953
954 Connection* top_connection = 954 Connection* top_connection =
955 (connections_.size() > 0) ? connections_[0] : nullptr; 955 (connections_.size() > 0) ? connections_[0] : nullptr;
956 956
957 // If necessary, switch to the new choice. 957 // If necessary, switch to the new choice.
958 // Note that |top_connection| doesn't have to be writable to become the best 958 // Note that |top_connection| doesn't have to be writable to become the best
959 // connection although it will have higher priority if it is writable. 959 // connection although it will have higher priority if it is writable.
960 if (ShouldSwitch(best_connection_, top_connection, ice_role_)) { 960 if (ShouldSwitch(best_connection_, top_connection, ice_role_)) {
961 LOG(LS_INFO) << "Switching best connection: " << top_connection->ToString(); 961 LOG(LS_INFO) << "Switching best connection: " << top_connection->ToString();
962 SwitchBestConnectionTo(top_connection); 962 SwitchBestConnectionTo(top_connection);
963 } 963 }
964 964
965 // Controlled side can prune only if the best connection has been nominated. 965 // Controlled side can prune only if the best connection has been nominated.
966 // because otherwise it may delete the connection that will be selected by 966 // because otherwise it may delete the connection that will be selected by
967 // the controlling side. 967 // the controlling side.
968 if (ice_role_ == ICEROLE_CONTROLLING || best_nominated_connection()) { 968 if (ice_role_ == ICEROLE_CONTROLLING || best_nominated_connection()) {
969 PruneConnections(); 969 PruneConnections();
970 } 970 }
971 971
972 // Check if all connections are timedout. 972 // Check if all connections are timedout.
973 bool all_connections_timedout = true; 973 bool all_connections_timedout = true;
974 for (uint32 i = 0; i < connections_.size(); ++i) { 974 for (size_t i = 0; i < connections_.size(); ++i) {
975 if (connections_[i]->write_state() != Connection::STATE_WRITE_TIMEOUT) { 975 if (connections_[i]->write_state() != Connection::STATE_WRITE_TIMEOUT) {
976 all_connections_timedout = false; 976 all_connections_timedout = false;
977 break; 977 break;
978 } 978 }
979 } 979 }
980 980
981 // Now update the writable state of the channel with the information we have 981 // Now update the writable state of the channel with the information we have
982 // so far. 982 // so far.
983 if (best_connection_ && best_connection_->writable()) { 983 if (best_connection_ && best_connection_->writable()) {
984 HandleWritable(); 984 HandleWritable();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1113
1114 // If we have a best connection, return it, otherwise return top one in the 1114 // If we have a best connection, return it, otherwise return top one in the
1115 // list (later we will mark it best). 1115 // list (later we will mark it best).
1116 Connection* P2PTransportChannel::GetBestConnectionOnNetwork( 1116 Connection* P2PTransportChannel::GetBestConnectionOnNetwork(
1117 rtc::Network* network) const { 1117 rtc::Network* network) const {
1118 // If the best connection is on this network, then it wins. 1118 // If the best connection is on this network, then it wins.
1119 if (best_connection_ && (best_connection_->port()->Network() == network)) 1119 if (best_connection_ && (best_connection_->port()->Network() == network))
1120 return best_connection_; 1120 return best_connection_;
1121 1121
1122 // Otherwise, we return the top-most in sorted order. 1122 // Otherwise, we return the top-most in sorted order.
1123 for (uint32 i = 0; i < connections_.size(); ++i) { 1123 for (size_t i = 0; i < connections_.size(); ++i) {
1124 if (connections_[i]->port()->Network() == network) 1124 if (connections_[i]->port()->Network() == network)
1125 return connections_[i]; 1125 return connections_[i];
1126 } 1126 }
1127 1127
1128 return NULL; 1128 return NULL;
1129 } 1129 }
1130 1130
1131 // Handle any queued up requests 1131 // Handle any queued up requests
1132 void P2PTransportChannel::OnMessage(rtc::Message *pmsg) { 1132 void P2PTransportChannel::OnMessage(rtc::Message *pmsg) {
1133 switch (pmsg->message_id) { 1133 switch (pmsg->message_id) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 return weak() || conn->write_state() != Connection::STATE_WRITE_TIMEOUT; 1191 return weak() || conn->write_state() != Connection::STATE_WRITE_TIMEOUT;
1192 } 1192 }
1193 1193
1194 // Returns the next pingable connection to ping. This will be the oldest 1194 // Returns the next pingable connection to ping. This will be the oldest
1195 // pingable connection unless we have a connected, writable connection that is 1195 // pingable connection unless we have a connected, writable connection that is
1196 // past the maximum acceptable ping delay. When reconnecting a TCP connection, 1196 // past the maximum acceptable ping delay. When reconnecting a TCP connection,
1197 // the best connection is disconnected, although still WRITABLE while 1197 // the best connection is disconnected, although still WRITABLE while
1198 // reconnecting. The newly created connection should be selected as the ping 1198 // reconnecting. The newly created connection should be selected as the ping
1199 // target to become writable instead. See the big comment in CompareConnections. 1199 // target to become writable instead. See the big comment in CompareConnections.
1200 Connection* P2PTransportChannel::FindNextPingableConnection() { 1200 Connection* P2PTransportChannel::FindNextPingableConnection() {
1201 uint32 now = rtc::Time(); 1201 uint32_t now = rtc::Time();
1202 if (best_connection_ && best_connection_->connected() && 1202 if (best_connection_ && best_connection_->connected() &&
1203 best_connection_->writable() && 1203 best_connection_->writable() &&
1204 (best_connection_->last_ping_sent() + MAX_CURRENT_STRONG_DELAY <= now)) { 1204 (best_connection_->last_ping_sent() + MAX_CURRENT_STRONG_DELAY <= now)) {
1205 return best_connection_; 1205 return best_connection_;
1206 } 1206 }
1207 1207
1208 // First, find "triggered checks". We ping first those connections 1208 // First, find "triggered checks". We ping first those connections
1209 // that have received a ping but have not sent a ping since receiving 1209 // that have received a ping but have not sent a ping since receiving
1210 // it (last_received_ping > last_sent_ping). But we shouldn't do 1210 // it (last_received_ping > last_sent_ping). But we shouldn't do
1211 // triggered checks if the connection is already writable. 1211 // triggered checks if the connection is already writable.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 } 1356 }
1357 } 1357 }
1358 1358
1359 void P2PTransportChannel::OnReadyToSend(Connection* connection) { 1359 void P2PTransportChannel::OnReadyToSend(Connection* connection) {
1360 if (connection == best_connection_ && writable()) { 1360 if (connection == best_connection_ && writable()) {
1361 SignalReadyToSend(this); 1361 SignalReadyToSend(this);
1362 } 1362 }
1363 } 1363 }
1364 1364
1365 } // namespace cricket 1365 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698