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_unittest.cc

Issue 2416023002: Introduce rtc::PacketTransportInterface and let cricket::TransportChannel inherit. (Closed)
Patch Set: Resolve unused variable issue in release build. 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 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 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
11 #include <algorithm> 11 #include <algorithm>
12 #include <memory> 12 #include <memory>
13 13
14 #include "webrtc/api/fakemetricsobserver.h" 14 #include "webrtc/api/fakemetricsobserver.h"
15 #include "webrtc/p2p/base/fakeportallocator.h" 15 #include "webrtc/p2p/base/fakeportallocator.h"
16 #include "webrtc/p2p/base/packettransport.h"
16 #include "webrtc/p2p/base/p2ptransportchannel.h" 17 #include "webrtc/p2p/base/p2ptransportchannel.h"
17 #include "webrtc/p2p/base/testrelayserver.h" 18 #include "webrtc/p2p/base/testrelayserver.h"
18 #include "webrtc/p2p/base/teststunserver.h" 19 #include "webrtc/p2p/base/teststunserver.h"
19 #include "webrtc/p2p/base/testturnserver.h" 20 #include "webrtc/p2p/base/testturnserver.h"
20 #include "webrtc/p2p/client/basicportallocator.h" 21 #include "webrtc/p2p/client/basicportallocator.h"
21 #include "webrtc/base/dscp.h" 22 #include "webrtc/base/dscp.h"
22 #include "webrtc/base/fakeclock.h" 23 #include "webrtc/base/fakeclock.h"
23 #include "webrtc/base/fakenetwork.h" 24 #include "webrtc/base/fakenetwork.h"
24 #include "webrtc/base/firewallsocketserver.h" 25 #include "webrtc/base/firewallsocketserver.h"
25 #include "webrtc/base/gunit.h" 26 #include "webrtc/base/gunit.h"
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 ep2_ch1()->receiving() && 664 ep2_ch1()->receiving() &&
664 ep2_ch1()->writable(), 665 ep2_ch1()->writable(),
665 1000); 666 1000);
666 667
667 EXPECT_TRUE(ep1_ch1()->selected_connection() && 668 EXPECT_TRUE(ep1_ch1()->selected_connection() &&
668 ep2_ch1()->selected_connection()); 669 ep2_ch1()->selected_connection());
669 670
670 TestSendRecv(); 671 TestSendRecv();
671 } 672 }
672 673
673 void OnReadyToSend(TransportChannel* ch) { 674 void OnReadyToSend(rtc::PacketTransport* pt) {
674 GetEndpoint(ch)->ready_to_send_ = true; 675 GetEndpoint(static_cast<TransportChannel*>(pt))->ready_to_send_ = true;
675 } 676 }
676 677
677 // We pass the candidates directly to the other side. 678 // We pass the candidates directly to the other side.
678 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) { 679 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) {
679 if (force_relay_ && c.type() != RELAY_PORT_TYPE) 680 if (force_relay_ && c.type() != RELAY_PORT_TYPE)
680 return; 681 return;
681 682
682 if (GetEndpoint(ch)->save_candidates_) { 683 if (GetEndpoint(ch)->save_candidates_) {
683 GetEndpoint(ch)->saved_candidates_.push_back( 684 GetEndpoint(ch)->saved_candidates_.push_back(
684 std::unique_ptr<CandidatesData>(new CandidatesData(ch, c))); 685 std::unique_ptr<CandidatesData>(new CandidatesData(ch, c)));
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 return; 771 return;
771 } 772 }
772 for (Candidate& c : data->candidates) { 773 for (Candidate& c : data->candidates) {
773 LOG(LS_INFO) << "Removed remote candidate " << c.ToString(); 774 LOG(LS_INFO) << "Removed remote candidate " << c.ToString();
774 rch->RemoveRemoteCandidate(c); 775 rch->RemoveRemoteCandidate(c);
775 } 776 }
776 break; 777 break;
777 } 778 }
778 } 779 }
779 } 780 }
780 void OnReadPacket(TransportChannel* channel, 781 void OnReadPacket(rtc::PacketTransport* pt,
781 const char* data, 782 const char* data,
782 size_t len, 783 size_t len,
783 const rtc::PacketTime& packet_time, 784 const rtc::PacketTime& packet_time,
784 int flags) { 785 int flags) {
785 std::list<std::string>& packets = GetPacketList(channel); 786 std::list<std::string>& packets =
787 GetPacketList(static_cast<TransportChannel*>(pt));
786 packets.push_front(std::string(data, len)); 788 packets.push_front(std::string(data, len));
787 } 789 }
788 void OnRoleConflict(TransportChannelImpl* channel) { 790 void OnRoleConflict(TransportChannelImpl* channel) {
789 GetEndpoint(channel)->OnRoleConflict(true); 791 GetEndpoint(channel)->OnRoleConflict(true);
790 IceRole new_role = GetEndpoint(channel)->ice_role() == ICEROLE_CONTROLLING 792 IceRole new_role = GetEndpoint(channel)->ice_role() == ICEROLE_CONTROLLING
791 ? ICEROLE_CONTROLLED 793 ? ICEROLE_CONTROLLED
792 : ICEROLE_CONTROLLING; 794 : ICEROLE_CONTROLLING;
793 channel->SetIceRole(new_role); 795 channel->SetIceRole(new_role);
794 } 796 }
795 797
(...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2902 new StunUInt32Attribute(STUN_ATTR_NOMINATION, nomination)); 2904 new StunUInt32Attribute(STUN_ATTR_NOMINATION, nomination));
2903 } 2905 }
2904 msg.SetTransactionID(rtc::CreateRandomString(kStunTransactionIdLength)); 2906 msg.SetTransactionID(rtc::CreateRandomString(kStunTransactionIdLength));
2905 msg.AddMessageIntegrity(conn->local_candidate().password()); 2907 msg.AddMessageIntegrity(conn->local_candidate().password());
2906 msg.AddFingerprint(); 2908 msg.AddFingerprint();
2907 rtc::ByteBufferWriter buf; 2909 rtc::ByteBufferWriter buf;
2908 msg.Write(&buf); 2910 msg.Write(&buf);
2909 conn->OnReadPacket(buf.Data(), buf.Length(), rtc::CreatePacketTime(0)); 2911 conn->OnReadPacket(buf.Data(), buf.Length(), rtc::CreatePacketTime(0));
2910 } 2912 }
2911 2913
2912 void OnReadyToSend(TransportChannel* channel) { 2914 void OnReadyToSend(rtc::PacketTransport* pt) {
2913 channel_ready_to_send_ = true; 2915 channel_ready_to_send_ = true;
2914 } 2916 }
2915 void OnChannelStateChanged(TransportChannelImpl* channel) { 2917 void OnChannelStateChanged(TransportChannelImpl* channel) {
2916 channel_state_ = channel->GetState(); 2918 channel_state_ = channel->GetState();
2917 } 2919 }
2918 2920
2919 CandidatePairInterface* last_selected_candidate_pair() { 2921 CandidatePairInterface* last_selected_candidate_pair() {
2920 return last_selected_candidate_pair_; 2922 return last_selected_candidate_pair_;
2921 } 2923 }
2922 int last_sent_packet_id() { return last_sent_packet_id_; } 2924 int last_sent_packet_id() { return last_sent_packet_id_; }
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
4216 4218
4217 // TCP Relay/Relay is the next. 4219 // TCP Relay/Relay is the next.
4218 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, 4220 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE,
4219 TCP_PROTOCOL_NAME); 4221 TCP_PROTOCOL_NAME);
4220 4222
4221 // Finally, Local/Relay will be pinged. 4223 // Finally, Local/Relay will be pinged.
4222 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); 4224 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE);
4223 } 4225 }
4224 4226
4225 } // namespace cricket { 4227 } // namespace cricket {
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698