OLD | NEW |
---|---|
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 Loading... | |
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 callback_->OnStatsDelivered(std::unique_ptr<blink::WebRTCStatsReport>( | |
755 new RTCStatsReport(make_scoped_refptr(report.get())))); | |
756 // Make sure the callback is destroyed in the main thread as well. | |
757 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.
| |
758 } | |
756 | 759 |
757 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; | 760 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; |
758 std::unique_ptr<blink::WebRTCStatsReportCallback> callback_; | 761 std::unique_ptr<blink::WebRTCStatsReportCallback> callback_; |
759 }; | 762 }; |
760 | 763 |
761 void GetRTCStatsOnSignalingThread( | 764 void GetRTCStatsOnSignalingThread( |
762 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, | 765 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, |
763 scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection, | 766 scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection, |
764 std::unique_ptr<blink::WebRTCStatsReportCallback> callback) { | 767 std::unique_ptr<blink::WebRTCStatsReportCallback> callback) { |
765 TRACE_EVENT0("webrtc", "GetRTCStatsOnSignalingThread"); | 768 TRACE_EVENT0("webrtc", "GetRTCStatsOnSignalingThread"); |
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2005 } | 2008 } |
2006 | 2009 |
2007 void RTCPeerConnectionHandler::ResetUMAStats() { | 2010 void RTCPeerConnectionHandler::ResetUMAStats() { |
2008 DCHECK(thread_checker_.CalledOnValidThread()); | 2011 DCHECK(thread_checker_.CalledOnValidThread()); |
2009 num_local_candidates_ipv6_ = 0; | 2012 num_local_candidates_ipv6_ = 0; |
2010 num_local_candidates_ipv4_ = 0; | 2013 num_local_candidates_ipv4_ = 0; |
2011 ice_connection_checking_start_ = base::TimeTicks(); | 2014 ice_connection_checking_start_ = base::TimeTicks(); |
2012 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); | 2015 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); |
2013 } | 2016 } |
2014 } // namespace content | 2017 } // namespace content |
OLD | NEW |