Initialize PeerConnection members in declaration order and destroy them in reverse order.

BUG=webrtc:7658

Review-Url: https://codereview.webrtc.org/2882803002
Cr-Commit-Position: refs/heads/master@{#18130}
This commit is contained in:
terelius 2017-05-12 23:37:18 -07:00 committed by Commit bot
parent d0ffa8615d
commit 338602596c
2 changed files with 13 additions and 8 deletions

View File

@ -395,10 +395,10 @@ PeerConnection::PeerConnection(PeerConnectionFactory* factory)
: factory_(factory),
observer_(NULL),
uma_observer_(NULL),
event_log_(RtcEventLog::Create()),
signaling_state_(kStable),
ice_connection_state_(kIceConnectionNew),
ice_gathering_state_(kIceGatheringNew),
event_log_(RtcEventLog::Create()),
rtcp_cname_(GenerateRtcpCname()),
local_streams_(StreamCollection::Create()),
remote_streams_(StreamCollection::Create()) {}
@ -1289,7 +1289,6 @@ void PeerConnection::Close() {
stats_->UpdateStats(kStatsOutputLevelStandard);
session_->Close();
event_log_.reset();
network_thread()->Invoke<void>(
RTC_FROM_HERE,
rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool,
@ -1297,6 +1296,9 @@ void PeerConnection::Close() {
factory_->worker_thread()->Invoke<void>(RTC_FROM_HERE,
[this] { call_.reset(); });
// The event log must outlive call (and any other object that uses it).
event_log_.reset();
}
void PeerConnection::OnSessionStateChange(WebRtcSession* /*session*/,

View File

@ -402,14 +402,16 @@ class PeerConnection : public PeerConnectionInterface,
rtc::scoped_refptr<PeerConnectionFactory> factory_;
PeerConnectionObserver* observer_;
UMAObserver* uma_observer_;
// The EventLog needs to outlive |call_| (and any other object that uses it).
std::unique_ptr<RtcEventLog> event_log_;
SignalingState signaling_state_;
IceConnectionState ice_connection_state_;
IceGatheringState ice_gathering_state_;
PeerConnectionInterface::RTCConfiguration configuration_;
std::unique_ptr<cricket::PortAllocator> port_allocator_;
// The EventLog needs to outlive |call_|.
std::unique_ptr<RtcEventLog> event_log_;
// One PeerConnection has only one RTCP CNAME.
// https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9
@ -436,15 +438,16 @@ class PeerConnection : public PeerConnectionInterface,
bool remote_peer_supports_msid_ = false;
std::unique_ptr<Call> call_;
std::unique_ptr<WebRtcSession> session_;
std::unique_ptr<StatsCollector> stats_; // A pointer is passed to senders_
rtc::scoped_refptr<RTCStatsCollector> stats_collector_;
std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
senders_;
std::vector<
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>>
receivers_;
std::unique_ptr<WebRtcSession> session_;
std::unique_ptr<Call> call_;
std::unique_ptr<StatsCollector> stats_;
rtc::scoped_refptr<RTCStatsCollector> stats_collector_;
};
} // namespace webrtc