Index: content/renderer/media/rtc_peer_connection_handler.cc |
diff --git a/content/renderer/media/rtc_peer_connection_handler.cc b/content/renderer/media/rtc_peer_connection_handler.cc |
index 3240a7a2fbe2e9e97bb3f0bade3ce22d159fb618..685d7395a1fb05c84b11eb44edb3962fb966625d 100644 |
--- a/content/renderer/media/rtc_peer_connection_handler.cc |
+++ b/content/renderer/media/rtc_peer_connection_handler.cc |
@@ -738,14 +738,6 @@ class GetRTCStatsCallback : public webrtc::RTCStatsCollectorCallback { |
this, report)); |
} |
- void OnStatsDeliveredOnMainThread( |
- const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) { |
- DCHECK(main_thread_->BelongsToCurrentThread()); |
- DCHECK(report); |
- callback_->OnStatsDelivered(std::unique_ptr<blink::WebRTCStatsReport>( |
- new RTCStatsReport(make_scoped_refptr(report.get())))); |
- } |
- |
protected: |
GetRTCStatsCallback( |
const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, |
@@ -753,6 +745,17 @@ class GetRTCStatsCallback : public webrtc::RTCStatsCollectorCallback { |
: main_thread_(main_thread), |
callback_(callback) { |
} |
+ ~GetRTCStatsCallback() override { DCHECK(!callback_); } |
+ |
+ void OnStatsDeliveredOnMainThread( |
+ const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) { |
+ DCHECK(main_thread_->BelongsToCurrentThread()); |
+ DCHECK(report); |
+ callback_->OnStatsDelivered(std::unique_ptr<blink::WebRTCStatsReport>( |
+ new RTCStatsReport(make_scoped_refptr(report.get())))); |
+ // Make sure the callback is destroyed in the main thread as well. |
+ callback_.release(); |
Guido Urdaneta
2017/03/27 12:19:46
I think you want .reset() here.
release() does not
hbos_chromium
2017/03/27 12:22:44
Oops, yes, done.
|
+ } |
const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; |
std::unique_ptr<blink::WebRTCStatsReportCallback> callback_; |