зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616570 - Part 3: Change the CookieJarSettings::CreateBlockingAll to be a singleton and rename it to GetBlockingAll(). r=Ehsan
We don't need to create the blocking-all cookieJarSettings every time we request it since it is basically the same. Instead, we should make it as a singleton. The patch makes this change the rename the CookieJarSettings::CreateBlockingAll() to GetBlockingAll() which reflects the fact that it is a singleton. Differential Revision: https://phabricator.services.mozilla.com/D64564 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
636d5ec488
Коммит
5d0ba9975d
|
@ -4516,7 +4516,7 @@ Storage* nsGlobalWindowInner::GetLocalStorage(ErrorResult& aError) {
|
|||
if (mDoc) {
|
||||
cookieJarSettings = mDoc->CookieJarSettings();
|
||||
} else {
|
||||
cookieJarSettings = net::CookieJarSettings::CreateBlockingAll();
|
||||
cookieJarSettings = net::CookieJarSettings::GetBlockingAll();
|
||||
}
|
||||
|
||||
bool partitioningEnabled =
|
||||
|
|
|
@ -882,7 +882,7 @@ already_AddRefed<nsICookieJarSettings> CreateCookieJarSettings(
|
|||
return CookieJarSettings::Create();
|
||||
}
|
||||
|
||||
return CookieJarSettings::CreateBlockingAll();
|
||||
return CookieJarSettings::GetBlockingAll();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/net/CookieJarSettings.h"
|
||||
#include "mozilla/net/NeckoChannelParams.h"
|
||||
#include "mozilla/StaticPrefs_network.h"
|
||||
|
@ -20,6 +21,8 @@
|
|||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
static StaticRefPtr<CookieJarSettings> sBlockinAll;
|
||||
|
||||
namespace {
|
||||
|
||||
class PermissionComparator {
|
||||
|
@ -67,12 +70,18 @@ class ReleaseCookiePermissions final : public Runnable {
|
|||
} // namespace
|
||||
|
||||
// static
|
||||
already_AddRefed<nsICookieJarSettings> CookieJarSettings::CreateBlockingAll() {
|
||||
already_AddRefed<nsICookieJarSettings> CookieJarSettings::GetBlockingAll() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
RefPtr<CookieJarSettings> cookieJarSettings =
|
||||
if (sBlockinAll) {
|
||||
return do_AddRef(sBlockinAll);
|
||||
}
|
||||
|
||||
sBlockinAll =
|
||||
new CookieJarSettings(nsICookieService::BEHAVIOR_REJECT, eFixed);
|
||||
return cookieJarSettings.forget();
|
||||
ClearOnShutdown(&sBlockinAll);
|
||||
|
||||
return do_AddRef(sBlockinAll);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -112,7 +112,7 @@ class CookieJarSettings final : public nsICookieJarSettings {
|
|||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSICOOKIEJARSETTINGS
|
||||
|
||||
static already_AddRefed<nsICookieJarSettings> CreateBlockingAll();
|
||||
static already_AddRefed<nsICookieJarSettings> GetBlockingAll();
|
||||
|
||||
static already_AddRefed<nsICookieJarSettings> Create();
|
||||
|
||||
|
|
|
@ -2091,7 +2091,7 @@ already_AddRefed<nsICookieJarSettings> nsCookieService::GetCookieJarSettings(
|
|||
nsresult rv =
|
||||
loadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
cookieJarSettings = CookieJarSettings::CreateBlockingAll();
|
||||
cookieJarSettings = CookieJarSettings::GetBlockingAll();
|
||||
}
|
||||
} else {
|
||||
cookieJarSettings = CookieJarSettings::Create();
|
||||
|
|
|
@ -101,7 +101,7 @@ void SetASameSiteCookie(nsICookieService* aCookieService, const char* aSpec1,
|
|||
|
||||
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
|
||||
aAllowed ? CookieJarSettings::Create()
|
||||
: CookieJarSettings::CreateBlockingAll();
|
||||
: CookieJarSettings::GetBlockingAll();
|
||||
MOZ_ASSERT(cookieJarSettings);
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = dummyChannel->LoadInfo();
|
||||
|
@ -983,7 +983,7 @@ TEST(TestCookie, TestCookieMain)
|
|||
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->RemoveAll()));
|
||||
|
||||
// None of these cookies will be set because using
|
||||
// CookieJarSettings::CreateBlockingAll().
|
||||
// CookieJarSettings::GetBlockingAll().
|
||||
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
|
||||
"unset=yes", nullptr, false);
|
||||
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
|
||||
|
|
Загрузка…
Ссылка в новой задаче