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

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

Issue 1345913004: Replace readable with receiving where receiving means receiving anything (stun ping, response or da… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address comments Created 5 years, 3 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/transport.h ('k') | webrtc/p2p/base/transportchannel.h » ('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
11 #include "webrtc/p2p/base/transport.h" 11 #include "webrtc/p2p/base/transport.h"
12 12
13 #include "webrtc/p2p/base/candidate.h" 13 #include "webrtc/p2p/base/candidate.h"
14 #include "webrtc/p2p/base/constants.h" 14 #include "webrtc/p2p/base/constants.h"
15 #include "webrtc/p2p/base/port.h" 15 #include "webrtc/p2p/base/port.h"
16 #include "webrtc/p2p/base/transportchannelimpl.h" 16 #include "webrtc/p2p/base/transportchannelimpl.h"
17 #include "webrtc/base/bind.h" 17 #include "webrtc/base/bind.h"
18 #include "webrtc/base/common.h" 18 #include "webrtc/base/common.h"
19 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
20 20
21 namespace cricket { 21 namespace cricket {
22 22
23 using rtc::Bind; 23 using rtc::Bind;
24 24
25 enum { 25 enum {
26 MSG_ONSIGNALINGREADY = 1, 26 MSG_ONSIGNALINGREADY = 1,
27 MSG_ONREMOTECANDIDATE, 27 MSG_ONREMOTECANDIDATE,
28 MSG_READSTATE,
29 MSG_WRITESTATE, 28 MSG_WRITESTATE,
30 MSG_REQUESTSIGNALING, 29 MSG_REQUESTSIGNALING,
31 MSG_CANDIDATEREADY, 30 MSG_CANDIDATEREADY,
32 MSG_ROUTECHANGE, 31 MSG_ROUTECHANGE,
33 MSG_CONNECTING, 32 MSG_CONNECTING,
34 MSG_CANDIDATEALLOCATIONCOMPLETE, 33 MSG_CANDIDATEALLOCATIONCOMPLETE,
35 MSG_ROLECONFLICT, 34 MSG_ROLECONFLICT,
36 MSG_COMPLETED, 35 MSG_COMPLETED,
37 MSG_FAILED, 36 MSG_FAILED,
38 MSG_RECEIVINGSTATE, 37 MSG_RECEIVINGSTATE,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 impl->SetReceivingTimeout(channel_receiving_timeout_); 230 impl->SetReceivingTimeout(channel_receiving_timeout_);
232 // TODO(ronghuawu): Change CreateChannel_w to be able to return error since 231 // TODO(ronghuawu): Change CreateChannel_w to be able to return error since
233 // below Apply**Description_w calls can fail. 232 // below Apply**Description_w calls can fail.
234 if (local_description_) 233 if (local_description_)
235 ApplyLocalTransportDescription_w(impl, NULL); 234 ApplyLocalTransportDescription_w(impl, NULL);
236 if (remote_description_) 235 if (remote_description_)
237 ApplyRemoteTransportDescription_w(impl, NULL); 236 ApplyRemoteTransportDescription_w(impl, NULL);
238 if (local_description_ && remote_description_) 237 if (local_description_ && remote_description_)
239 ApplyNegotiatedTransportDescription_w(impl, NULL); 238 ApplyNegotiatedTransportDescription_w(impl, NULL);
240 239
241 impl->SignalReadableState.connect(this, &Transport::OnChannelReadableState);
242 impl->SignalWritableState.connect(this, &Transport::OnChannelWritableState); 240 impl->SignalWritableState.connect(this, &Transport::OnChannelWritableState);
243 impl->SignalReceivingState.connect(this, &Transport::OnChannelReceivingState); 241 impl->SignalReceivingState.connect(this, &Transport::OnChannelReceivingState);
244 impl->SignalRequestSignaling.connect( 242 impl->SignalRequestSignaling.connect(
245 this, &Transport::OnChannelRequestSignaling); 243 this, &Transport::OnChannelRequestSignaling);
246 impl->SignalCandidateReady.connect(this, &Transport::OnChannelCandidateReady); 244 impl->SignalCandidateReady.connect(this, &Transport::OnChannelCandidateReady);
247 impl->SignalRouteChange.connect(this, &Transport::OnChannelRouteChange); 245 impl->SignalRouteChange.connect(this, &Transport::OnChannelRouteChange);
248 impl->SignalCandidatesAllocationDone.connect( 246 impl->SignalCandidatesAllocationDone.connect(
249 this, &Transport::OnChannelCandidatesAllocationDone); 247 this, &Transport::OnChannelCandidatesAllocationDone);
250 impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict); 248 impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict);
251 impl->SignalConnectionRemoved.connect( 249 impl->SignalConnectionRemoved.connect(
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 484
487 void Transport::OnRemoteCandidate_w(const Candidate& candidate) { 485 void Transport::OnRemoteCandidate_w(const Candidate& candidate) {
488 ASSERT(worker_thread()->IsCurrent()); 486 ASSERT(worker_thread()->IsCurrent());
489 ChannelMap::iterator iter = channels_.find(candidate.component()); 487 ChannelMap::iterator iter = channels_.find(candidate.component());
490 // It's ok for a channel to go away while this message is in transit. 488 // It's ok for a channel to go away while this message is in transit.
491 if (iter != channels_.end()) { 489 if (iter != channels_.end()) {
492 iter->second->OnCandidate(candidate); 490 iter->second->OnCandidate(candidate);
493 } 491 }
494 } 492 }
495 493
496 void Transport::OnChannelReadableState(TransportChannel* channel) {
497 ASSERT(worker_thread()->IsCurrent());
498 signaling_thread()->Post(this, MSG_READSTATE, NULL);
499 }
500
501 void Transport::OnChannelReadableState_s() {
502 ASSERT(signaling_thread()->IsCurrent());
503 TransportState readable = GetTransportState_s(TRANSPORT_READABLE_STATE);
504 if (readable_ != readable) {
505 readable_ = readable;
506 SignalReadableState(this);
507 }
508 }
509
510 void Transport::OnChannelWritableState(TransportChannel* channel) { 494 void Transport::OnChannelWritableState(TransportChannel* channel) {
511 ASSERT(worker_thread()->IsCurrent()); 495 ASSERT(worker_thread()->IsCurrent());
512 signaling_thread()->Post(this, MSG_WRITESTATE, NULL); 496 signaling_thread()->Post(this, MSG_WRITESTATE, NULL);
513 497
514 MaybeCompleted_w(); 498 MaybeCompleted_w();
515 } 499 }
516 500
517 void Transport::OnChannelWritableState_s() { 501 void Transport::OnChannelWritableState_s() {
518 ASSERT(signaling_thread()->IsCurrent()); 502 ASSERT(signaling_thread()->IsCurrent());
519 TransportState writable = GetTransportState_s(TRANSPORT_WRITABLE_STATE); 503 TransportState writable = GetTransportState_s(TRANSPORT_WRITABLE_STATE);
(...skipping 20 matching lines...) Expand all
540 524
541 TransportState Transport::GetTransportState_s(TransportStateType state_type) { 525 TransportState Transport::GetTransportState_s(TransportStateType state_type) {
542 ASSERT(signaling_thread()->IsCurrent()); 526 ASSERT(signaling_thread()->IsCurrent());
543 527
544 rtc::CritScope cs(&crit_); 528 rtc::CritScope cs(&crit_);
545 bool any = false; 529 bool any = false;
546 bool all = !channels_.empty(); 530 bool all = !channels_.empty();
547 for (const auto iter : channels_) { 531 for (const auto iter : channels_) {
548 bool b = false; 532 bool b = false;
549 switch (state_type) { 533 switch (state_type) {
550 case TRANSPORT_READABLE_STATE:
551 b = iter.second->readable();
552 break;
553 case TRANSPORT_WRITABLE_STATE: 534 case TRANSPORT_WRITABLE_STATE:
554 b = iter.second->writable(); 535 b = iter.second->writable();
555 break; 536 break;
556 case TRANSPORT_RECEIVING_STATE: 537 case TRANSPORT_RECEIVING_STATE:
557 b = iter.second->receiving(); 538 b = iter.second->receiving();
558 break; 539 break;
559 default: 540 default:
560 ASSERT(false); 541 ASSERT(false);
561 } 542 }
562 any |= b; 543 any |= b;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 break; 844 break;
864 case MSG_ONREMOTECANDIDATE: { 845 case MSG_ONREMOTECANDIDATE: {
865 ChannelParams* params = static_cast<ChannelParams*>(msg->pdata); 846 ChannelParams* params = static_cast<ChannelParams*>(msg->pdata);
866 OnRemoteCandidate_w(*params->candidate); 847 OnRemoteCandidate_w(*params->candidate);
867 delete params; 848 delete params;
868 } 849 }
869 break; 850 break;
870 case MSG_CONNECTING: 851 case MSG_CONNECTING:
871 OnConnecting_s(); 852 OnConnecting_s();
872 break; 853 break;
873 case MSG_READSTATE:
874 OnChannelReadableState_s();
875 break;
876 case MSG_WRITESTATE: 854 case MSG_WRITESTATE:
877 OnChannelWritableState_s(); 855 OnChannelWritableState_s();
878 break; 856 break;
879 case MSG_RECEIVINGSTATE: 857 case MSG_RECEIVINGSTATE:
880 OnChannelReceivingState_s(); 858 OnChannelReceivingState_s();
881 break; 859 break;
882 case MSG_REQUESTSIGNALING: 860 case MSG_REQUESTSIGNALING:
883 OnChannelRequestSignaling_s(); 861 OnChannelRequestSignaling_s();
884 break; 862 break;
885 case MSG_CANDIDATEREADY: 863 case MSG_CANDIDATEREADY:
(...skipping 14 matching lines...) Expand all
900 case MSG_COMPLETED: 878 case MSG_COMPLETED:
901 SignalCompleted(this); 879 SignalCompleted(this);
902 break; 880 break;
903 case MSG_FAILED: 881 case MSG_FAILED:
904 SignalFailed(this); 882 SignalFailed(this);
905 break; 883 break;
906 } 884 }
907 } 885 }
908 886
909 } // namespace cricket 887 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transport.h ('k') | webrtc/p2p/base/transportchannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698