diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /dom/cache/Cache.cpp | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/cache/Cache.cpp')
-rw-r--r-- | dom/cache/Cache.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/dom/cache/Cache.cpp b/dom/cache/Cache.cpp index 3f84e08e66..78480022c1 100644 --- a/dom/cache/Cache.cpp +++ b/dom/cache/Cache.cpp @@ -34,12 +34,11 @@ namespace { enum class PutStatusPolicy { Default, RequireOK }; -bool IsValidPutRequestURL(const nsAString& aUrl, ErrorResult& aRv) { +bool IsValidPutRequestURL(const nsACString& aUrl, ErrorResult& aRv) { bool validScheme = false; // make a copy because ProcessURL strips the fragmet - NS_ConvertUTF16toUTF8 url(aUrl); - + nsAutoCString url(aUrl); TypeUtils::ProcessURL(url, &validScheme, nullptr, nullptr, aRv); if (aRv.Failed()) { return false; @@ -47,8 +46,7 @@ bool IsValidPutRequestURL(const nsAString& aUrl, ErrorResult& aRv) { if (!validScheme) { // `url` has been modified, so don't use it here. - aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>("Request", - NS_ConvertUTF16toUTF8(aUrl)); + aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>("Request", aUrl); return false; } @@ -66,7 +64,7 @@ static bool IsValidPutRequestMethod(const Request& aRequest, ErrorResult& aRv) { return true; } -static bool IsValidPutRequestMethod(const RequestOrUSVString& aRequest, +static bool IsValidPutRequestMethod(const RequestOrUTF8String& aRequest, ErrorResult& aRv) { // If the provided request is a string URL, then it will default to // a valid http method automatically. @@ -81,12 +79,10 @@ static bool IsValidPutResponseStatus(Response& aResponse, ErrorResult& aRv) { if ((aPolicy == PutStatusPolicy::RequireOK && !aResponse.Ok()) || aResponse.Status() == 206) { - nsAutoString url; + nsAutoCString url; aResponse.GetUrl(url); - aRv.ThrowTypeError<MSG_CACHE_ADD_FAILED_RESPONSE>( - GetEnumString(aResponse.Type()), IntToCString(aResponse.Status()), - NS_ConvertUTF16toUTF8(url)); + GetEnumString(aResponse.Type()), IntToCString(aResponse.Status()), url); return false; } @@ -228,7 +224,7 @@ Cache::Cache(nsIGlobalObject* aGlobal, CacheChild* aActor, Namespace aNamespace) } already_AddRefed<Promise> Cache::Match(JSContext* aCx, - const RequestOrUSVString& aRequest, + const RequestOrUTF8String& aRequest, const CacheQueryOptions& aOptions, ErrorResult& aRv) { if (NS_WARN_IF(!mActor)) { @@ -259,7 +255,7 @@ already_AddRefed<Promise> Cache::Match(JSContext* aCx, } already_AddRefed<Promise> Cache::MatchAll( - JSContext* aCx, const Optional<RequestOrUSVString>& aRequest, + JSContext* aCx, const Optional<RequestOrUTF8String>& aRequest, const CacheQueryOptions& aOptions, ErrorResult& aRv) { if (NS_WARN_IF(!mActor)) { aRv.Throw(NS_ERROR_UNEXPECTED); @@ -291,7 +287,7 @@ already_AddRefed<Promise> Cache::MatchAll( } already_AddRefed<Promise> Cache::Add(JSContext* aContext, - const RequestOrUSVString& aRequest, + const RequestOrUTF8String& aRequest, CallerType aCallerType, ErrorResult& aRv) { if (NS_WARN_IF(!mActor)) { aRv.Throw(NS_ERROR_UNEXPECTED); @@ -315,7 +311,7 @@ already_AddRefed<Promise> Cache::Add(JSContext* aContext, return nullptr; } - nsAutoString url; + nsAutoCString url; request->GetUrl(url); if (NS_WARN_IF(!IsValidPutRequestURL(url, aRv))) { return nullptr; @@ -326,7 +322,8 @@ already_AddRefed<Promise> Cache::Add(JSContext* aContext, } already_AddRefed<Promise> Cache::AddAll( - JSContext* aContext, const Sequence<OwningRequestOrUSVString>& aRequestList, + JSContext* aContext, + const Sequence<OwningRequestOrUTF8String>& aRequestList, CallerType aCallerType, ErrorResult& aRv) { if (NS_WARN_IF(!mActor)) { aRv.Throw(NS_ERROR_UNEXPECTED); @@ -340,7 +337,7 @@ already_AddRefed<Promise> Cache::AddAll( nsTArray<SafeRefPtr<Request>> requestList(aRequestList.Length()); for (uint32_t i = 0; i < aRequestList.Length(); ++i) { - RequestOrUSVString requestOrString; + RequestOrUTF8String requestOrString; if (aRequestList[i].IsRequest()) { requestOrString.SetAsRequest() = aRequestList[i].GetAsRequest(); @@ -349,8 +346,8 @@ already_AddRefed<Promise> Cache::AddAll( return nullptr; } } else { - requestOrString.SetAsUSVString().ShareOrDependUpon( - aRequestList[i].GetAsUSVString()); + requestOrString.SetAsUTF8String().ShareOrDependUpon( + aRequestList[i].GetAsUTF8String()); } RootedDictionary<RequestInit> requestInit(aContext); @@ -360,7 +357,7 @@ already_AddRefed<Promise> Cache::AddAll( return nullptr; } - nsAutoString url; + nsAutoCString url; request->GetUrl(url); if (NS_WARN_IF(!IsValidPutRequestURL(url, aRv))) { return nullptr; @@ -373,7 +370,7 @@ already_AddRefed<Promise> Cache::AddAll( } already_AddRefed<Promise> Cache::Put(JSContext* aCx, - const RequestOrUSVString& aRequest, + const RequestOrUTF8String& aRequest, Response& aResponse, ErrorResult& aRv) { if (NS_WARN_IF(!mActor)) { aRv.Throw(NS_ERROR_UNEXPECTED); @@ -418,7 +415,7 @@ already_AddRefed<Promise> Cache::Put(JSContext* aCx, } already_AddRefed<Promise> Cache::Delete(JSContext* aCx, - const RequestOrUSVString& aRequest, + const RequestOrUTF8String& aRequest, const CacheQueryOptions& aOptions, ErrorResult& aRv) { if (NS_WARN_IF(!mActor)) { @@ -448,7 +445,7 @@ already_AddRefed<Promise> Cache::Delete(JSContext* aCx, } already_AddRefed<Promise> Cache::Keys( - JSContext* aCx, const Optional<RequestOrUSVString>& aRequest, + JSContext* aCx, const Optional<RequestOrUTF8String>& aRequest, const CacheQueryOptions& aOptions, ErrorResult& aRv) { if (NS_WARN_IF(!mActor)) { aRv.Throw(NS_ERROR_UNEXPECTED); @@ -552,7 +549,7 @@ already_AddRefed<Promise> Cache::AddAll( // future once fetch supports it. for (uint32_t i = 0; i < aRequestList.Length(); ++i) { - RequestOrUSVString requestOrString; + RequestOrUTF8String requestOrString; requestOrString.SetAsRequest() = aRequestList[i].unsafeGetRawPtr(); RootedDictionary<RequestInit> requestInit(aGlobal.Context()); RefPtr<Promise> fetch = |