diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /dom/url/URLMainThread.cpp | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/url/URLMainThread.cpp')
-rw-r--r-- | dom/url/URLMainThread.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/dom/url/URLMainThread.cpp b/dom/url/URLMainThread.cpp index 95afd0db45..fb57be4401 100644 --- a/dom/url/URLMainThread.cpp +++ b/dom/url/URLMainThread.cpp @@ -19,7 +19,7 @@ namespace mozilla::dom { /* static */ void URLMainThread::CreateObjectURL(const GlobalObject& aGlobal, Blob& aBlob, - nsAString& aResult, ErrorResult& aRv) { + nsACString& aResult, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports()); @@ -41,20 +41,18 @@ void URLMainThread::CreateObjectURL(const GlobalObject& aGlobal, Blob& aBlob, nsCOMPtr<nsIPrincipal> principal = nsContentUtils::ObjectPrincipal(aGlobal.Get()); - nsAutoCString url; aRv = BlobURLProtocolHandler::AddDataEntry( - aBlob.Impl(), principal, NS_ConvertUTF16toUTF8(partKey), url); + aBlob.Impl(), principal, NS_ConvertUTF16toUTF8(partKey), aResult); if (NS_WARN_IF(aRv.Failed())) { return; } - global->RegisterHostObjectURI(url); - CopyASCIItoUTF16(url, aResult); + global->RegisterHostObjectURI(aResult); } /* static */ void URLMainThread::CreateObjectURL(const GlobalObject& aGlobal, - MediaSource& aSource, nsAString& aResult, + MediaSource& aSource, nsACString& aResult, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); @@ -77,25 +75,23 @@ void URLMainThread::CreateObjectURL(const GlobalObject& aGlobal, nsCOMPtr<nsIPrincipal> principal = nsContentUtils::ObjectPrincipal(aGlobal.Get()); - nsAutoCString url; aRv = BlobURLProtocolHandler::AddDataEntry( - &aSource, principal, NS_ConvertUTF16toUTF8(partKey), url); + &aSource, principal, NS_ConvertUTF16toUTF8(partKey), aResult); if (NS_WARN_IF(aRv.Failed())) { return; } nsCOMPtr<nsIRunnable> revocation = NS_NewRunnableFunction( - "dom::URLMainThread::CreateObjectURL", - [url] { BlobURLProtocolHandler::RemoveDataEntry(url); }); + "dom::URLMainThread::CreateObjectURL", [result = nsCString(aResult)] { + BlobURLProtocolHandler::RemoveDataEntry(result); + }); nsContentUtils::RunInStableState(revocation.forget()); - - CopyASCIItoUTF16(url, aResult); } /* static */ void URLMainThread::RevokeObjectURL(const GlobalObject& aGlobal, - const nsAString& aURL, ErrorResult& aRv) { + const nsACString& aURL, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports()); if (!global) { @@ -113,21 +109,18 @@ void URLMainThread::RevokeObjectURL(const GlobalObject& aGlobal, } } - NS_LossyConvertUTF16toASCII asciiurl(aURL); - if (BlobURLProtocolHandler::RemoveDataEntry( - asciiurl, nsContentUtils::ObjectPrincipal(aGlobal.Get()), + aURL, nsContentUtils::ObjectPrincipal(aGlobal.Get()), NS_ConvertUTF16toUTF8(partKey))) { - global->UnregisterHostObjectURI(asciiurl); + global->UnregisterHostObjectURI(aURL); } } /* static */ bool URLMainThread::IsValidObjectURL(const GlobalObject& aGlobal, - const nsAString& aURL, ErrorResult& aRv) { + const nsACString& aURL, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); - NS_LossyConvertUTF16toASCII asciiurl(aURL); - return BlobURLProtocolHandler::HasDataEntry(asciiurl); + return BlobURLProtocolHandler::HasDataEntry(aURL); } } // namespace mozilla::dom |