| 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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 // the proxy map directly from the session stats. | 690 // the proxy map directly from the session stats. |
| 691 // As is, if GetStats() failed, we could be using old (incorrect?) proxy | 691 // As is, if GetStats() failed, we could be using old (incorrect?) proxy |
| 692 // data. | 692 // data. |
| 693 proxy_to_transport_ = stats.proxy_to_transport; | 693 proxy_to_transport_ = stats.proxy_to_transport; |
| 694 | 694 |
| 695 for (const auto& transport_iter : stats.transport_stats) { | 695 for (const auto& transport_iter : stats.transport_stats) { |
| 696 // Attempt to get a copy of the certificates from the transport and | 696 // Attempt to get a copy of the certificates from the transport and |
| 697 // expose them in stats reports. All channels in a transport share the | 697 // expose them in stats reports. All channels in a transport share the |
| 698 // same local and remote certificates. | 698 // same local and remote certificates. |
| 699 // | 699 // |
| 700 // Note that Transport::GetCertificate and Transport::GetRemoteCertificate |
| 701 // invoke method calls on the worker thread and block this thread, but |
| 702 // messages are still processed on this thread, which may blow way the |
| 703 // existing transports. So we cannot reuse |transport| after these calls. |
| 700 StatsReport::Id local_cert_report_id, remote_cert_report_id; | 704 StatsReport::Id local_cert_report_id, remote_cert_report_id; |
| 705 |
| 706 cricket::Transport* transport = |
| 707 session_->GetTransport(transport_iter.second.content_name); |
| 701 rtc::scoped_refptr<rtc::RTCCertificate> certificate; | 708 rtc::scoped_refptr<rtc::RTCCertificate> certificate; |
| 702 if (session_->GetLocalCertificate(transport_iter.second.transport_name, | 709 if (transport && transport->GetCertificate(&certificate)) { |
| 703 &certificate)) { | |
| 704 StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate())); | 710 StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate())); |
| 705 if (r) | 711 if (r) |
| 706 local_cert_report_id = r->id(); | 712 local_cert_report_id = r->id(); |
| 707 } | 713 } |
| 708 | 714 |
| 715 transport = session_->GetTransport(transport_iter.second.content_name); |
| 709 rtc::scoped_ptr<rtc::SSLCertificate> cert; | 716 rtc::scoped_ptr<rtc::SSLCertificate> cert; |
| 710 if (session_->GetRemoteSSLCertificate(transport_iter.second.transport_name, | 717 if (transport && transport->GetRemoteSSLCertificate(cert.accept())) { |
| 711 cert.accept())) { | |
| 712 StatsReport* r = AddCertificateReports(cert.get()); | 718 StatsReport* r = AddCertificateReports(cert.get()); |
| 713 if (r) | 719 if (r) |
| 714 remote_cert_report_id = r->id(); | 720 remote_cert_report_id = r->id(); |
| 715 } | 721 } |
| 716 | 722 |
| 717 for (const auto& channel_iter : transport_iter.second.channel_stats) { | 723 for (const auto& channel_iter : transport_iter.second.channel_stats) { |
| 718 StatsReport::Id id(StatsReport::NewComponentId( | 724 StatsReport::Id id(StatsReport::NewComponentId( |
| 719 transport_iter.second.transport_name, channel_iter.component)); | 725 transport_iter.second.content_name, channel_iter.component)); |
| 720 StatsReport* channel_report = reports_.ReplaceOrAddNew(id); | 726 StatsReport* channel_report = reports_.ReplaceOrAddNew(id); |
| 721 channel_report->set_timestamp(stats_gathering_started_); | 727 channel_report->set_timestamp(stats_gathering_started_); |
| 722 channel_report->AddInt(StatsReport::kStatsValueNameComponent, | 728 channel_report->AddInt(StatsReport::kStatsValueNameComponent, |
| 723 channel_iter.component); | 729 channel_iter.component); |
| 724 if (local_cert_report_id.get()) { | 730 if (local_cert_report_id.get()) { |
| 725 channel_report->AddId(StatsReport::kStatsValueNameLocalCertificateId, | 731 channel_report->AddId(StatsReport::kStatsValueNameLocalCertificateId, |
| 726 local_cert_report_id); | 732 local_cert_report_id); |
| 727 } | 733 } |
| 728 if (remote_cert_report_id.get()) { | 734 if (remote_cert_report_id.get()) { |
| 729 channel_report->AddId(StatsReport::kStatsValueNameRemoteCertificateId, | 735 channel_report->AddId(StatsReport::kStatsValueNameRemoteCertificateId, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 | 932 |
| 927 void StatsCollector::UpdateTrackReports() { | 933 void StatsCollector::UpdateTrackReports() { |
| 928 RTC_DCHECK(session_->signaling_thread()->IsCurrent()); | 934 RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
| 929 | 935 |
| 930 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; | 936 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
| 931 | 937 |
| 932 for (const auto& entry : track_ids_) { | 938 for (const auto& entry : track_ids_) { |
| 933 StatsReport* report = entry.second; | 939 StatsReport* report = entry.second; |
| 934 report->set_timestamp(stats_gathering_started_); | 940 report->set_timestamp(stats_gathering_started_); |
| 935 } | 941 } |
| 942 |
| 936 } | 943 } |
| 937 | 944 |
| 938 void StatsCollector::ClearUpdateStatsCacheForTest() { | 945 void StatsCollector::ClearUpdateStatsCacheForTest() { |
| 939 stats_gathering_started_ = 0; | 946 stats_gathering_started_ = 0; |
| 940 } | 947 } |
| 941 | 948 |
| 942 } // namespace webrtc | 949 } // namespace webrtc |
| OLD | NEW |