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

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

Issue 2583613003: Fix segfault when PeerConnection is destroyed during stats collection. (Closed)
Patch Set: Addressed comments 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
« webrtc/api/peerconnection.cc ('K') | « webrtc/api/rtcstatscollector.h ('k') | no next file » | 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 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, 423 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread,
424 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); 424 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us));
425 } 425 }
426 } 426 }
427 427
428 void RTCStatsCollector::ClearCachedStatsReport() { 428 void RTCStatsCollector::ClearCachedStatsReport() {
429 RTC_DCHECK(signaling_thread_->IsCurrent()); 429 RTC_DCHECK(signaling_thread_->IsCurrent());
430 cached_report_ = nullptr; 430 cached_report_ = nullptr;
431 } 431 }
432 432
433 void RTCStatsCollector::WaitForPendingRequest() {
434 RTC_DCHECK(signaling_thread_->IsCurrent());
435 if (num_pending_partial_reports_) {
436 rtc::Thread::Current()->ProcessMessages(0);
437 while (num_pending_partial_reports_) {
438 rtc::Thread::Current()->SleepMs(1);
Taylor Brandstetter 2016/12/16 18:53:27 nit: Could use an rtc::Event that's set when a par
hbos 2016/12/19 09:52:48 rtc::Event's wait does not process messages. In or
439 rtc::Thread::Current()->ProcessMessages(0);
440 }
441 }
442 }
443
433 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( 444 void RTCStatsCollector::ProducePartialResultsOnSignalingThread(
434 int64_t timestamp_us) { 445 int64_t timestamp_us) {
435 RTC_DCHECK(signaling_thread_->IsCurrent()); 446 RTC_DCHECK(signaling_thread_->IsCurrent());
436 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( 447 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create(
437 timestamp_us); 448 timestamp_us);
438 449
439 SessionStats session_stats; 450 SessionStats session_stats;
440 if (pc_->session()->GetTransportStats(&session_stats)) { 451 if (pc_->session()->GetTransportStats(&session_stats)) {
441 std::map<std::string, CertificateStatsPair> transport_cert_stats = 452 std::map<std::string, CertificateStatsPair> transport_cert_stats =
442 PrepareTransportCertificateStats(session_stats); 453 PrepareTransportCertificateStats(session_stats);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 const std::string& type) { 939 const std::string& type) {
929 return CandidateTypeToRTCIceCandidateType(type); 940 return CandidateTypeToRTCIceCandidateType(type);
930 } 941 }
931 942
932 const char* DataStateToRTCDataChannelStateForTesting( 943 const char* DataStateToRTCDataChannelStateForTesting(
933 DataChannelInterface::DataState state) { 944 DataChannelInterface::DataState state) {
934 return DataStateToRTCDataChannelState(state); 945 return DataStateToRTCDataChannelState(state);
935 } 946 }
936 947
937 } // namespace webrtc 948 } // namespace webrtc
OLDNEW
« webrtc/api/peerconnection.cc ('K') | « webrtc/api/rtcstatscollector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698