| 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. | |
| 704 StatsReport::Id local_cert_report_id, remote_cert_report_id; | 700 StatsReport::Id local_cert_report_id, remote_cert_report_id; |
| 705 | |
| 706 cricket::Transport* transport = | |
| 707 session_->GetTransport(transport_iter.second.content_name); | |
| 708 rtc::scoped_refptr<rtc::RTCCertificate> certificate; | 701 rtc::scoped_refptr<rtc::RTCCertificate> certificate; |
| 709 if (transport && transport->GetCertificate(&certificate)) { | 702 if (session_->GetLocalCertificate(transport_iter.second.transport_name, |
| 703 &certificate)) { |
| 710 StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate())); | 704 StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate())); |
| 711 if (r) | 705 if (r) |
| 712 local_cert_report_id = r->id(); | 706 local_cert_report_id = r->id(); |
| 713 } | 707 } |
| 714 | 708 |
| 715 transport = session_->GetTransport(transport_iter.second.content_name); | |
| 716 rtc::scoped_ptr<rtc::SSLCertificate> cert; | 709 rtc::scoped_ptr<rtc::SSLCertificate> cert; |
| 717 if (transport && transport->GetRemoteCertificate(cert.accept())) { | 710 if (session_->GetRemoteCertificate(transport_iter.second.transport_name, |
| 711 cert.accept())) { |
| 718 StatsReport* r = AddCertificateReports(cert.get()); | 712 StatsReport* r = AddCertificateReports(cert.get()); |
| 719 if (r) | 713 if (r) |
| 720 remote_cert_report_id = r->id(); | 714 remote_cert_report_id = r->id(); |
| 721 } | 715 } |
| 722 | 716 |
| 723 for (const auto& channel_iter : transport_iter.second.channel_stats) { | 717 for (const auto& channel_iter : transport_iter.second.channel_stats) { |
| 724 StatsReport::Id id(StatsReport::NewComponentId( | 718 StatsReport::Id id(StatsReport::NewComponentId( |
| 725 transport_iter.second.content_name, channel_iter.component)); | 719 transport_iter.second.transport_name, channel_iter.component)); |
| 726 StatsReport* channel_report = reports_.ReplaceOrAddNew(id); | 720 StatsReport* channel_report = reports_.ReplaceOrAddNew(id); |
| 727 channel_report->set_timestamp(stats_gathering_started_); | 721 channel_report->set_timestamp(stats_gathering_started_); |
| 728 channel_report->AddInt(StatsReport::kStatsValueNameComponent, | 722 channel_report->AddInt(StatsReport::kStatsValueNameComponent, |
| 729 channel_iter.component); | 723 channel_iter.component); |
| 730 if (local_cert_report_id.get()) { | 724 if (local_cert_report_id.get()) { |
| 731 channel_report->AddId(StatsReport::kStatsValueNameLocalCertificateId, | 725 channel_report->AddId(StatsReport::kStatsValueNameLocalCertificateId, |
| 732 local_cert_report_id); | 726 local_cert_report_id); |
| 733 } | 727 } |
| 734 if (remote_cert_report_id.get()) { | 728 if (remote_cert_report_id.get()) { |
| 735 channel_report->AddId(StatsReport::kStatsValueNameRemoteCertificateId, | 729 channel_report->AddId(StatsReport::kStatsValueNameRemoteCertificateId, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 | 926 |
| 933 void StatsCollector::UpdateTrackReports() { | 927 void StatsCollector::UpdateTrackReports() { |
| 934 DCHECK(session_->signaling_thread()->IsCurrent()); | 928 DCHECK(session_->signaling_thread()->IsCurrent()); |
| 935 | 929 |
| 936 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; | 930 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
| 937 | 931 |
| 938 for (const auto& entry : track_ids_) { | 932 for (const auto& entry : track_ids_) { |
| 939 StatsReport* report = entry.second; | 933 StatsReport* report = entry.second; |
| 940 report->set_timestamp(stats_gathering_started_); | 934 report->set_timestamp(stats_gathering_started_); |
| 941 } | 935 } |
| 942 | |
| 943 } | 936 } |
| 944 | 937 |
| 945 void StatsCollector::ClearUpdateStatsCacheForTest() { | 938 void StatsCollector::ClearUpdateStatsCacheForTest() { |
| 946 stats_gathering_started_ = 0; | 939 stats_gathering_started_ = 0; |
| 947 } | 940 } |
| 948 | 941 |
| 949 } // namespace webrtc | 942 } // namespace webrtc |
| OLD | NEW |