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

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

Issue 2583613003: Fix segfault when PeerConnection is destroyed during stats collection. (Closed)
Patch Set: 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
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 DataChannelInit init; 66 DataChannelInit init;
67 caller_->CreateDataChannel("data", init); 67 caller_->CreateDataChannel("data", init);
68 callee_->CreateDataChannel("data", init); 68 callee_->CreateDataChannel("data", init);
69 69
70 // Negotiate and wait for call to establish 70 // Negotiate and wait for call to establish
71 caller_->CreateOffer(nullptr); 71 caller_->CreateOffer(nullptr);
72 caller_->WaitForCallEstablished(); 72 caller_->WaitForCallEstablished();
73 callee_->WaitForCallEstablished(); 73 callee_->WaitForCallEstablished();
74 } 74 }
75 75
76 void DestroyCallerAndCallee() {
77 caller_ = callee_ = nullptr;
78 }
79
76 rtc::scoped_refptr<const RTCStatsReport> GetStatsFromCaller() { 80 rtc::scoped_refptr<const RTCStatsReport> GetStatsFromCaller() {
77 return GetStats(caller_->pc()); 81 return GetStats(caller_->pc());
78 } 82 }
79 83
80 rtc::scoped_refptr<const RTCStatsReport> GetStatsFromCallee() { 84 rtc::scoped_refptr<const RTCStatsReport> GetStatsFromCallee() {
81 return GetStats(callee_->pc()); 85 return GetStats(callee_->pc());
82 } 86 }
83 87
84 protected: 88 protected:
85 static rtc::scoped_refptr<const RTCStatsReport> GetStats( 89 static rtc::scoped_refptr<const RTCStatsReport> GetStats(
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 RTCStatsReportVerifier(report.get()).VerifyReport(); 534 RTCStatsReportVerifier(report.get()).VerifyReport();
531 } 535 }
532 536
533 TEST_F(RTCStatsIntegrationTest, GetStatsFromCallee) { 537 TEST_F(RTCStatsIntegrationTest, GetStatsFromCallee) {
534 StartCall(); 538 StartCall();
535 539
536 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsFromCallee(); 540 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsFromCallee();
537 RTCStatsReportVerifier(report.get()).VerifyReport(); 541 RTCStatsReportVerifier(report.get()).VerifyReport();
538 } 542 }
539 543
544 TEST_F(RTCStatsIntegrationTest, GetsStatsWhileDestroyingPeerConnections) {
545 StartCall();
546
547 rtc::scoped_refptr<RTCStatsObtainer> stats_obtainer =
548 RTCStatsObtainer::Create();
549 caller_->pc()->GetStats(stats_obtainer);
550 DestroyCallerAndCallee();
hta-webrtc 2016/12/16 14:05:31 In the interest of minimizing the amount of side e
hbos 2016/12/16 14:34:52 Good point, changed to "caller_ = nullptr" and rem
551 // Any pending stats requests should have completed in the act of destroying
552 // the peer connection.
553 EXPECT_TRUE(stats_obtainer->report());
554 }
555
540 } // namespace 556 } // namespace
541 557
542 } // namespace webrtc 558 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698