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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 main_thread, callback.release())); 731 main_thread, callback.release()));
732 } 732 }
733 733
734 void OnStatsDelivered( 734 void OnStatsDelivered(
735 const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) override { 735 const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) override {
736 main_thread_->PostTask(FROM_HERE, 736 main_thread_->PostTask(FROM_HERE,
737 base::Bind(&GetRTCStatsCallback::OnStatsDeliveredOnMainThread, 737 base::Bind(&GetRTCStatsCallback::OnStatsDeliveredOnMainThread,
738 this, report)); 738 this, report));
739 } 739 }
740 740
741 void OnStatsDeliveredOnMainThread(
742 const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) {
743 DCHECK(main_thread_->BelongsToCurrentThread());
744 DCHECK(report);
745 callback_->OnStatsDelivered(std::unique_ptr<blink::WebRTCStatsReport>(
746 new RTCStatsReport(make_scoped_refptr(report.get()))));
747 }
748
749 protected: 741 protected:
750 GetRTCStatsCallback( 742 GetRTCStatsCallback(
751 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, 743 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread,
752 blink::WebRTCStatsReportCallback* callback) 744 blink::WebRTCStatsReportCallback* callback)
753 : main_thread_(main_thread), 745 : main_thread_(main_thread),
754 callback_(callback) { 746 callback_(callback) {
755 } 747 }
748 ~GetRTCStatsCallback() override { DCHECK(!callback_); }
749
750 void OnStatsDeliveredOnMainThread(
751 const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) {
752 DCHECK(main_thread_->BelongsToCurrentThread());
753 DCHECK(report);
754 DCHECK(callback_);
755 callback_->OnStatsDelivered(std::unique_ptr<blink::WebRTCStatsReport>(
756 new RTCStatsReport(make_scoped_refptr(report.get()))));
757 // Make sure the callback is destroyed in the main thread as well.
758 callback_.reset();
759 }
756 760
757 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; 761 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
758 std::unique_ptr<blink::WebRTCStatsReportCallback> callback_; 762 std::unique_ptr<blink::WebRTCStatsReportCallback> callback_;
759 }; 763 };
760 764
761 void GetRTCStatsOnSignalingThread( 765 void GetRTCStatsOnSignalingThread(
762 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, 766 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread,
763 scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection, 767 scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection,
764 std::unique_ptr<blink::WebRTCStatsReportCallback> callback) { 768 std::unique_ptr<blink::WebRTCStatsReportCallback> callback) {
765 TRACE_EVENT0("webrtc", "GetRTCStatsOnSignalingThread"); 769 TRACE_EVENT0("webrtc", "GetRTCStatsOnSignalingThread");
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 } 2009 }
2006 2010
2007 void RTCPeerConnectionHandler::ResetUMAStats() { 2011 void RTCPeerConnectionHandler::ResetUMAStats() {
2008 DCHECK(thread_checker_.CalledOnValidThread()); 2012 DCHECK(thread_checker_.CalledOnValidThread());
2009 num_local_candidates_ipv6_ = 0; 2013 num_local_candidates_ipv6_ = 0;
2010 num_local_candidates_ipv4_ = 0; 2014 num_local_candidates_ipv4_ = 0;
2011 ice_connection_checking_start_ = base::TimeTicks(); 2015 ice_connection_checking_start_ = base::TimeTicks();
2012 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); 2016 memset(ice_state_seen_, 0, sizeof(ice_state_seen_));
2013 } 2017 }
2014 } // namespace content 2018 } // namespace content
OLDNEW
« 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