OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 // the proxy map directly from the session stats. | 685 // the proxy map directly from the session stats. |
686 // As is, if GetStats() failed, we could be using old (incorrect?) proxy | 686 // As is, if GetStats() failed, we could be using old (incorrect?) proxy |
687 // data. | 687 // data. |
688 proxy_to_transport_ = stats.proxy_to_transport; | 688 proxy_to_transport_ = stats.proxy_to_transport; |
689 | 689 |
690 for (const auto& transport_iter : stats.transport_stats) { | 690 for (const auto& transport_iter : stats.transport_stats) { |
691 // Attempt to get a copy of the certificates from the transport and | 691 // Attempt to get a copy of the certificates from the transport and |
692 // expose them in stats reports. All channels in a transport share the | 692 // expose them in stats reports. All channels in a transport share the |
693 // same local and remote certificates. | 693 // same local and remote certificates. |
694 // | 694 // |
695 // Note that Transport::GetCertificate and Transport::GetRemoteCertificate | |
696 // invoke method calls on the worker thread and block this thread, but | |
697 // messages are still processed on this thread, which may blow way the | |
698 // existing transports. So we cannot reuse |transport| after these calls. | |
699 StatsReport::Id local_cert_report_id, remote_cert_report_id; | 695 StatsReport::Id local_cert_report_id, remote_cert_report_id; |
700 | |
701 cricket::Transport* transport = | |
702 session_->GetTransport(transport_iter.second.content_name); | |
703 rtc::scoped_refptr<rtc::RTCCertificate> certificate; | 696 rtc::scoped_refptr<rtc::RTCCertificate> certificate; |
704 if (transport && transport->GetCertificate(&certificate)) { | 697 if (session_->GetLocalCertificate(transport_iter.second.transport_name, |
| 698 &certificate)) { |
705 StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate())); | 699 StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate())); |
706 if (r) | 700 if (r) |
707 local_cert_report_id = r->id(); | 701 local_cert_report_id = r->id(); |
708 } | 702 } |
709 | 703 |
710 transport = session_->GetTransport(transport_iter.second.content_name); | |
711 rtc::scoped_ptr<rtc::SSLCertificate> cert; | 704 rtc::scoped_ptr<rtc::SSLCertificate> cert; |
712 if (transport && transport->GetRemoteCertificate(cert.accept())) { | 705 if (session_->GetRemoteCertificate(transport_iter.second.transport_name, |
| 706 cert.accept())) { |
713 StatsReport* r = AddCertificateReports(cert.get()); | 707 StatsReport* r = AddCertificateReports(cert.get()); |
714 if (r) | 708 if (r) |
715 remote_cert_report_id = r->id(); | 709 remote_cert_report_id = r->id(); |
716 } | 710 } |
717 | 711 |
718 for (const auto& channel_iter : transport_iter.second.channel_stats) { | 712 for (const auto& channel_iter : transport_iter.second.channel_stats) { |
719 StatsReport::Id id(StatsReport::NewComponentId( | 713 StatsReport::Id id(StatsReport::NewComponentId( |
720 transport_iter.second.content_name, channel_iter.component)); | 714 transport_iter.second.transport_name, channel_iter.component)); |
721 StatsReport* channel_report = reports_.ReplaceOrAddNew(id); | 715 StatsReport* channel_report = reports_.ReplaceOrAddNew(id); |
722 channel_report->set_timestamp(stats_gathering_started_); | 716 channel_report->set_timestamp(stats_gathering_started_); |
723 channel_report->AddInt(StatsReport::kStatsValueNameComponent, | 717 channel_report->AddInt(StatsReport::kStatsValueNameComponent, |
724 channel_iter.component); | 718 channel_iter.component); |
725 if (local_cert_report_id.get()) { | 719 if (local_cert_report_id.get()) { |
726 channel_report->AddId(StatsReport::kStatsValueNameLocalCertificateId, | 720 channel_report->AddId(StatsReport::kStatsValueNameLocalCertificateId, |
727 local_cert_report_id); | 721 local_cert_report_id); |
728 } | 722 } |
729 if (remote_cert_report_id.get()) { | 723 if (remote_cert_report_id.get()) { |
730 channel_report->AddId(StatsReport::kStatsValueNameRemoteCertificateId, | 724 channel_report->AddId(StatsReport::kStatsValueNameRemoteCertificateId, |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 | 921 |
928 void StatsCollector::UpdateTrackReports() { | 922 void StatsCollector::UpdateTrackReports() { |
929 DCHECK(session_->signaling_thread()->IsCurrent()); | 923 DCHECK(session_->signaling_thread()->IsCurrent()); |
930 | 924 |
931 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; | 925 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
932 | 926 |
933 for (const auto& entry : track_ids_) { | 927 for (const auto& entry : track_ids_) { |
934 StatsReport* report = entry.second; | 928 StatsReport* report = entry.second; |
935 report->set_timestamp(stats_gathering_started_); | 929 report->set_timestamp(stats_gathering_started_); |
936 } | 930 } |
937 | |
938 } | 931 } |
939 | 932 |
940 void StatsCollector::ClearUpdateStatsCacheForTest() { | 933 void StatsCollector::ClearUpdateStatsCacheForTest() { |
941 stats_gathering_started_ = 0; | 934 stats_gathering_started_ = 0; |
942 } | 935 } |
943 | 936 |
944 } // namespace webrtc | 937 } // namespace webrtc |
OLD | NEW |