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 <pthatcher@webrtc.org>
Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21684}
This commit is contained in:
Taylor Brandstetter 2018-01-03 17:14:20 -08:00 committed by Commit Bot
parent 42805f36e3
commit 215fda713e
2 changed files with 5 additions and 5 deletions

View File

@ -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.

View File

@ -922,7 +922,7 @@ class PeerConnection : public PeerConnectionInterface,
// will refer to the same reference count.
rtc::scoped_refptr<PeerConnectionFactory> factory_;
PeerConnectionObserver* observer_ = nullptr;
UMAObserver* uma_observer_ = nullptr;
rtc::scoped_refptr<UMAObserver> uma_observer_ = nullptr;
// The EventLog needs to outlive |call_| (and any other object that uses it).
std::unique_ptr<RtcEventLog> event_log_;