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

Unified Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 2772283002: Destroy WebRTCStatsReportCallbackResolver on main thread, fixes crash. (Closed)
Patch Set: DCHECK that the callback is invoked and destroyed on the expected thread Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..98b5dbe1824e33270c1b2bc936aedb48d7d4f5b7 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,18 @@ 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);
+ DCHECK(callback_);
+ 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_.reset();
+ }
const scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
std::unique_ptr<blink::WebRTCStatsReportCallback> callback_;
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698