From 21b2b112f4b8acd3a23e21507b14b108fdd5dec2 Mon Sep 17 00:00:00 2001 From: Niklas Goegge Date: Thu, 4 Nov 2021 08:55:46 +0000 Subject: [PATCH] Bug 1724152: Replace GkRustUtils::GenerateUUID with nsID::GenerateUUID. r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D129633 --- Cargo.lock | 1 - caps/NullPrincipal.cpp | 12 +++--------- xpcom/base/GkRustUtils.cpp | 6 ------ xpcom/base/GkRustUtils.h | 1 - xpcom/rust/gkrust_utils/Cargo.toml | 1 - xpcom/rust/gkrust_utils/src/lib.rs | 10 ---------- 6 files changed, 3 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 377d05bfb138..7f9615f59650 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1964,7 +1964,6 @@ version = "0.1.0" dependencies = [ "nsstring", "semver", - "uuid", ] [[package]] diff --git a/caps/NullPrincipal.cpp b/caps/NullPrincipal.cpp index 31e3e2b2b940..aa9bdad4e64c 100644 --- a/caps/NullPrincipal.cpp +++ b/caps/NullPrincipal.cpp @@ -85,17 +85,11 @@ already_AddRefed NullPrincipal::CreateURI( iMutator = new mozilla::net::nsSimpleURI::Mutator(); } - nsAutoCStringN uuid; - if (aNullPrincipalID) { - // FIXME: When D119267 lands, clean this up on top of those changes. - aNullPrincipalID->ToProvidedString(*reinterpret_cast( - uuid.GetMutableData(NSID_LENGTH - 1).data())); - } else { - GkRustUtils::GenerateUUID(uuid); - } + nsID uuid = aNullPrincipalID ? *aNullPrincipalID : nsID::GenerateUUID(); NS_MutateURI mutator(iMutator); - mutator.SetSpec(NS_NULLPRINCIPAL_SCHEME ":"_ns + uuid); + mutator.SetSpec(NS_NULLPRINCIPAL_SCHEME ":"_ns + + nsDependentCString(nsIDToCString(uuid).get())); // If there's a precursor URI, encode it in the null principal URI's query. if (aPrecursor) { diff --git a/xpcom/base/GkRustUtils.cpp b/xpcom/base/GkRustUtils.cpp index 70f9d390b0cf..00d32e6f656c 100644 --- a/xpcom/base/GkRustUtils.cpp +++ b/xpcom/base/GkRustUtils.cpp @@ -5,16 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gk_rust_utils_ffi_generated.h" -#include "nsString.h" #include "GkRustUtils.h" using namespace mozilla; -/* static */ -void GkRustUtils::GenerateUUID(nsACString& aResult) { - GkRustUtils_GenerateUUID(&aResult); -}; - /* static */ bool GkRustUtils::ParseSemVer(const nsACString& aVersion, uint64_t& aOutMajor, uint64_t& aOutMinor, uint64_t& aOutPatch) { diff --git a/xpcom/base/GkRustUtils.h b/xpcom/base/GkRustUtils.h index f77d96d6ac1e..b7f8c3b99cf7 100644 --- a/xpcom/base/GkRustUtils.h +++ b/xpcom/base/GkRustUtils.h @@ -11,7 +11,6 @@ class GkRustUtils { public: - static void GenerateUUID(nsACString& aResult); static bool ParseSemVer(const nsACString& aVersion, uint64_t& aOutMajor, uint64_t& aOutMinor, uint64_t& aOutPatch); }; diff --git a/xpcom/rust/gkrust_utils/Cargo.toml b/xpcom/rust/gkrust_utils/Cargo.toml index 3a484b68dd75..3df425fcecb0 100644 --- a/xpcom/rust/gkrust_utils/Cargo.toml +++ b/xpcom/rust/gkrust_utils/Cargo.toml @@ -4,6 +4,5 @@ version = "0.1.0" authors = ["Jonathan Kingston "] [dependencies] -uuid = { version = "0.8", features = ["v4"] } semver = "0.9" nsstring = { path = "../nsstring" } diff --git a/xpcom/rust/gkrust_utils/src/lib.rs b/xpcom/rust/gkrust_utils/src/lib.rs index a733ece897c3..c519d7e002ea 100644 --- a/xpcom/rust/gkrust_utils/src/lib.rs +++ b/xpcom/rust/gkrust_utils/src/lib.rs @@ -4,17 +4,7 @@ extern crate nsstring; extern crate semver; -extern crate uuid; use nsstring::nsACString; -use uuid::Uuid; - -use std::fmt::Write; - -#[no_mangle] -pub extern "C" fn GkRustUtils_GenerateUUID(res: &mut nsACString) { - let uuid = Uuid::new_v4(); - write!(res, "{{{}}}", uuid.to_hyphenated_ref()).expect("Unexpected uuid generated"); -} #[no_mangle] pub unsafe extern "C" fn GkRustUtils_ParseSemVer(