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

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

Issue 2567243003: RTCStatsCollector: Utilize network thread to minimize thread hops. (Closed)
Patch Set: Created 4 years 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 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 bool TransportController::GetLocalCertificate( 112 bool TransportController::GetLocalCertificate(
113 const std::string& transport_name, 113 const std::string& transport_name,
114 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const { 114 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const {
115 return network_thread_->Invoke<bool>( 115 return network_thread_->Invoke<bool>(
116 RTC_FROM_HERE, rtc::Bind(&TransportController::GetLocalCertificate_n, 116 RTC_FROM_HERE, rtc::Bind(&TransportController::GetLocalCertificate_n,
117 this, transport_name, certificate)); 117 this, transport_name, certificate));
118 } 118 }
119 119
120 bool TransportController::GetLocalCertificate_n(
hbos 2016/12/13 14:14:34 All of these were moved after being made public, t
hbos 2016/12/14 14:56:31 (Reverted the move after changing so that they can
121 const std::string& transport_name,
122 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const {
123 RTC_DCHECK(network_thread_->IsCurrent());
124
125 const JsepTransport* t = GetJsepTransport(transport_name);
126 if (!t) {
127 return false;
128 }
129 return t->GetLocalCertificate(certificate);
130 }
131
120 std::unique_ptr<rtc::SSLCertificate> 132 std::unique_ptr<rtc::SSLCertificate>
121 TransportController::GetRemoteSSLCertificate( 133 TransportController::GetRemoteSSLCertificate(
122 const std::string& transport_name) const { 134 const std::string& transport_name) const {
123 return network_thread_->Invoke<std::unique_ptr<rtc::SSLCertificate>>( 135 return network_thread_->Invoke<std::unique_ptr<rtc::SSLCertificate>>(
124 RTC_FROM_HERE, rtc::Bind(&TransportController::GetRemoteSSLCertificate_n, 136 RTC_FROM_HERE, rtc::Bind(&TransportController::GetRemoteSSLCertificate_n,
125 this, transport_name)); 137 this, transport_name));
126 } 138 }
127 139
140 std::unique_ptr<rtc::SSLCertificate>
141 TransportController::GetRemoteSSLCertificate_n(
142 const std::string& transport_name) const {
143 RTC_DCHECK(network_thread_->IsCurrent());
144
145 // Get the certificate from the RTP channel's DTLS handshake. Should be
146 // identical to the RTCP channel's, since they were given the same remote
147 // fingerprint.
148 const RefCountedChannel* ch = GetChannel_n(transport_name, 1);
149 if (!ch) {
150 return nullptr;
151 }
152 return ch->dtls()->GetRemoteSSLCertificate();
153 }
154
128 bool TransportController::SetLocalTransportDescription( 155 bool TransportController::SetLocalTransportDescription(
129 const std::string& transport_name, 156 const std::string& transport_name,
130 const TransportDescription& tdesc, 157 const TransportDescription& tdesc,
131 ContentAction action, 158 ContentAction action,
132 std::string* err) { 159 std::string* err) {
133 return network_thread_->Invoke<bool>( 160 return network_thread_->Invoke<bool>(
134 RTC_FROM_HERE, 161 RTC_FROM_HERE,
135 rtc::Bind(&TransportController::SetLocalTransportDescription_n, this, 162 rtc::Bind(&TransportController::SetLocalTransportDescription_n, this,
136 transport_name, tdesc, action, err)); 163 transport_name, tdesc, action, err));
137 } 164 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 this, transport_name)); 202 this, transport_name));
176 } 203 }
177 204
178 bool TransportController::GetStats(const std::string& transport_name, 205 bool TransportController::GetStats(const std::string& transport_name,
179 TransportStats* stats) { 206 TransportStats* stats) {
180 return network_thread_->Invoke<bool>( 207 return network_thread_->Invoke<bool>(
181 RTC_FROM_HERE, 208 RTC_FROM_HERE,
182 rtc::Bind(&TransportController::GetStats_n, this, transport_name, stats)); 209 rtc::Bind(&TransportController::GetStats_n, this, transport_name, stats));
183 } 210 }
184 211
212 bool TransportController::GetStats_n(const std::string& transport_name,
213 TransportStats* stats) {
214 RTC_DCHECK(network_thread_->IsCurrent());
215
216 JsepTransport* transport = GetJsepTransport(transport_name);
217 if (!transport) {
218 return false;
219 }
220 return transport->GetStats(stats);
221 }
222
185 void TransportController::SetMetricsObserver( 223 void TransportController::SetMetricsObserver(
186 webrtc::MetricsObserverInterface* metrics_observer) { 224 webrtc::MetricsObserverInterface* metrics_observer) {
187 return network_thread_->Invoke<void>( 225 return network_thread_->Invoke<void>(
188 RTC_FROM_HERE, rtc::Bind(&TransportController::SetMetricsObserver_n, this, 226 RTC_FROM_HERE, rtc::Bind(&TransportController::SetMetricsObserver_n, this,
189 metrics_observer)); 227 metrics_observer));
190 } 228 }
191 229
192 TransportChannel* TransportController::CreateTransportChannel_n( 230 TransportChannel* TransportController::CreateTransportChannel_n(
193 const std::string& transport_name, 231 const std::string& transport_name,
194 int component) { 232 int component) {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 kv.second->SetLocalCertificate(certificate_); 522 kv.second->SetLocalCertificate(certificate_);
485 } 523 }
486 // ... and for the DTLS channel, which needs it for the DTLS handshake. 524 // ... and for the DTLS channel, which needs it for the DTLS handshake.
487 for (auto& channel : channels_) { 525 for (auto& channel : channels_) {
488 bool set_cert_success = channel.dtls()->SetLocalCertificate(certificate); 526 bool set_cert_success = channel.dtls()->SetLocalCertificate(certificate);
489 RTC_DCHECK(set_cert_success); 527 RTC_DCHECK(set_cert_success);
490 } 528 }
491 return true; 529 return true;
492 } 530 }
493 531
494 bool TransportController::GetLocalCertificate_n(
495 const std::string& transport_name,
496 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const {
497 RTC_DCHECK(network_thread_->IsCurrent());
498
499 const JsepTransport* t = GetJsepTransport(transport_name);
500 if (!t) {
501 return false;
502 }
503 return t->GetLocalCertificate(certificate);
504 }
505
506 std::unique_ptr<rtc::SSLCertificate>
507 TransportController::GetRemoteSSLCertificate_n(
508 const std::string& transport_name) const {
509 RTC_DCHECK(network_thread_->IsCurrent());
510
511 // Get the certificate from the RTP channel's DTLS handshake. Should be
512 // identical to the RTCP channel's, since they were given the same remote
513 // fingerprint.
514 const RefCountedChannel* ch = GetChannel_n(transport_name, 1);
515 if (!ch) {
516 return nullptr;
517 }
518 return ch->dtls()->GetRemoteSSLCertificate();
519 }
520
521 bool TransportController::SetLocalTransportDescription_n( 532 bool TransportController::SetLocalTransportDescription_n(
522 const std::string& transport_name, 533 const std::string& transport_name,
523 const TransportDescription& tdesc, 534 const TransportDescription& tdesc,
524 ContentAction action, 535 ContentAction action,
525 std::string* err) { 536 std::string* err) {
526 RTC_DCHECK(network_thread_->IsCurrent()); 537 RTC_DCHECK(network_thread_->IsCurrent());
527 538
528 JsepTransport* transport = GetJsepTransport(transport_name); 539 JsepTransport* transport = GetJsepTransport(transport_name);
529 if (!transport) { 540 if (!transport) {
530 // If we didn't find a transport, that's not an error; 541 // If we didn't find a transport, that's not an error;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 const std::string& transport_name) const { 670 const std::string& transport_name) const {
660 RTC_DCHECK(network_thread_->IsCurrent()); 671 RTC_DCHECK(network_thread_->IsCurrent());
661 672
662 const JsepTransport* transport = GetJsepTransport(transport_name); 673 const JsepTransport* transport = GetJsepTransport(transport_name);
663 if (!transport) { 674 if (!transport) {
664 return false; 675 return false;
665 } 676 }
666 return transport->ready_for_remote_candidates(); 677 return transport->ready_for_remote_candidates();
667 } 678 }
668 679
669 bool TransportController::GetStats_n(const std::string& transport_name,
670 TransportStats* stats) {
671 RTC_DCHECK(network_thread_->IsCurrent());
672
673 JsepTransport* transport = GetJsepTransport(transport_name);
674 if (!transport) {
675 return false;
676 }
677 return transport->GetStats(stats);
678 }
679
680 void TransportController::SetMetricsObserver_n( 680 void TransportController::SetMetricsObserver_n(
681 webrtc::MetricsObserverInterface* metrics_observer) { 681 webrtc::MetricsObserverInterface* metrics_observer) {
682 RTC_DCHECK(network_thread_->IsCurrent()); 682 RTC_DCHECK(network_thread_->IsCurrent());
683 metrics_observer_ = metrics_observer; 683 metrics_observer_ = metrics_observer;
684 for (auto& channel : channels_) { 684 for (auto& channel : channels_) {
685 channel.dtls()->SetMetricsObserver(metrics_observer); 685 channel.dtls()->SetMetricsObserver(metrics_observer);
686 } 686 }
687 } 687 }
688 688
689 void TransportController::OnChannelWritableState_n( 689 void TransportController::OnChannelWritableState_n(
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, 823 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE,
824 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); 824 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state));
825 } 825 }
826 } 826 }
827 827
828 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { 828 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) {
829 SignalDtlsHandshakeError(error); 829 SignalDtlsHandshakeError(error);
830 } 830 }
831 831
832 } // namespace cricket 832 } // namespace cricket
OLDNEW
« webrtc/p2p/base/transportcontroller.h ('K') | « webrtc/p2p/base/transportcontroller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698