diff options
Diffstat (limited to 'dom/serviceworkers')
-rw-r--r-- | dom/serviceworkers/ServiceWorkerPrivate.cpp | 8 | ||||
-rw-r--r-- | dom/serviceworkers/ServiceWorkerScriptCache.cpp | 50 | ||||
-rw-r--r-- | dom/serviceworkers/ServiceWorkerScriptCache.h | 2 | ||||
-rw-r--r-- | dom/serviceworkers/ServiceWorkerUpdateJob.cpp | 3 |
4 files changed, 33 insertions, 30 deletions
diff --git a/dom/serviceworkers/ServiceWorkerPrivate.cpp b/dom/serviceworkers/ServiceWorkerPrivate.cpp index 864a598006..664874d991 100644 --- a/dom/serviceworkers/ServiceWorkerPrivate.cpp +++ b/dom/serviceworkers/ServiceWorkerPrivate.cpp @@ -324,7 +324,7 @@ Result<IPCInternalRequest, nsresult> GetIPCInternalRequest( RequestCredentials requestCredentials = InternalRequest::MapChannelToRequestCredentials(underlyingChannel); - nsAutoString referrer; + nsAutoCString referrer; ReferrerPolicy referrerPolicy = ReferrerPolicy::_empty; ReferrerPolicy environmentReferrerPolicy = ReferrerPolicy::_empty; @@ -544,10 +544,11 @@ nsresult ServiceWorkerPrivate::Initialize() { nsAutoString scheme; nsAutoString pkBaseDomain; int32_t unused; + bool unused2; if (OriginAttributes::ParsePartitionKey( principal->OriginAttributesRef().mPartitionKey, scheme, - pkBaseDomain, unused)) { + pkBaseDomain, unused, unused2)) { nsCOMPtr<nsIURI> firstPartyURI; rv = NS_NewURI(getter_AddRefs(firstPartyURI), scheme + u"://"_ns + pkBaseDomain); @@ -592,7 +593,8 @@ nsresult ServiceWorkerPrivate::Initialize() { } } } else { - net::CookieJarSettings::Cast(cookieJarSettings)->SetPartitionKey(uri); + net::CookieJarSettings::Cast(cookieJarSettings) + ->SetPartitionKey(uri, false); // The service worker is for a first-party context, we can use the uri of // the service worker as the first-party domain to get the fingerprinting diff --git a/dom/serviceworkers/ServiceWorkerScriptCache.cpp b/dom/serviceworkers/ServiceWorkerScriptCache.cpp index f1569ffe5f..00b69ebf45 100644 --- a/dom/serviceworkers/ServiceWorkerScriptCache.cpp +++ b/dom/serviceworkers/ServiceWorkerScriptCache.cpp @@ -114,7 +114,7 @@ class CompareNetwork final : public nsIStreamLoaderObserver, MOZ_ASSERT(NS_IsMainThread()); } - nsresult Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL, + nsresult Initialize(nsIPrincipal* aPrincipal, const nsACString& aURL, Cache* const aCache); void Abort(); @@ -123,7 +123,7 @@ class CompareNetwork final : public nsIStreamLoaderObserver, void CacheFinish(nsresult aRv); - const nsString& URL() const { + const nsCString& URL() const { MOZ_ASSERT(NS_IsMainThread()); return mURL; } @@ -164,7 +164,7 @@ class CompareNetwork final : public nsIStreamLoaderObserver, nsCOMPtr<nsIChannel> mChannel; nsString mBuffer; - nsString mURL; + nsCString mURL; ChannelInfo mChannelInfo; RefPtr<InternalHeaders> mInternalHeaders; UniquePtr<PrincipalInfo> mPrincipalInfo; @@ -204,7 +204,7 @@ class CompareCache final : public PromiseNativeHandler, MOZ_ASSERT(NS_IsMainThread()); } - nsresult Initialize(Cache* const aCache, const nsAString& aURL); + nsresult Initialize(Cache* const aCache, const nsACString& aURL); void Finish(nsresult aStatus, bool aInCache); @@ -231,7 +231,7 @@ class CompareCache final : public PromiseNativeHandler, RefPtr<CompareNetwork> mCN; nsCOMPtr<nsIInputStreamPump> mPump; - nsString mURL; + nsCString mURL; nsString mBuffer; enum { @@ -262,7 +262,7 @@ class CompareManager final : public PromiseNativeHandler { MOZ_ASSERT(aRegistration); } - nsresult Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL, + nsresult Initialize(nsIPrincipal* aPrincipal, const nsACString& aURL, const nsAString& aCacheName); void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue, @@ -326,7 +326,7 @@ class CompareManager final : public PromiseNativeHandler { void Cleanup(); - nsresult FetchScript(const nsAString& aURL, bool aIsMainScript, + nsresult FetchScript(const nsACString& aURL, bool aIsMainScript, Cache* const aCache = nullptr) { MOZ_ASSERT(NS_IsMainThread()); @@ -364,7 +364,7 @@ class CompareManager final : public PromiseNativeHandler { return; } - Optional<RequestOrUSVString> request; + Optional<RequestOrUTF8String> request; CacheQueryOptions options; ErrorResult error; RefPtr<Promise> promise = mOldCache->Keys(aCx, request, options, error); @@ -407,7 +407,7 @@ class CompareManager final : public PromiseNativeHandler { mState = WaitingForScriptOrComparisonResult; bool hasMainScript = false; - AutoTArray<nsString, 8> urlList; + AutoTArray<nsCString, 8> urlList; // Extract the list of URLs in the old cache. for (uint32_t i = 0; i < len; ++i) { @@ -423,14 +423,14 @@ class CompareManager final : public PromiseNativeHandler { return; }; - nsString url; + nsCString url; request->GetUrl(url); if (!hasMainScript && url == mURL) { hasMainScript = true; } - urlList.AppendElement(url); + urlList.AppendElement(std::move(url)); } // If the main script is missing, then something has gone wrong. We @@ -565,8 +565,8 @@ class CompareManager final : public PromiseNativeHandler { RefPtr<Response> response = new Response(aCache->GetGlobalObject(), std::move(ir), nullptr); - RequestOrUSVString request; - request.SetAsUSVString().ShareOrDependUpon(aCN->URL()); + RequestOrUTF8String request; + request.SetAsUTF8String().ShareOrDependUpon(aCN->URL()); // For now we have to wait until the Put Promise is fulfilled before we can // continue since Cache does not yet support starting a read that is being @@ -592,7 +592,7 @@ class CompareManager final : public PromiseNativeHandler { nsTArray<RefPtr<CompareNetwork>> mCNList; - nsString mURL; + nsCString mURL; RefPtr<nsIPrincipal> mPrincipal; // Used for the old cache where saves the old source scripts. @@ -622,7 +622,7 @@ class CompareManager final : public PromiseNativeHandler { NS_IMPL_ISUPPORTS0(CompareManager) nsresult CompareNetwork::Initialize(nsIPrincipal* aPrincipal, - const nsAString& aURL, + const nsACString& aURL, Cache* const aCache) { MOZ_ASSERT(aPrincipal); MOZ_ASSERT(NS_IsMainThread()); @@ -634,7 +634,7 @@ nsresult CompareNetwork::Initialize(nsIPrincipal* aPrincipal, } mURL = aURL; - mURLList.AppendElement(NS_ConvertUTF16toUTF8(mURL)); + mURLList.AppendElement(mURL); nsCOMPtr<nsILoadGroup> loadGroup; rv = NS_NewLoadGroup(getter_AddRefs(loadGroup), aPrincipal); @@ -678,7 +678,8 @@ nsresult CompareNetwork::Initialize(nsIPrincipal* aPrincipal, net::CookieJarSettings::Cast(cookieJarSettings) ->SetPartitionKey(aPrincipal->OriginAttributesRef().mPartitionKey); } else { - net::CookieJarSettings::Cast(cookieJarSettings)->SetPartitionKey(uri); + net::CookieJarSettings::Cast(cookieJarSettings) + ->SetPartitionKey(uri, false); } // Note that because there is no "serviceworker" RequestContext type, we can @@ -1044,7 +1045,7 @@ CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader, ServiceWorkerManager::LocalizeAndReportToAllClients( mRegistration->Scope(), "ServiceWorkerRegisterNetworkError", nsTArray<nsString>{NS_ConvertUTF8toUTF16(mRegistration->Scope()), - statusAsText, mURL}); + statusAsText, NS_ConvertUTF8toUTF16(mURL)}); rv = NS_ERROR_FAILURE; return NS_OK; @@ -1077,7 +1078,8 @@ CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader, ServiceWorkerManager::LocalizeAndReportToAllClients( mRegistration->Scope(), "ServiceWorkerRegisterMimeTypeError2", nsTArray<nsString>{NS_ConvertUTF8toUTF16(mRegistration->Scope()), - NS_ConvertUTF8toUTF16(mimeType), mURL}); + NS_ConvertUTF8toUTF16(mimeType), + NS_ConvertUTF8toUTF16(mURL)}); rv = NS_ERROR_DOM_SECURITY_ERR; return rv; } @@ -1114,7 +1116,7 @@ CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader, return NS_OK; } -nsresult CompareCache::Initialize(Cache* const aCache, const nsAString& aURL) { +nsresult CompareCache::Initialize(Cache* const aCache, const nsACString& aURL) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aCache); MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForInitialization); @@ -1124,8 +1126,8 @@ nsresult CompareCache::Initialize(Cache* const aCache, const nsAString& aURL) { AutoJSAPI jsapi; jsapi.Init(); - RequestOrUSVString request; - request.SetAsUSVString().ShareOrDependUpon(aURL); + RequestOrUTF8String request; + request.SetAsUTF8String().ShareOrDependUpon(aURL); ErrorResult error; CacheQueryOptions params; RefPtr<Promise> promise = aCache->Match(jsapi.cx(), request, params, error); @@ -1293,7 +1295,7 @@ void CompareCache::ManageValueResult(JSContext* aCx, } nsresult CompareManager::Initialize(nsIPrincipal* aPrincipal, - const nsAString& aURL, + const nsACString& aURL, const nsAString& aCacheName) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aPrincipal); @@ -1488,7 +1490,7 @@ nsresult GenerateCacheName(nsAString& aName) { nsresult Compare(ServiceWorkerRegistrationInfo* aRegistration, nsIPrincipal* aPrincipal, const nsAString& aCacheName, - const nsAString& aURL, CompareCallback* aCallback) { + const nsACString& aURL, CompareCallback* aCallback) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aRegistration); MOZ_ASSERT(aPrincipal); diff --git a/dom/serviceworkers/ServiceWorkerScriptCache.h b/dom/serviceworkers/ServiceWorkerScriptCache.h index 5d71840b46..8c71c42b1a 100644 --- a/dom/serviceworkers/ServiceWorkerScriptCache.h +++ b/dom/serviceworkers/ServiceWorkerScriptCache.h @@ -45,7 +45,7 @@ class CompareCallback { nsresult Compare(ServiceWorkerRegistrationInfo* aRegistration, nsIPrincipal* aPrincipal, const nsAString& aCacheName, - const nsAString& aURL, CompareCallback* aCallback); + const nsACString& aURL, CompareCallback* aCallback); } // namespace serviceWorkerScriptCache diff --git a/dom/serviceworkers/ServiceWorkerUpdateJob.cpp b/dom/serviceworkers/ServiceWorkerUpdateJob.cpp index a6726fbf47..25f86e164d 100644 --- a/dom/serviceworkers/ServiceWorkerUpdateJob.cpp +++ b/dom/serviceworkers/ServiceWorkerUpdateJob.cpp @@ -287,8 +287,7 @@ void ServiceWorkerUpdateJob::Update() { RefPtr<CompareCallback> callback = new CompareCallback(this); nsresult rv = serviceWorkerScriptCache::Compare( - mRegistration, mPrincipal, cacheName, NS_ConvertUTF8toUTF16(mScriptSpec), - callback); + mRegistration, mPrincipal, cacheName, mScriptSpec, callback); if (NS_WARN_IF(NS_FAILED(rv))) { FailUpdateJob(rv); return; |