Chromium Code Reviews| Index: content/renderer/media/rtc_peer_connection_handler.cc |
| diff --git a/content/renderer/media/rtc_peer_connection_handler.cc b/content/renderer/media/rtc_peer_connection_handler.cc |
| index d11ba1b0cee4b820674c298e853e262db5620f16..7b3a6b44a650398caf578e577dab4a9cdfef6f46 100644 |
| --- a/content/renderer/media/rtc_peer_connection_handler.cc |
| +++ b/content/renderer/media/rtc_peer_connection_handler.cc |
| @@ -28,6 +28,7 @@ |
| #include "content/renderer/media/peer_connection_tracker.h" |
| #include "content/renderer/media/remote_media_stream_impl.h" |
| #include "content/renderer/media/rtc_certificate.h" |
| +#include "content/renderer/media/rtc_certificate_generator.h" |
| #include "content/renderer/media/rtc_data_channel_handler.h" |
| #include "content/renderer/media/rtc_dtmf_sender_handler.h" |
| #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| @@ -724,6 +725,30 @@ void ConvertConstraintsToWebrtcOfferOptions( |
| base::LazyInstance<std::set<RTCPeerConnectionHandler*> >::Leaky |
| g_peer_connection_handlers = LAZY_INSTANCE_INITIALIZER; |
| +void OverrideDefaultCertificateBasedOnExperiment( |
| + webrtc::PeerConnectionInterface::RTCConfiguration* config) { |
| + if (!config->certificates.empty()) |
| + return; // A certificate has already been set up to override the default. |
| + rtc::KeyType key_type; |
| + if (base::FeatureList::IsEnabled(features::kWebRtcEcdsaDefault)) { |
| + key_type = rtc::KT_ECDSA; |
| + } else { |
| + key_type = rtc::KT_RSA; |
| + } |
| + if (key_type != rtc::KT_DEFAULT) { |
|
tommi (sloooow) - chröme
2016/05/12 12:42:56
Can you add a static assert that ensure that KT_DE
hbos_chromium
2016/05/12 14:28:00
As discussed, that is not necessary. We should mak
|
| + rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
|
tommi (sloooow) - chröme
2016/05/12 12:42:56
avoid rtc:: types
hbos_chromium
2016/05/12 14:28:00
Done.
|
| + RTCCertificateGenerator::generateCertificateAndWait( |
| + rtc::KeyParams(key_type), rtc::Optional<uint64_t>()); |
| + if (!certificate) { |
| + // This should not happen, but if it does it is better than crashing. |
| + LOG(WARNING) << "Failed to generate certificate, will rely on default " |
| + "instead."; |
| + } else { |
| + config->certificates.push_back(certificate); |
| + } |
| + } |
| +} |
| + |
| } // namespace |
| // Implementation of LocalRTCStatsRequest. |
| @@ -954,14 +979,7 @@ bool RTCPeerConnectionHandler::initialize( |
| webrtc::PeerConnectionInterface::RTCConfiguration config; |
| GetNativeRtcConfiguration(server_configuration, &config); |
| - |
| - if (base::FeatureList::IsEnabled(features::kWebRtcEcdsaDefault)) { |
| - if (config.certificates.empty()) { |
| - rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
| - PeerConnectionDependencyFactory::GenerateDefaultCertificate(); |
| - config.certificates.push_back(certificate); |
| - } |
| - } |
| + OverrideDefaultCertificateBasedOnExperiment(&config); |
| // Choose between RTC smoothness algorithm and prerenderer smoothing. |
| // Prerenderer smoothing is turned on if RTC smoothness is turned off. |
| @@ -998,14 +1016,7 @@ bool RTCPeerConnectionHandler::InitializeForTest( |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| webrtc::PeerConnectionInterface::RTCConfiguration config; |
| GetNativeRtcConfiguration(server_configuration, &config); |
| - |
| - if (base::FeatureList::IsEnabled(features::kWebRtcEcdsaDefault)) { |
| - if (config.certificates.empty()) { |
| - rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
| - PeerConnectionDependencyFactory::GenerateDefaultCertificate(); |
| - config.certificates.push_back(certificate); |
| - } |
| - } |
| + OverrideDefaultCertificateBasedOnExperiment(&config); |
| peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); |
| CopyConstraintsIntoRtcConfiguration(options, &config); |