Migrate from deprecated SSLFingerprint::CreateUnique* factories Instead use shorter SSLFingerprint::Create* names with the same functionality. Update nearby checks for nullability to more modern practices. Mark old names deprecated to prevent new usages of it in WebRTC Bug: None Change-Id: I558806cd892737a8d0e55192c46d55e798e089c0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/478840 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47909}
diff --git a/api/webrtc_sdp.cc b/api/webrtc_sdp.cc index e090464..d96eeb0 100644 --- a/api/webrtc_sdp.cc +++ b/api/webrtc_sdp.cc
@@ -1627,8 +1627,8 @@ absl::c_transform(algorithm, algorithm.begin(), ::tolower); // The second field is the digest value. De-hexify it. - *fingerprint = SSLFingerprint::CreateUniqueFromRfc4572(algorithm, fields[1]); - if (!*fingerprint) { + *fingerprint = SSLFingerprint::CreateFromRfc4572(algorithm, fields[1]); + if (*fingerprint == nullptr) { return ParseFailed(line, "Failed to create fingerprint from the digest.", error); }
diff --git a/pc/jsep_transport.cc b/pc/jsep_transport.cc index 7605a70..8383b2c 100644 --- a/pc/jsep_transport.cc +++ b/pc/jsep_transport.cc
@@ -329,9 +329,9 @@ return RTCError(RTCErrorType::INVALID_PARAMETER, "Fingerprint provided but no identity available."); } - std::unique_ptr<SSLFingerprint> fp_tmp = SSLFingerprint::CreateUnique( - fingerprint->algorithm, *certificate->identity()); - RTC_DCHECK(fp_tmp.get() != nullptr); + std::unique_ptr<SSLFingerprint> fp_tmp = + SSLFingerprint::Create(fingerprint->algorithm, *certificate->identity()); + RTC_DCHECK(fp_tmp != nullptr); if (*fp_tmp == *fingerprint) { return RTCError::OK(); }
diff --git a/pc/jsep_transport_unittest.cc b/pc/jsep_transport_unittest.cc index 4f39259..12b5645 100644 --- a/pc/jsep_transport_unittest.cc +++ b/pc/jsep_transport_unittest.cc
@@ -496,9 +496,8 @@ &digest_algorithm)); ASSERT_FALSE(digest_algorithm.empty()); std::unique_ptr<SSLFingerprint> good_fingerprint = - SSLFingerprint::CreateUnique(digest_algorithm, - *certificate->identity()); - ASSERT_NE(nullptr, good_fingerprint); + SSLFingerprint::Create(digest_algorithm, *certificate->identity()); + ASSERT_NE(good_fingerprint, nullptr); EXPECT_TRUE(jsep_transport_ ->VerifyCertificateFingerprint(certificate.get(),
diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index c64467e..43e92ae 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc
@@ -4489,10 +4489,10 @@ void SetNewFingerprint(std::unique_ptr<SessionDescriptionInterface>& sdp) { auto identity = SSLIdentity::Create("NewIdentity", KT_DEFAULT); - auto new_fingerprint = SSLFingerprint::CreateUnique("sha-256", *identity); + auto new_fingerprint = SSLFingerprint::Create("sha-256", *identity); for (auto& transport_info : sdp->description()->transport_infos()) { transport_info.description.identity_fingerprint = - absl::WrapUnique(new SSLFingerprint(*new_fingerprint)); + std::make_unique<SSLFingerprint>(*new_fingerprint); } }
diff --git a/rtc_base/ssl_fingerprint.cc b/rtc_base/ssl_fingerprint.cc index 6758b5d..54daa1b 100644 --- a/rtc_base/ssl_fingerprint.cc +++ b/rtc_base/ssl_fingerprint.cc
@@ -76,8 +76,8 @@ } std::unique_ptr<SSLFingerprint> fingerprint = - CreateUnique(digest_alg, *cert.identity()); - if (!fingerprint) { + Create(digest_alg, *cert.identity()); + if (fingerprint == nullptr) { RTC_LOG(LS_ERROR) << "Failed to create identity fingerprint, alg=" << digest_alg; }
diff --git a/rtc_base/ssl_fingerprint.h b/rtc_base/ssl_fingerprint.h index b3bbe84..e51580b 100644 --- a/rtc_base/ssl_fingerprint.h +++ b/rtc_base/ssl_fingerprint.h
@@ -47,17 +47,16 @@ static absl_nullable std::unique_ptr<SSLFingerprint> CreateFromCertificate( const RTCCertificate& cert); - ABSL_DEPRECATE_AND_INLINE() - static absl_nullable std::unique_ptr<SSLFingerprint> CreateUnique( - absl::string_view algorithm, - const SSLIdentity& identity) { + [[deprecated]] ABSL_REFACTOR_INLINE static absl_nullable + std::unique_ptr<SSLFingerprint> + CreateUnique(absl::string_view algorithm, const SSLIdentity& identity) { return Create(algorithm, identity); } - ABSL_DEPRECATE_AND_INLINE() - static absl_nullable std::unique_ptr<SSLFingerprint> CreateUniqueFromRfc4572( - absl::string_view algorithm, - absl::string_view fingerprint) { + [[deprecated]] ABSL_REFACTOR_INLINE static absl_nullable + std::unique_ptr<SSLFingerprint> + CreateUniqueFromRfc4572(absl::string_view algorithm, + absl::string_view fingerprint) { return CreateFromRfc4572(algorithm, fingerprint); }