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

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 2435863004: Remove stl_util's deletion function use from content/. (Closed)
Patch Set: minus service worker Created 4 years, 2 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 | « content/renderer/media/rtc_peer_connection_handler.h ('k') | no next file » | 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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/ptr_util.h"
17 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
18 #include "base/metrics/sparse_histogram.h" 19 #include "base/metrics/sparse_histogram.h"
19 #include "base/stl_util.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
22 #include "base/trace_event/trace_event.h" 22 #include "base/trace_event/trace_event.h"
23 #include "content/public/common/content_features.h" 23 #include "content/public/common/content_features.h"
24 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
25 #include "content/renderer/media/media_stream_constraints_util.h" 25 #include "content/renderer/media/media_stream_constraints_util.h"
26 #include "content/renderer/media/media_stream_track.h" 26 #include "content/renderer/media/media_stream_track.h"
27 #include "content/renderer/media/peer_connection_tracker.h" 27 #include "content/renderer/media/peer_connection_tracker.h"
28 #include "content/renderer/media/remote_media_stream_impl.h" 28 #include "content/renderer/media/remote_media_stream_impl.h"
29 #include "content/renderer/media/rtc_certificate.h" 29 #include "content/renderer/media/rtc_certificate.h"
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 } 1050 }
1051 1051
1052 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { 1052 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() {
1053 DCHECK(thread_checker_.CalledOnValidThread()); 1053 DCHECK(thread_checker_.CalledOnValidThread());
1054 1054
1055 stop(); 1055 stop();
1056 1056
1057 g_peer_connection_handlers.Get().erase(this); 1057 g_peer_connection_handlers.Get().erase(this);
1058 if (peer_connection_tracker_) 1058 if (peer_connection_tracker_)
1059 peer_connection_tracker_->UnregisterPeerConnection(this); 1059 peer_connection_tracker_->UnregisterPeerConnection(this);
1060 base::STLDeleteValues(&remote_streams_);
1061 1060
1062 UMA_HISTOGRAM_COUNTS_10000( 1061 UMA_HISTOGRAM_COUNTS_10000(
1063 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_); 1062 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_);
1064 } 1063 }
1065 1064
1066 // static 1065 // static
1067 void RTCPeerConnectionHandler::DestructAllHandlers() { 1066 void RTCPeerConnectionHandler::DestructAllHandlers() {
1068 // Copy g_peer_connection_handlers since releasePeerConnectionHandler will 1067 // Copy g_peer_connection_handlers since releasePeerConnectionHandler will
1069 // remove an item. 1068 // remove an item.
1070 std::set<RTCPeerConnectionHandler*> handlers( 1069 std::set<RTCPeerConnectionHandler*> handlers(
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 } 1774 }
1776 1775
1777 void RTCPeerConnectionHandler::OnAddStream( 1776 void RTCPeerConnectionHandler::OnAddStream(
1778 std::unique_ptr<RemoteMediaStreamImpl> stream) { 1777 std::unique_ptr<RemoteMediaStreamImpl> stream) {
1779 DCHECK(thread_checker_.CalledOnValidThread()); 1778 DCHECK(thread_checker_.CalledOnValidThread());
1780 DCHECK(remote_streams_.find(stream->webrtc_stream().get()) == 1779 DCHECK(remote_streams_.find(stream->webrtc_stream().get()) ==
1781 remote_streams_.end()); 1780 remote_streams_.end());
1782 DCHECK(stream->webkit_stream().getExtraData()) << "Initialization not done"; 1781 DCHECK(stream->webkit_stream().getExtraData()) << "Initialization not done";
1783 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnAddStreamImpl"); 1782 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnAddStreamImpl");
1784 1783
1785 // Ownership is with remote_streams_ now. 1784 RemoteMediaStreamImpl* stream_ptr = stream.get();
1786 RemoteMediaStreamImpl* s = stream.release(); 1785 remote_streams_[stream_ptr->webrtc_stream().get()] = std::move(stream);
1787 remote_streams_.insert(
1788 std::pair<webrtc::MediaStreamInterface*, RemoteMediaStreamImpl*> (
1789 s->webrtc_stream().get(), s));
1790 1786
1791 if (peer_connection_tracker_) { 1787 if (peer_connection_tracker_) {
1792 peer_connection_tracker_->TrackAddStream( 1788 peer_connection_tracker_->TrackAddStream(
1793 this, s->webkit_stream(), PeerConnectionTracker::SOURCE_REMOTE); 1789 this, stream_ptr->webkit_stream(),
1790 PeerConnectionTracker::SOURCE_REMOTE);
1794 } 1791 }
1795 1792
1796 PerSessionWebRTCAPIMetrics::GetInstance()->IncrementStreamCounter(); 1793 PerSessionWebRTCAPIMetrics::GetInstance()->IncrementStreamCounter();
1797 1794
1798 track_metrics_.AddStream(MediaStreamTrackMetrics::RECEIVED_STREAM, 1795 track_metrics_.AddStream(MediaStreamTrackMetrics::RECEIVED_STREAM,
1799 s->webrtc_stream().get()); 1796 stream_ptr->webrtc_stream().get());
1800 if (!is_closed_) 1797 if (!is_closed_)
1801 client_->didAddRemoteStream(s->webkit_stream()); 1798 client_->didAddRemoteStream(stream_ptr->webkit_stream());
1802 } 1799 }
1803 1800
1804 void RTCPeerConnectionHandler::OnRemoveStream( 1801 void RTCPeerConnectionHandler::OnRemoveStream(
1805 const scoped_refptr<webrtc::MediaStreamInterface>& stream) { 1802 const scoped_refptr<webrtc::MediaStreamInterface>& stream) {
1806 DCHECK(thread_checker_.CalledOnValidThread()); 1803 DCHECK(thread_checker_.CalledOnValidThread());
1807 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnRemoveStreamImpl"); 1804 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnRemoveStreamImpl");
1808 RemoteStreamMap::iterator it = remote_streams_.find(stream.get()); 1805 auto it = remote_streams_.find(stream.get());
1809 if (it == remote_streams_.end()) { 1806 if (it == remote_streams_.end()) {
1810 NOTREACHED() << "Stream not found"; 1807 NOTREACHED() << "Stream not found";
1811 return; 1808 return;
1812 } 1809 }
1813 1810
1814 track_metrics_.RemoveStream(MediaStreamTrackMetrics::RECEIVED_STREAM, 1811 track_metrics_.RemoveStream(MediaStreamTrackMetrics::RECEIVED_STREAM,
1815 stream.get()); 1812 stream.get());
1816 PerSessionWebRTCAPIMetrics::GetInstance()->DecrementStreamCounter(); 1813 PerSessionWebRTCAPIMetrics::GetInstance()->DecrementStreamCounter();
1817 1814
1818 std::unique_ptr<RemoteMediaStreamImpl> remote_stream(it->second); 1815 std::unique_ptr<RemoteMediaStreamImpl> remote_stream = std::move(it->second);
1819 const blink::WebMediaStream& webkit_stream = remote_stream->webkit_stream(); 1816 const blink::WebMediaStream& webkit_stream = remote_stream->webkit_stream();
1820 DCHECK(!webkit_stream.isNull()); 1817 DCHECK(!webkit_stream.isNull());
1821 remote_streams_.erase(it); 1818 remote_streams_.erase(it);
1822 1819
1823 if (peer_connection_tracker_) { 1820 if (peer_connection_tracker_) {
1824 peer_connection_tracker_->TrackRemoveStream( 1821 peer_connection_tracker_->TrackRemoveStream(
1825 this, webkit_stream, PeerConnectionTracker::SOURCE_REMOTE); 1822 this, webkit_stream, PeerConnectionTracker::SOURCE_REMOTE);
1826 } 1823 }
1827 1824
1828 if (!is_closed_) 1825 if (!is_closed_)
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 } 1950 }
1954 1951
1955 void RTCPeerConnectionHandler::ResetUMAStats() { 1952 void RTCPeerConnectionHandler::ResetUMAStats() {
1956 DCHECK(thread_checker_.CalledOnValidThread()); 1953 DCHECK(thread_checker_.CalledOnValidThread());
1957 num_local_candidates_ipv6_ = 0; 1954 num_local_candidates_ipv6_ = 0;
1958 num_local_candidates_ipv4_ = 0; 1955 num_local_candidates_ipv4_ = 0;
1959 ice_connection_checking_start_ = base::TimeTicks(); 1956 ice_connection_checking_start_ = base::TimeTicks();
1960 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); 1957 memset(ice_state_seen_, 0, sizeof(ice_state_seen_));
1961 } 1958 }
1962 } // namespace content 1959 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_peer_connection_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698