diff options
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 |