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 <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 &RTCCertificateIdentityObserver::RequestIdentityOnWebRtcSignalingThread, | 69 &RTCCertificateIdentityObserver::RequestIdentityOnWebRtcSignalingThread, |
70 this, url, first_party_for_cookies, expires_ms)); | 70 this, url, first_party_for_cookies, expires_ms)); |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 void RequestIdentityOnWebRtcSignalingThread( | 74 void RequestIdentityOnWebRtcSignalingThread( |
75 GURL url, | 75 GURL url, |
76 GURL first_party_for_cookies, | 76 GURL first_party_for_cookies, |
77 rtc::Optional<uint64_t> expires_ms) { | 77 rtc::Optional<uint64_t> expires_ms) { |
78 DCHECK(signaling_thread_->BelongsToCurrentThread()); | 78 DCHECK(signaling_thread_->BelongsToCurrentThread()); |
79 rtc::scoped_ptr<PeerConnectionIdentityStore> store( | 79 std::unique_ptr<PeerConnectionIdentityStore> store( |
80 new PeerConnectionIdentityStore(main_thread_, signaling_thread_, url, | 80 new PeerConnectionIdentityStore(main_thread_, signaling_thread_, url, |
81 first_party_for_cookies)); | 81 first_party_for_cookies)); |
82 // Request identity with |this| as the observer. OnSuccess/OnFailure will be | 82 // Request identity with |this| as the observer. OnSuccess/OnFailure will be |
83 // called asynchronously. | 83 // called asynchronously. |
84 store->RequestIdentity(WebRTCKeyParamsToKeyParams(key_params_), | 84 store->RequestIdentity(WebRTCKeyParamsToKeyParams(key_params_), |
85 expires_ms, this); | 85 expires_ms, this); |
86 } | 86 } |
87 | 87 |
88 // webrtc::DtlsIdentityRequestObserver implementation. | 88 // webrtc::DtlsIdentityRequestObserver implementation. |
89 void OnFailure(int error) override { | 89 void OnFailure(int error) override { |
90 DCHECK(signaling_thread_->BelongsToCurrentThread()); | 90 DCHECK(signaling_thread_->BelongsToCurrentThread()); |
91 DCHECK(observer_); | 91 DCHECK(observer_); |
92 main_thread_->PostTask(FROM_HERE, base::Bind( | 92 main_thread_->PostTask(FROM_HERE, base::Bind( |
93 &RTCCertificateIdentityObserver::DoCallbackOnMainThread, | 93 &RTCCertificateIdentityObserver::DoCallbackOnMainThread, |
94 this, nullptr)); | 94 this, nullptr)); |
95 } | 95 } |
96 void OnSuccess(const std::string& der_cert, | 96 void OnSuccess(const std::string& der_cert, |
97 const std::string& der_private_key) override { | 97 const std::string& der_private_key) override { |
98 std::string pem_cert = rtc::SSLIdentity::DerToPem( | 98 std::string pem_cert = rtc::SSLIdentity::DerToPem( |
99 rtc::kPemTypeCertificate, | 99 rtc::kPemTypeCertificate, |
100 reinterpret_cast<const unsigned char*>(der_cert.data()), | 100 reinterpret_cast<const unsigned char*>(der_cert.data()), |
101 der_cert.length()); | 101 der_cert.length()); |
102 std::string pem_key = rtc::SSLIdentity::DerToPem( | 102 std::string pem_key = rtc::SSLIdentity::DerToPem( |
103 rtc::kPemTypeRsaPrivateKey, | 103 rtc::kPemTypeRsaPrivateKey, |
104 reinterpret_cast<const unsigned char*>(der_private_key.data()), | 104 reinterpret_cast<const unsigned char*>(der_private_key.data()), |
105 der_private_key.length()); | 105 der_private_key.length()); |
106 OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity>( | 106 OnSuccess(std::unique_ptr<rtc::SSLIdentity>( |
107 rtc::SSLIdentity::FromPEMStrings(pem_key, pem_cert))); | 107 rtc::SSLIdentity::FromPEMStrings(pem_key, pem_cert))); |
108 } | 108 } |
109 void OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity> identity) override { | 109 void OnSuccess(std::unique_ptr<rtc::SSLIdentity> identity) override { |
110 DCHECK(signaling_thread_->BelongsToCurrentThread()); | 110 DCHECK(signaling_thread_->BelongsToCurrentThread()); |
111 DCHECK(observer_); | 111 DCHECK(observer_); |
112 rtc::scoped_refptr<rtc::RTCCertificate> certificate = | 112 rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
113 rtc::RTCCertificate::Create(std::move(identity)); | 113 rtc::RTCCertificate::Create(std::move(identity)); |
114 main_thread_->PostTask( | 114 main_thread_->PostTask( |
115 FROM_HERE, | 115 FROM_HERE, |
116 base::Bind(&RTCCertificateIdentityObserver::DoCallbackOnMainThread, | 116 base::Bind(&RTCCertificateIdentityObserver::DoCallbackOnMainThread, |
117 this, base::Passed(base::WrapUnique( | 117 this, base::Passed(base::WrapUnique( |
118 new RTCCertificate(key_params_, certificate))))); | 118 new RTCCertificate(key_params_, certificate))))); |
119 } | 119 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 observer->onError(); | 191 observer->onError(); |
192 #endif | 192 #endif |
193 } | 193 } |
194 | 194 |
195 bool RTCCertificateGenerator::isSupportedKeyParams( | 195 bool RTCCertificateGenerator::isSupportedKeyParams( |
196 const blink::WebRTCKeyParams& key_params) { | 196 const blink::WebRTCKeyParams& key_params) { |
197 return WebRTCKeyParamsToKeyParams(key_params).IsValid(); | 197 return WebRTCKeyParamsToKeyParams(key_params).IsValid(); |
198 } | 198 } |
199 | 199 |
200 } // namespace content | 200 } // namespace content |
OLD | NEW |