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> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/lazy_instance.h" | |
14 #include "base/logging.h" | 13 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
17 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
19 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
20 #include "content/renderer/media/media_stream_track.h" | 19 #include "content/renderer/media/media_stream_track.h" |
21 #include "content/renderer/media/peer_connection_tracker.h" | 20 #include "content/renderer/media/peer_connection_tracker.h" |
22 #include "content/renderer/media/remote_media_stream_impl.h" | 21 #include "content/renderer/media/remote_media_stream_impl.h" |
23 #include "content/renderer/media/rtc_data_channel_handler.h" | 22 #include "content/renderer/media/rtc_data_channel_handler.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 double timestamp) { | 310 double timestamp) { |
312 return impl_.addReport(type, id, timestamp); | 311 return impl_.addReport(type, id, timestamp); |
313 } | 312 } |
314 | 313 |
315 void LocalRTCStatsResponse::addStatistic(size_t report, | 314 void LocalRTCStatsResponse::addStatistic(size_t report, |
316 blink::WebString name, | 315 blink::WebString name, |
317 blink::WebString value) { | 316 blink::WebString value) { |
318 impl_.addStatistic(report, name, value); | 317 impl_.addStatistic(report, name, value); |
319 } | 318 } |
320 | 319 |
321 namespace { | |
322 | |
323 class PeerConnectionUMAObserver : public webrtc::UMAObserver { | 320 class PeerConnectionUMAObserver : public webrtc::UMAObserver { |
324 public: | 321 public: |
325 PeerConnectionUMAObserver() {} | 322 PeerConnectionUMAObserver() {} |
326 virtual ~PeerConnectionUMAObserver() {} | 323 virtual ~PeerConnectionUMAObserver() {} |
327 | 324 |
328 virtual void IncrementCounter( | 325 virtual void IncrementCounter( |
329 webrtc::PeerConnectionUMAMetricsCounter counter) OVERRIDE { | 326 webrtc::PeerConnectionUMAMetricsCounter counter) OVERRIDE { |
330 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.IPMetrics", | 327 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.IPMetrics", |
331 counter, | 328 counter, |
332 webrtc::kBoundary); | 329 webrtc::kBoundary); |
(...skipping 14 matching lines...) Expand all Loading... |
347 case webrtc::kNetworkInterfaces_IPv6: | 344 case webrtc::kNetworkInterfaces_IPv6: |
348 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6Interfaces", | 345 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6Interfaces", |
349 value); | 346 value); |
350 break; | 347 break; |
351 default: | 348 default: |
352 NOTREACHED(); | 349 NOTREACHED(); |
353 } | 350 } |
354 } | 351 } |
355 }; | 352 }; |
356 | 353 |
357 base::LazyInstance<std::set<RTCPeerConnectionHandler*> >::Leaky | |
358 g_peer_connection_handlers = LAZY_INSTANCE_INITIALIZER; | |
359 | |
360 } // namespace | |
361 | |
362 RTCPeerConnectionHandler::RTCPeerConnectionHandler( | 354 RTCPeerConnectionHandler::RTCPeerConnectionHandler( |
363 blink::WebRTCPeerConnectionHandlerClient* client, | 355 blink::WebRTCPeerConnectionHandlerClient* client, |
364 PeerConnectionDependencyFactory* dependency_factory) | 356 PeerConnectionDependencyFactory* dependency_factory) |
365 : client_(client), | 357 : client_(client), |
366 dependency_factory_(dependency_factory), | 358 dependency_factory_(dependency_factory), |
367 frame_(NULL), | 359 frame_(NULL), |
368 peer_connection_tracker_(NULL), | 360 peer_connection_tracker_(NULL), |
369 num_data_channels_created_(0) { | 361 num_data_channels_created_(0) { |
370 g_peer_connection_handlers.Get().insert(this); | |
371 } | 362 } |
372 | 363 |
373 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { | 364 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { |
374 g_peer_connection_handlers.Get().erase(this); | |
375 if (peer_connection_tracker_) | 365 if (peer_connection_tracker_) |
376 peer_connection_tracker_->UnregisterPeerConnection(this); | 366 peer_connection_tracker_->UnregisterPeerConnection(this); |
377 STLDeleteValues(&remote_streams_); | 367 STLDeleteValues(&remote_streams_); |
378 | 368 |
379 UMA_HISTOGRAM_COUNTS_10000( | 369 UMA_HISTOGRAM_COUNTS_10000( |
380 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_); | 370 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_); |
381 } | 371 } |
382 | 372 |
383 // static | |
384 void RTCPeerConnectionHandler::DestructAllHandlers() { | |
385 std::set<RTCPeerConnectionHandler*> handlers( | |
386 g_peer_connection_handlers.Get().begin(), | |
387 g_peer_connection_handlers.Get().end()); | |
388 for (std::set<RTCPeerConnectionHandler*>::iterator handler = handlers.begin(); | |
389 handler != handlers.end(); | |
390 ++handler) { | |
391 (*handler)->client_->releasePeerConnectionHandler(); | |
392 } | |
393 } | |
394 | |
395 void RTCPeerConnectionHandler::associateWithFrame(blink::WebFrame* frame) { | 373 void RTCPeerConnectionHandler::associateWithFrame(blink::WebFrame* frame) { |
396 DCHECK(frame); | 374 DCHECK(frame); |
397 frame_ = frame; | 375 frame_ = frame; |
398 } | 376 } |
399 | 377 |
400 bool RTCPeerConnectionHandler::initialize( | 378 bool RTCPeerConnectionHandler::initialize( |
401 const blink::WebRTCConfiguration& server_configuration, | 379 const blink::WebRTCConfiguration& server_configuration, |
402 const blink::WebMediaConstraints& options) { | 380 const blink::WebMediaConstraints& options) { |
403 DCHECK(frame_); | 381 DCHECK(frame_); |
404 | 382 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 webrtc::SessionDescriptionInterface* native_desc = | 898 webrtc::SessionDescriptionInterface* native_desc = |
921 dependency_factory_->CreateSessionDescription(type, sdp, error); | 899 dependency_factory_->CreateSessionDescription(type, sdp, error); |
922 | 900 |
923 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 901 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
924 << " Type: " << type << " SDP: " << sdp; | 902 << " Type: " << type << " SDP: " << sdp; |
925 | 903 |
926 return native_desc; | 904 return native_desc; |
927 } | 905 } |
928 | 906 |
929 } // namespace content | 907 } // namespace content |
OLD | NEW |