| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_certificate_generator.h" | 5 #include "content/renderer/media/rtc_certificate_generator.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "content/renderer/media/peer_connection_identity_store.h" | 9 #include "content/renderer/media/peer_connection_identity_store.h" |
| 8 #include "content/renderer/media/rtc_certificate.h" | 10 #include "content/renderer/media/rtc_certificate.h" |
| 9 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 11 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| 10 #include "content/renderer/render_thread_impl.h" | 12 #include "content/renderer/render_thread_impl.h" |
| 11 #include "third_party/webrtc/base/rtccertificate.h" | 13 #include "third_party/webrtc/base/rtccertificate.h" |
| 12 #include "third_party/webrtc/base/scoped_ref_ptr.h" | 14 #include "third_party/webrtc/base/scoped_ref_ptr.h" |
| 13 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 14 | 16 |
| 15 namespace content { | 17 namespace content { |
| 16 namespace { | 18 namespace { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void OnSuccess(const std::string& der_cert, | 90 void OnSuccess(const std::string& der_cert, |
| 89 const std::string& der_private_key) override { | 91 const std::string& der_private_key) override { |
| 90 std::string pem_cert = rtc::SSLIdentity::DerToPem( | 92 std::string pem_cert = rtc::SSLIdentity::DerToPem( |
| 91 rtc::kPemTypeCertificate, | 93 rtc::kPemTypeCertificate, |
| 92 reinterpret_cast<const unsigned char*>(der_cert.data()), | 94 reinterpret_cast<const unsigned char*>(der_cert.data()), |
| 93 der_cert.length()); | 95 der_cert.length()); |
| 94 std::string pem_key = rtc::SSLIdentity::DerToPem( | 96 std::string pem_key = rtc::SSLIdentity::DerToPem( |
| 95 rtc::kPemTypeRsaPrivateKey, | 97 rtc::kPemTypeRsaPrivateKey, |
| 96 reinterpret_cast<const unsigned char*>(der_private_key.data()), | 98 reinterpret_cast<const unsigned char*>(der_private_key.data()), |
| 97 der_private_key.length()); | 99 der_private_key.length()); |
| 98 rtc::scoped_ptr<rtc::SSLIdentity> identity( | 100 OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity>( |
| 99 rtc::SSLIdentity::FromPEMStrings(pem_key, pem_cert)); | 101 rtc::SSLIdentity::FromPEMStrings(pem_key, pem_cert))); |
| 100 OnSuccess(identity.Pass()); | |
| 101 } | 102 } |
| 102 void OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity> identity) override { | 103 void OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity> identity) override { |
| 103 DCHECK(signaling_thread_->BelongsToCurrentThread()); | 104 DCHECK(signaling_thread_->BelongsToCurrentThread()); |
| 104 DCHECK(observer_); | 105 DCHECK(observer_); |
| 105 rtc::scoped_refptr<rtc::RTCCertificate> certificate = | 106 rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
| 106 rtc::RTCCertificate::Create(identity.Pass()); | 107 rtc::RTCCertificate::Create(std::move(identity)); |
| 107 main_thread_->PostTask(FROM_HERE, base::Bind( | 108 main_thread_->PostTask(FROM_HERE, base::Bind( |
| 108 &RTCCertificateIdentityObserver::DoCallbackOnMainThread, | 109 &RTCCertificateIdentityObserver::DoCallbackOnMainThread, |
| 109 this, new RTCCertificate(key_params_, certificate))); | 110 this, new RTCCertificate(key_params_, certificate))); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void DoCallbackOnMainThread(blink::WebRTCCertificate* certificate) { | 113 void DoCallbackOnMainThread(blink::WebRTCCertificate* certificate) { |
| 113 DCHECK(main_thread_->BelongsToCurrentThread()); | 114 DCHECK(main_thread_->BelongsToCurrentThread()); |
| 114 DCHECK(observer_); | 115 DCHECK(observer_); |
| 115 if (certificate) | 116 if (certificate) |
| 116 observer_->onSuccess(certificate); | 117 observer_->onSuccess(certificate); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 observer->onError(); | 159 observer->onError(); |
| 159 #endif | 160 #endif |
| 160 } | 161 } |
| 161 | 162 |
| 162 bool RTCCertificateGenerator::isSupportedKeyParams( | 163 bool RTCCertificateGenerator::isSupportedKeyParams( |
| 163 const blink::WebRTCKeyParams& key_params) { | 164 const blink::WebRTCKeyParams& key_params) { |
| 164 return WebRTCKeyParamsToKeyParams(key_params).IsValid(); | 165 return WebRTCKeyParamsToKeyParams(key_params).IsValid(); |
| 165 } | 166 } |
| 166 | 167 |
| 167 } // namespace content | 168 } // namespace content |
| OLD | NEW |