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