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

Side by Side Diff: webrtc/api/statscollector.cc

Issue 2567243003: RTCStatsCollector: Utilize network thread to minimize thread hops. (Closed)
Patch Set: Rebase and rename Get[Session]Stats_n 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
« no previous file with comments | « webrtc/api/rtcstatscollector_unittest.cc ('k') | webrtc/api/statscollector_unittest.cc » ('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 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 668 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
669 669
670 // Extract information from the base session. 670 // Extract information from the base session.
671 StatsReport::Id id(StatsReport::NewTypedId( 671 StatsReport::Id id(StatsReport::NewTypedId(
672 StatsReport::kStatsReportTypeSession, pc_->session()->id())); 672 StatsReport::kStatsReportTypeSession, pc_->session()->id()));
673 StatsReport* report = reports_.ReplaceOrAddNew(id); 673 StatsReport* report = reports_.ReplaceOrAddNew(id);
674 report->set_timestamp(stats_gathering_started_); 674 report->set_timestamp(stats_gathering_started_);
675 report->AddBoolean(StatsReport::kStatsValueNameInitiator, 675 report->AddBoolean(StatsReport::kStatsValueNameInitiator,
676 pc_->session()->initial_offerer()); 676 pc_->session()->initial_offerer());
677 677
678 SessionStats stats; 678 std::unique_ptr<SessionStats> stats = pc_->session()->GetStats();
679 if (!pc_->session()->GetTransportStats(&stats)) { 679 if (!stats) {
680 return; 680 return;
681 } 681 }
682 682
683 // Store the proxy map away for use in SSRC reporting. 683 // Store the proxy map away for use in SSRC reporting.
684 // TODO(tommi): This shouldn't be necessary if we post the stats back to the 684 // TODO(tommi): This shouldn't be necessary if we post the stats back to the
685 // signaling thread after fetching them on the worker thread, then just use 685 // signaling thread after fetching them on the worker thread, then just use
686 // the proxy map directly from the session stats. 686 // the proxy map directly from the session stats.
687 // As is, if GetStats() failed, we could be using old (incorrect?) proxy 687 // As is, if GetStats() failed, we could be using old (incorrect?) proxy
688 // data. 688 // data.
689 proxy_to_transport_ = stats.proxy_to_transport; 689 proxy_to_transport_ = stats->proxy_to_transport;
690 690
691 for (const auto& transport_iter : stats.transport_stats) { 691 for (const auto& transport_iter : stats->transport_stats) {
692 // Attempt to get a copy of the certificates from the transport and 692 // Attempt to get a copy of the certificates from the transport and
693 // expose them in stats reports. All channels in a transport share the 693 // expose them in stats reports. All channels in a transport share the
694 // same local and remote certificates. 694 // same local and remote certificates.
695 // 695 //
696 StatsReport::Id local_cert_report_id, remote_cert_report_id; 696 StatsReport::Id local_cert_report_id, remote_cert_report_id;
697 rtc::scoped_refptr<rtc::RTCCertificate> certificate; 697 rtc::scoped_refptr<rtc::RTCCertificate> certificate;
698 if (pc_->session()->GetLocalCertificate( 698 if (pc_->session()->GetLocalCertificate(
699 transport_iter.second.transport_name, &certificate)) { 699 transport_iter.second.transport_name, &certificate)) {
700 StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate())); 700 StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate()));
701 if (r) 701 if (r)
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 StatsReport* report = entry.second; 978 StatsReport* report = entry.second;
979 report->set_timestamp(stats_gathering_started_); 979 report->set_timestamp(stats_gathering_started_);
980 } 980 }
981 } 981 }
982 982
983 void StatsCollector::ClearUpdateStatsCacheForTest() { 983 void StatsCollector::ClearUpdateStatsCacheForTest() {
984 stats_gathering_started_ = 0; 984 stats_gathering_started_ = 0;
985 } 985 }
986 986
987 } // namespace webrtc 987 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/rtcstatscollector_unittest.cc ('k') | webrtc/api/statscollector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698