Reland: Modernize rtc::SSLCertificate

Bug: webrtc:9860
Change-Id: I2344e2333f68e5d58ca38dfc041a676692401312
Tbr: Benjamin Wright <benwright@webrtc.org>
Tbr: Qingsi Wang <qingsi@webrtc.org>
Reviewed-on: https://webrtc-review.googlesource.com/c/106604
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25225}
diff --git a/rtc_base/sslcertificate.cc b/rtc_base/sslcertificate.cc
index 53af0f5..d735ebf 100644
--- a/rtc_base/sslcertificate.cc
+++ b/rtc_base/sslcertificate.cc
@@ -30,7 +30,7 @@
     std::string&& fingerprint,
     std::string&& fingerprint_algorithm,
     std::string&& base64_certificate,
-    std::unique_ptr<SSLCertificateStats>&& issuer)
+    std::unique_ptr<SSLCertificateStats> issuer)
     : fingerprint(std::move(fingerprint)),
       fingerprint_algorithm(std::move(fingerprint_algorithm)),
       base64_certificate(std::move(base64_certificate)),
@@ -70,49 +70,30 @@
                                                 std::move(der_base64), nullptr);
 }
 
-std::unique_ptr<SSLCertificate> SSLCertificate::GetUniqueReference() const {
-  return absl::WrapUnique(GetReference());
-}
-
 //////////////////////////////////////////////////////////////////////
 // SSLCertChain
 //////////////////////////////////////////////////////////////////////
 
+SSLCertChain::SSLCertChain(std::unique_ptr<SSLCertificate> single_cert) {
+  certs_.push_back(std::move(single_cert));
+}
+
 SSLCertChain::SSLCertChain(std::vector<std::unique_ptr<SSLCertificate>> certs)
     : certs_(std::move(certs)) {}
 
-SSLCertChain::SSLCertChain(const std::vector<SSLCertificate*>& certs) {
-  RTC_DCHECK(!certs.empty());
-  certs_.resize(certs.size());
-  std::transform(
-      certs.begin(), certs.end(), certs_.begin(),
-      [](const SSLCertificate* cert) -> std::unique_ptr<SSLCertificate> {
-        return cert->GetUniqueReference();
-      });
-}
-
-SSLCertChain::SSLCertChain(const SSLCertificate* cert) {
-  certs_.push_back(cert->GetUniqueReference());
-}
-
 SSLCertChain::SSLCertChain(SSLCertChain&& rhs) = default;
 
 SSLCertChain& SSLCertChain::operator=(SSLCertChain&&) = default;
 
-SSLCertChain::~SSLCertChain() {}
+SSLCertChain::~SSLCertChain() = default;
 
-SSLCertChain* SSLCertChain::Copy() const {
+std::unique_ptr<SSLCertChain> SSLCertChain::Clone() const {
   std::vector<std::unique_ptr<SSLCertificate>> new_certs(certs_.size());
-  std::transform(certs_.begin(), certs_.end(), new_certs.begin(),
-                 [](const std::unique_ptr<SSLCertificate>& cert)
-                     -> std::unique_ptr<SSLCertificate> {
-                   return cert->GetUniqueReference();
-                 });
-  return new SSLCertChain(std::move(new_certs));
-}
-
-std::unique_ptr<SSLCertChain> SSLCertChain::UniqueCopy() const {
-  return absl::WrapUnique(Copy());
+  std::transform(
+      certs_.begin(), certs_.end(), new_certs.begin(),
+      [](const std::unique_ptr<SSLCertificate>& cert)
+          -> std::unique_ptr<SSLCertificate> { return cert->Clone(); });
+  return absl::make_unique<SSLCertChain>(std::move(new_certs));
 }
 
 std::unique_ptr<SSLCertificateStats> SSLCertChain::GetStats() const {
@@ -134,7 +115,8 @@
 }
 
 // static
-SSLCertificate* SSLCertificate::FromPEMString(const std::string& pem_string) {
+std::unique_ptr<SSLCertificate> SSLCertificate::FromPEMString(
+    const std::string& pem_string) {
   return OpenSSLCertificate::FromPEMString(pem_string);
 }