From 215fda713e8eab61b005e5d7453e75a9712fd789 Mon Sep 17 00:00:00 2001 From: Taylor Brandstetter Date: Wed, 3 Jan 2018 17:14:20 -0800 Subject: [PATCH] Make PeerConnection take reference to UMA observer. It's reference counted, yet we aren't taking a reference to it for some reason. This could be causing it to be dereferenced after deletion in some cases in chromium. Bug: chromium:798251 Change-Id: I0b91451e38ed611d2ea8a477f1e7db482a790f79 Reviewed-on: https://webrtc-review.googlesource.com/37283 Reviewed-by: Peter Thatcher Commit-Queue: Taylor Brandstetter Cr-Commit-Position: refs/heads/master@{#21684} --- api/peerconnectioninterface.h | 8 ++++---- pc/peerconnection.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h index a6c8c06335..f6fae5848c 100644 --- a/api/peerconnectioninterface.h +++ b/api/peerconnectioninterface.h @@ -886,10 +886,10 @@ class PeerConnectionInterface : public rtc::RefCountInterface { return false; } - // Register a metric observer (used by chromium). - // - // There can only be one observer at a time. Before the observer is - // destroyed, RegisterUMAOberver(nullptr) should be called. + // Register a metric observer (used by chromium). It's reference counted, and + // this method takes a reference. RegisterUMAObserver(nullptr) will release + // the reference. + // TODO(deadbeef): Take argument as scoped_refptr? virtual void RegisterUMAObserver(UMAObserver* observer) = 0; // 0 <= min <= current <= max should hold for set parameters. diff --git a/pc/peerconnection.h b/pc/peerconnection.h index d86f2975b3..705fff5001 100644 --- a/pc/peerconnection.h +++ b/pc/peerconnection.h @@ -922,7 +922,7 @@ class PeerConnection : public PeerConnectionInterface, // will refer to the same reference count. rtc::scoped_refptr factory_; PeerConnectionObserver* observer_ = nullptr; - UMAObserver* uma_observer_ = nullptr; + rtc::scoped_refptr uma_observer_ = nullptr; // The EventLog needs to outlive |call_| (and any other object that uses it). std::unique_ptr event_log_;