mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1624146 - Cookie code refactoring - part 14 - Fix the namespaces, r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D67763 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
0f16f86d52
commit
78a4aecdfd
@ -47,16 +47,16 @@ already_AddRefed<Cookie> Cookie::Create(
|
|||||||
int64_t aCreationTime, bool aIsSession, bool aIsSecure, bool aIsHttpOnly,
|
int64_t aCreationTime, bool aIsSession, bool aIsSecure, bool aIsHttpOnly,
|
||||||
const OriginAttributes& aOriginAttributes, int32_t aSameSite,
|
const OriginAttributes& aOriginAttributes, int32_t aSameSite,
|
||||||
int32_t aRawSameSite) {
|
int32_t aRawSameSite) {
|
||||||
mozilla::net::CookieStruct cookieData(
|
CookieStruct cookieData(nsCString(aName), nsCString(aValue), nsCString(aHost),
|
||||||
nsCString(aName), nsCString(aValue), nsCString(aHost), nsCString(aPath),
|
nsCString(aPath), aExpiry, aLastAccessed,
|
||||||
aExpiry, aLastAccessed, aCreationTime, aIsHttpOnly, aIsSession, aIsSecure,
|
aCreationTime, aIsHttpOnly, aIsSession, aIsSecure,
|
||||||
aSameSite, aRawSameSite);
|
aSameSite, aRawSameSite);
|
||||||
|
|
||||||
return Create(cookieData, aOriginAttributes);
|
return Create(cookieData, aOriginAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Cookie> Cookie::Create(
|
already_AddRefed<Cookie> Cookie::Create(
|
||||||
const mozilla::net::CookieStruct& aCookieData,
|
const CookieStruct& aCookieData,
|
||||||
const OriginAttributes& aOriginAttributes) {
|
const OriginAttributes& aOriginAttributes) {
|
||||||
RefPtr<Cookie> cookie = new Cookie(aCookieData, aOriginAttributes);
|
RefPtr<Cookie> cookie = new Cookie(aCookieData, aOriginAttributes);
|
||||||
|
|
||||||
@ -98,8 +98,7 @@ bool Cookie::IsStale() const {
|
|||||||
int64_t currentTimeInUsec = PR_Now();
|
int64_t currentTimeInUsec = PR_Now();
|
||||||
|
|
||||||
return currentTimeInUsec - LastAccessed() >
|
return currentTimeInUsec - LastAccessed() >
|
||||||
mozilla::StaticPrefs::network_cookie_staleThreshold() *
|
StaticPrefs::network_cookie_staleThreshold() * PR_USEC_PER_SEC;
|
||||||
PR_USEC_PER_SEC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@ -157,7 +156,7 @@ NS_IMETHODIMP Cookie::GetLastAccessed(int64_t* aTime) {
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
NS_IMETHODIMP Cookie::GetSameSite(int32_t* aSameSite) {
|
NS_IMETHODIMP Cookie::GetSameSite(int32_t* aSameSite) {
|
||||||
if (mozilla::StaticPrefs::network_cookie_sameSite_laxByDefault()) {
|
if (StaticPrefs::network_cookie_sameSite_laxByDefault()) {
|
||||||
*aSameSite = SameSite();
|
*aSameSite = SameSite();
|
||||||
} else {
|
} else {
|
||||||
*aSameSite = RawSameSite();
|
*aSameSite = RawSameSite();
|
||||||
@ -215,7 +214,7 @@ Cookie::GetExpires(uint64_t* aExpires) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool Cookie::ValidateRawSame(const mozilla::net::CookieStruct& aCookieData) {
|
bool Cookie::ValidateRawSame(const CookieStruct& aCookieData) {
|
||||||
return aCookieData.rawSameSite() == aCookieData.sameSite() ||
|
return aCookieData.rawSameSite() == aCookieData.sameSite() ||
|
||||||
aCookieData.rawSameSite() == nsICookie::SAMESITE_NONE;
|
aCookieData.rawSameSite() == nsICookie::SAMESITE_NONE;
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,13 @@ class Cookie final : public nsICookie {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// for internal use only. see Cookie::Create().
|
// for internal use only. see Cookie::Create().
|
||||||
Cookie(const mozilla::net::CookieStruct& aCookieData,
|
Cookie(const CookieStruct& aCookieData,
|
||||||
const OriginAttributes& aOriginAttributes)
|
const OriginAttributes& aOriginAttributes)
|
||||||
: mData(aCookieData), mOriginAttributes(aOriginAttributes) {}
|
: mData(aCookieData), mOriginAttributes(aOriginAttributes) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Returns false if rawSameSite has an invalid value, compared to sameSite.
|
// Returns false if rawSameSite has an invalid value, compared to sameSite.
|
||||||
static bool ValidateRawSame(const mozilla::net::CookieStruct& aCookieData);
|
static bool ValidateRawSame(const CookieStruct& aCookieData);
|
||||||
|
|
||||||
// Generate a unique and monotonically increasing creation time. See comment
|
// Generate a unique and monotonically increasing creation time. See comment
|
||||||
// in Cookie.cpp.
|
// in Cookie.cpp.
|
||||||
@ -62,7 +62,7 @@ class Cookie final : public nsICookie {
|
|||||||
int32_t aRawSameSite);
|
int32_t aRawSameSite);
|
||||||
|
|
||||||
static already_AddRefed<Cookie> Create(
|
static already_AddRefed<Cookie> Create(
|
||||||
const mozilla::net::CookieStruct& aCookieData,
|
const CookieStruct& aCookieData,
|
||||||
const OriginAttributes& aOriginAttributes);
|
const OriginAttributes& aOriginAttributes);
|
||||||
|
|
||||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||||
@ -103,7 +103,7 @@ class Cookie final : public nsICookie {
|
|||||||
|
|
||||||
bool IsStale() const;
|
bool IsStale() const;
|
||||||
|
|
||||||
const mozilla::net::CookieStruct& ToIPC() const { return mData; }
|
const CookieStruct& ToIPC() const { return mData; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~Cookie() = default;
|
virtual ~Cookie() = default;
|
||||||
@ -112,8 +112,8 @@ class Cookie final : public nsICookie {
|
|||||||
// member variables
|
// member variables
|
||||||
//
|
//
|
||||||
// Please update SizeOfIncludingThis if this strategy changes.
|
// Please update SizeOfIncludingThis if this strategy changes.
|
||||||
mozilla::net::CookieStruct mData;
|
CookieStruct mData;
|
||||||
mozilla::OriginAttributes mOriginAttributes;
|
OriginAttributes mOriginAttributes;
|
||||||
nsCString mFilePathCache;
|
nsCString mFilePathCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ CookieJarSettings::CookieJarSettings(uint32_t aCookieBehavior, State aState)
|
|||||||
CookieJarSettings::~CookieJarSettings() {
|
CookieJarSettings::~CookieJarSettings() {
|
||||||
if (!NS_IsMainThread() && !mCookiePermissions.IsEmpty()) {
|
if (!NS_IsMainThread() && !mCookiePermissions.IsEmpty()) {
|
||||||
nsCOMPtr<nsIEventTarget> systemGroupEventTarget =
|
nsCOMPtr<nsIEventTarget> systemGroupEventTarget =
|
||||||
mozilla::SystemGroup::EventTargetFor(mozilla::TaskCategory::Other);
|
SystemGroup::EventTargetFor(TaskCategory::Other);
|
||||||
MOZ_ASSERT(systemGroupEventTarget);
|
MOZ_ASSERT(systemGroupEventTarget);
|
||||||
|
|
||||||
RefPtr<Runnable> r = new ReleaseCookiePermissions(mCookiePermissions);
|
RefPtr<Runnable> r = new ReleaseCookiePermissions(mCookiePermissions);
|
||||||
|
@ -42,10 +42,10 @@ class CookieKey : public PLDHashEntryHdr {
|
|||||||
nsAutoCString suffix;
|
nsAutoCString suffix;
|
||||||
aKey->mOriginAttributes.CreateSuffix(suffix);
|
aKey->mOriginAttributes.CreateSuffix(suffix);
|
||||||
temp.Append(suffix);
|
temp.Append(suffix);
|
||||||
return mozilla::HashString(temp);
|
return HashString(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
|
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
|
||||||
return mBaseDomain.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
return mBaseDomain.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ namespace net {
|
|||||||
static const bool kDefaultPolicy = true;
|
static const bool kDefaultPolicy = true;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
mozilla::StaticRefPtr<CookiePermission> gSingleton;
|
StaticRefPtr<CookiePermission> gSingleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(CookiePermission, nsICookiePermission)
|
NS_IMPL_ISUPPORTS(CookiePermission, nsICookiePermission)
|
||||||
|
@ -276,7 +276,7 @@ class InsertCookieDBListener final : public DBListenerErrorHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This notification is just for testing.
|
// This notification is just for testing.
|
||||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||||
if (os) {
|
if (os) {
|
||||||
os->NotifyObservers(nullptr, "cookie-saved-on-disk", nullptr);
|
os->NotifyObservers(nullptr, "cookie-saved-on-disk", nullptr);
|
||||||
}
|
}
|
||||||
@ -394,7 +394,7 @@ void CookiePersistentStorage::NotifyChangedInternal(nsISupports* aSubject,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||||
if (os) {
|
if (os) {
|
||||||
os->NotifyObservers(aSubject, "session-cookie-changed", aData);
|
os->NotifyObservers(aSubject, "session-cookie-changed", aData);
|
||||||
}
|
}
|
||||||
@ -422,8 +422,7 @@ void CookiePersistentStorage::RemoveAllInternal() {
|
|||||||
|
|
||||||
void CookiePersistentStorage::WriteCookieToDB(
|
void CookiePersistentStorage::WriteCookieToDB(
|
||||||
const nsACString& aBaseDomain, const OriginAttributes& aOriginAttributes,
|
const nsACString& aBaseDomain, const OriginAttributes& aOriginAttributes,
|
||||||
mozilla::net::Cookie* aCookie,
|
Cookie* aCookie, mozIStorageBindingParamsArray* aParamsArray) {
|
||||||
mozIStorageBindingParamsArray* aParamsArray) {
|
|
||||||
if (mDBConn) {
|
if (mDBConn) {
|
||||||
mozIStorageAsyncStatement* stmt = mStmtInsert;
|
mozIStorageAsyncStatement* stmt = mStmtInsert;
|
||||||
nsCOMPtr<mozIStorageBindingParamsArray> paramsArray(aParamsArray);
|
nsCOMPtr<mozIStorageBindingParamsArray> paramsArray(aParamsArray);
|
||||||
@ -484,8 +483,7 @@ void CookiePersistentStorage::HandleCorruptDB() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CookiePersistentStorage::RemoveCookiesWithOriginAttributes(
|
void CookiePersistentStorage::RemoveCookiesWithOriginAttributes(
|
||||||
const mozilla::OriginAttributesPattern& aPattern,
|
const OriginAttributesPattern& aPattern, const nsACString& aBaseDomain) {
|
||||||
const nsACString& aBaseDomain) {
|
|
||||||
mozStorageTransaction transaction(mDBConn, false);
|
mozStorageTransaction transaction(mDBConn, false);
|
||||||
|
|
||||||
CookieStorage::RemoveCookiesWithOriginAttributes(aPattern, aBaseDomain);
|
CookieStorage::RemoveCookiesWithOriginAttributes(aPattern, aBaseDomain);
|
||||||
@ -496,7 +494,7 @@ void CookiePersistentStorage::RemoveCookiesWithOriginAttributes(
|
|||||||
|
|
||||||
void CookiePersistentStorage::RemoveCookiesFromExactHost(
|
void CookiePersistentStorage::RemoveCookiesFromExactHost(
|
||||||
const nsACString& aHost, const nsACString& aBaseDomain,
|
const nsACString& aHost, const nsACString& aBaseDomain,
|
||||||
const mozilla::OriginAttributesPattern& aPattern) {
|
const OriginAttributesPattern& aPattern) {
|
||||||
mozStorageTransaction transaction(mDBConn, false);
|
mozStorageTransaction transaction(mDBConn, false);
|
||||||
|
|
||||||
CookieStorage::RemoveCookiesFromExactHost(aHost, aBaseDomain, aPattern);
|
CookieStorage::RemoveCookiesFromExactHost(aHost, aBaseDomain, aPattern);
|
||||||
@ -1627,7 +1625,7 @@ void CookiePersistentStorage::RebuildCorruptDB() {
|
|||||||
NS_ASSERTION(mCorruptFlag == CookiePersistentStorage::CLOSING_FOR_REBUILD,
|
NS_ASSERTION(mCorruptFlag == CookiePersistentStorage::CLOSING_FOR_REBUILD,
|
||||||
"should be in CLOSING_FOR_REBUILD state");
|
"should be in CLOSING_FOR_REBUILD state");
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||||
|
|
||||||
mCorruptFlag = CookiePersistentStorage::REBUILDING;
|
mCorruptFlag = CookiePersistentStorage::REBUILDING;
|
||||||
|
|
||||||
@ -1643,8 +1641,7 @@ void CookiePersistentStorage::RebuildCorruptDB() {
|
|||||||
|
|
||||||
nsCOMPtr<nsIRunnable> innerRunnable = NS_NewRunnableFunction(
|
nsCOMPtr<nsIRunnable> innerRunnable = NS_NewRunnableFunction(
|
||||||
"RebuildCorruptDB.TryInitDBComplete", [self, result] {
|
"RebuildCorruptDB.TryInitDBComplete", [self, result] {
|
||||||
nsCOMPtr<nsIObserverService> os =
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||||
mozilla::services::GetObserverService();
|
|
||||||
if (result != RESULT_OK) {
|
if (result != RESULT_OK) {
|
||||||
// We're done. Reset our DB connection and statements, and
|
// We're done. Reset our DB connection and statements, and
|
||||||
// notify of closure.
|
// notify of closure.
|
||||||
@ -1716,7 +1713,7 @@ void CookiePersistentStorage::HandleDBClosed() {
|
|||||||
COOKIE_LOGSTRING(LogLevel::Debug,
|
COOKIE_LOGSTRING(LogLevel::Debug,
|
||||||
("HandleDBClosed(): CookieStorage %p closed", this));
|
("HandleDBClosed(): CookieStorage %p closed", this));
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||||
|
|
||||||
switch (mCorruptFlag) {
|
switch (mCorruptFlag) {
|
||||||
case CookiePersistentStorage::OK: {
|
case CookiePersistentStorage::OK: {
|
||||||
@ -1825,7 +1822,7 @@ CookiePersistentStorage::OpenDBResult CookiePersistentStorage::Read() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract data from a single result row and create an Cookie.
|
// Extract data from a single result row and create an Cookie.
|
||||||
mozilla::UniquePtr<CookieStruct> CookiePersistentStorage::GetCookieFromRow(
|
UniquePtr<CookieStruct> CookiePersistentStorage::GetCookieFromRow(
|
||||||
mozIStorageStatement* aRow) {
|
mozIStorageStatement* aRow) {
|
||||||
nsCString name, value, host, path;
|
nsCString name, value, host, path;
|
||||||
DebugOnly<nsresult> rv = aRow->GetUTF8String(IDX_NAME, name);
|
DebugOnly<nsresult> rv = aRow->GetUTF8String(IDX_NAME, name);
|
||||||
@ -1846,9 +1843,9 @@ mozilla::UniquePtr<CookieStruct> CookiePersistentStorage::GetCookieFromRow(
|
|||||||
int32_t rawSameSite = aRow->AsInt32(IDX_RAW_SAME_SITE);
|
int32_t rawSameSite = aRow->AsInt32(IDX_RAW_SAME_SITE);
|
||||||
|
|
||||||
// Create a new constCookie and assign the data.
|
// Create a new constCookie and assign the data.
|
||||||
return mozilla::MakeUnique<CookieStruct>(
|
return MakeUnique<CookieStruct>(name, value, host, path, expiry, lastAccessed,
|
||||||
name, value, host, path, expiry, lastAccessed, creationTime, isHttpOnly,
|
creationTime, isHttpOnly, false, isSecure,
|
||||||
false, isSecure, sameSite, rawSameSite);
|
sameSite, rawSameSite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CookiePersistentStorage::EnsureReadComplete() {
|
void CookiePersistentStorage::EnsureReadComplete() {
|
||||||
@ -1942,9 +1939,9 @@ void CookiePersistentStorage::InitDBConn() {
|
|||||||
|
|
||||||
COOKIE_LOGSTRING(LogLevel::Debug,
|
COOKIE_LOGSTRING(LogLevel::Debug,
|
||||||
("InitDBConn(): mInitializedDBConn = true"));
|
("InitDBConn(): mInitializedDBConn = true"));
|
||||||
mEndInitDBConn = mozilla::TimeStamp::Now();
|
mEndInitDBConn = TimeStamp::Now();
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||||
if (os) {
|
if (os) {
|
||||||
os->NotifyObservers(nullptr, "cookie-db-read", nullptr);
|
os->NotifyObservers(nullptr, "cookie-db-read", nullptr);
|
||||||
mReadArray.Clear();
|
mReadArray.Clear();
|
||||||
|
@ -33,12 +33,12 @@ class CookiePersistentStorage final : public CookieStorage {
|
|||||||
void HandleCorruptDB();
|
void HandleCorruptDB();
|
||||||
|
|
||||||
void RemoveCookiesWithOriginAttributes(
|
void RemoveCookiesWithOriginAttributes(
|
||||||
const mozilla::OriginAttributesPattern& aPattern,
|
const OriginAttributesPattern& aPattern,
|
||||||
const nsACString& aBaseDomain) override;
|
const nsACString& aBaseDomain) override;
|
||||||
|
|
||||||
void RemoveCookiesFromExactHost(
|
void RemoveCookiesFromExactHost(
|
||||||
const nsACString& aHost, const nsACString& aBaseDomain,
|
const nsACString& aHost, const nsACString& aBaseDomain,
|
||||||
const mozilla::OriginAttributesPattern& aPattern) override;
|
const OriginAttributesPattern& aPattern) override;
|
||||||
|
|
||||||
void StaleCookies(const nsTArray<Cookie*>& aCookieList,
|
void StaleCookies(const nsTArray<Cookie*>& aCookieList,
|
||||||
int64_t aCurrentTimeInUsec) override;
|
int64_t aCurrentTimeInUsec) override;
|
||||||
@ -78,7 +78,7 @@ class CookiePersistentStorage final : public CookieStorage {
|
|||||||
|
|
||||||
void WriteCookieToDB(const nsACString& aBaseDomain,
|
void WriteCookieToDB(const nsACString& aBaseDomain,
|
||||||
const OriginAttributes& aOriginAttributes,
|
const OriginAttributes& aOriginAttributes,
|
||||||
mozilla::net::Cookie* aCookie,
|
Cookie* aCookie,
|
||||||
mozIStorageBindingParamsArray* aParamsArray) override;
|
mozIStorageBindingParamsArray* aParamsArray) override;
|
||||||
|
|
||||||
void RemoveAllInternal() override;
|
void RemoveAllInternal() override;
|
||||||
@ -109,7 +109,7 @@ class CookiePersistentStorage final : public CookieStorage {
|
|||||||
nsresult CreateTableForSchemaVersion6();
|
nsresult CreateTableForSchemaVersion6();
|
||||||
nsresult CreateTableForSchemaVersion5();
|
nsresult CreateTableForSchemaVersion5();
|
||||||
|
|
||||||
mozilla::UniquePtr<CookieStruct> GetCookieFromRow(mozIStorageStatement* aRow);
|
UniquePtr<CookieStruct> GetCookieFromRow(mozIStorageStatement* aRow);
|
||||||
|
|
||||||
nsCOMPtr<nsIThread> mThread;
|
nsCOMPtr<nsIThread> mThread;
|
||||||
nsCOMPtr<mozIStorageService> mStorageService;
|
nsCOMPtr<mozIStorageService> mStorageService;
|
||||||
@ -119,17 +119,17 @@ class CookiePersistentStorage final : public CookieStorage {
|
|||||||
struct CookieDomainTuple {
|
struct CookieDomainTuple {
|
||||||
CookieKey key;
|
CookieKey key;
|
||||||
OriginAttributes originAttributes;
|
OriginAttributes originAttributes;
|
||||||
mozilla::UniquePtr<mozilla::net::CookieStruct> cookie;
|
UniquePtr<CookieStruct> cookie;
|
||||||
};
|
};
|
||||||
|
|
||||||
// thread
|
// thread
|
||||||
mozilla::TimeStamp mEndInitDBConn;
|
TimeStamp mEndInitDBConn;
|
||||||
nsTArray<CookieDomainTuple> mReadArray;
|
nsTArray<CookieDomainTuple> mReadArray;
|
||||||
|
|
||||||
mozilla::Monitor mMonitor;
|
Monitor mMonitor;
|
||||||
|
|
||||||
mozilla::Atomic<bool> mInitialized;
|
Atomic<bool> mInitialized;
|
||||||
mozilla::Atomic<bool> mInitializedDBConn;
|
Atomic<bool> mInitializedDBConn;
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> mCookieFile;
|
nsCOMPtr<nsIFile> mCookieFile;
|
||||||
nsCOMPtr<mozIStorageConnection> mDBConn;
|
nsCOMPtr<mozIStorageConnection> mDBConn;
|
||||||
|
@ -30,7 +30,7 @@ class CookiePrivateStorage final : public CookieStorage {
|
|||||||
|
|
||||||
void WriteCookieToDB(const nsACString& aBaseDomain,
|
void WriteCookieToDB(const nsACString& aBaseDomain,
|
||||||
const OriginAttributes& aOriginAttributes,
|
const OriginAttributes& aOriginAttributes,
|
||||||
mozilla::net::Cookie* aCookie,
|
Cookie* aCookie,
|
||||||
mozIStorageBindingParamsArray* aParamsArray) override{};
|
mozIStorageBindingParamsArray* aParamsArray) override{};
|
||||||
|
|
||||||
void RemoveAllInternal() override {}
|
void RemoveAllInternal() override {}
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include "ThirdPartyUtil.h"
|
#include "ThirdPartyUtil.h"
|
||||||
|
|
||||||
using namespace mozilla::ipc;
|
using namespace mozilla::ipc;
|
||||||
using mozilla::OriginAttributes;
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
@ -88,8 +87,7 @@ CookieServiceChild::CookieServiceChild() {
|
|||||||
PrefChanged(prefBranch);
|
PrefChanged(prefBranch);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> observerService =
|
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
|
||||||
mozilla::services::GetObserverService();
|
|
||||||
if (observerService) {
|
if (observerService) {
|
||||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||||
}
|
}
|
||||||
@ -141,7 +139,7 @@ void CookieServiceChild::TrackCookieLoad(nsIChannel* aChannel) {
|
|||||||
aChannel->GetURI(getter_AddRefs(uri));
|
aChannel->GetURI(getter_AddRefs(uri));
|
||||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||||
|
|
||||||
mozilla::OriginAttributes attrs = loadInfo->GetOriginAttributes();
|
OriginAttributes attrs = loadInfo->GetOriginAttributes();
|
||||||
StoragePrincipalHelper::PrepareOriginAttributes(aChannel, attrs);
|
StoragePrincipalHelper::PrepareOriginAttributes(aChannel, attrs);
|
||||||
URIParams uriParams;
|
URIParams uriParams;
|
||||||
SerializeURI(uri, uriParams);
|
SerializeURI(uri, uriParams);
|
||||||
@ -155,13 +153,13 @@ void CookieServiceChild::TrackCookieLoad(nsIChannel* aChannel) {
|
|||||||
rejectedReason, isSafeTopLevelNav, isSameSiteForeign, attrs);
|
rejectedReason, isSafeTopLevelNav, isSameSiteForeign, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult CookieServiceChild::RecvRemoveAll() {
|
IPCResult CookieServiceChild::RecvRemoveAll() {
|
||||||
mCookiesMap.Clear();
|
mCookiesMap.Clear();
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult CookieServiceChild::RecvRemoveCookie(
|
IPCResult CookieServiceChild::RecvRemoveCookie(const CookieStruct& aCookie,
|
||||||
const CookieStruct& aCookie, const OriginAttributes& aAttrs) {
|
const OriginAttributes& aAttrs) {
|
||||||
nsCString baseDomain;
|
nsCString baseDomain;
|
||||||
CookieCommons::GetBaseDomainFromHost(mTLDService, aCookie.host(), baseDomain);
|
CookieCommons::GetBaseDomainFromHost(mTLDService, aCookie.host(), baseDomain);
|
||||||
CookieKey key(baseDomain, aAttrs);
|
CookieKey key(baseDomain, aAttrs);
|
||||||
@ -185,8 +183,8 @@ mozilla::ipc::IPCResult CookieServiceChild::RecvRemoveCookie(
|
|||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult CookieServiceChild::RecvAddCookie(
|
IPCResult CookieServiceChild::RecvAddCookie(const CookieStruct& aCookie,
|
||||||
const CookieStruct& aCookie, const OriginAttributes& aAttrs) {
|
const OriginAttributes& aAttrs) {
|
||||||
RefPtr<Cookie> cookie = Cookie::Create(
|
RefPtr<Cookie> cookie = Cookie::Create(
|
||||||
aCookie.name(), aCookie.value(), aCookie.host(), aCookie.path(),
|
aCookie.name(), aCookie.value(), aCookie.host(), aCookie.path(),
|
||||||
aCookie.expiry(), aCookie.lastAccessed(), aCookie.creationTime(),
|
aCookie.expiry(), aCookie.lastAccessed(), aCookie.creationTime(),
|
||||||
@ -196,7 +194,7 @@ mozilla::ipc::IPCResult CookieServiceChild::RecvAddCookie(
|
|||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult CookieServiceChild::RecvRemoveBatchDeletedCookies(
|
IPCResult CookieServiceChild::RecvRemoveBatchDeletedCookies(
|
||||||
nsTArray<CookieStruct>&& aCookiesList,
|
nsTArray<CookieStruct>&& aCookiesList,
|
||||||
nsTArray<OriginAttributes>&& aAttrsList) {
|
nsTArray<OriginAttributes>&& aAttrsList) {
|
||||||
MOZ_ASSERT(aCookiesList.Length() == aAttrsList.Length());
|
MOZ_ASSERT(aCookiesList.Length() == aAttrsList.Length());
|
||||||
@ -207,7 +205,7 @@ mozilla::ipc::IPCResult CookieServiceChild::RecvRemoveBatchDeletedCookies(
|
|||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult CookieServiceChild::RecvTrackCookiesLoad(
|
IPCResult CookieServiceChild::RecvTrackCookiesLoad(
|
||||||
nsTArray<CookieStruct>&& aCookiesList, const OriginAttributes& aAttrs) {
|
nsTArray<CookieStruct>&& aCookiesList, const OriginAttributes& aAttrs) {
|
||||||
for (uint32_t i = 0; i < aCookiesList.Length(); i++) {
|
for (uint32_t i = 0; i < aCookiesList.Length(); i++) {
|
||||||
RefPtr<Cookie> cookie = Cookie::Create(
|
RefPtr<Cookie> cookie = Cookie::Create(
|
||||||
@ -254,7 +252,7 @@ void CookieServiceChild::GetCookieStringFromCookieHashTable(
|
|||||||
nsAutoCString baseDomain;
|
nsAutoCString baseDomain;
|
||||||
|
|
||||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||||
mozilla::OriginAttributes attrs;
|
OriginAttributes attrs;
|
||||||
if (aChannel) {
|
if (aChannel) {
|
||||||
loadInfo = aChannel->LoadInfo();
|
loadInfo = aChannel->LoadInfo();
|
||||||
attrs = loadInfo->GetOriginAttributes();
|
attrs = loadInfo->GetOriginAttributes();
|
||||||
@ -356,7 +354,7 @@ uint32_t CookieServiceChild::CountCookiesFromHashTable(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CookieServiceChild::SetCookieInternal(
|
void CookieServiceChild::SetCookieInternal(
|
||||||
const CookieStruct& aCookieData, const mozilla::OriginAttributes& aAttrs,
|
const CookieStruct& aCookieData, const OriginAttributes& aAttrs,
|
||||||
nsIChannel* aChannel, bool aFromHttp,
|
nsIChannel* aChannel, bool aFromHttp,
|
||||||
nsICookiePermission* aPermissionService) {
|
nsICookiePermission* aPermissionService) {
|
||||||
int64_t currentTimeInUsec = PR_Now();
|
int64_t currentTimeInUsec = PR_Now();
|
||||||
@ -486,7 +484,7 @@ nsresult CookieServiceChild::SetCookieStringInternal(
|
|||||||
SerializeURI(aHostURI, hostURIParams);
|
SerializeURI(aHostURI, hostURIParams);
|
||||||
|
|
||||||
Maybe<URIParams> channelURIParams;
|
Maybe<URIParams> channelURIParams;
|
||||||
mozilla::OriginAttributes attrs;
|
OriginAttributes attrs;
|
||||||
if (aChannel) {
|
if (aChannel) {
|
||||||
nsCOMPtr<nsIURI> channelURI;
|
nsCOMPtr<nsIURI> channelURI;
|
||||||
aChannel->GetURI(getter_AddRefs(channelURI));
|
aChannel->GetURI(getter_AddRefs(channelURI));
|
||||||
@ -590,7 +588,7 @@ CookieServiceChild::Observe(nsISupports* aSubject, const char* aTopic,
|
|||||||
mCookieTimer = nullptr;
|
mCookieTimer = nullptr;
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsIObserverService> observerService =
|
nsCOMPtr<nsIObserverService> observerService =
|
||||||
mozilla::services::GetObserverService();
|
services::GetObserverService();
|
||||||
if (observerService) {
|
if (observerService) {
|
||||||
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,8 @@ class CookieServiceChild : public PCookieServiceChild,
|
|||||||
void RecordDocumentCookie(Cookie* aCookie, const OriginAttributes& aAttrs);
|
void RecordDocumentCookie(Cookie* aCookie, const OriginAttributes& aAttrs);
|
||||||
|
|
||||||
void SetCookieInternal(const CookieStruct& aCookieData,
|
void SetCookieInternal(const CookieStruct& aCookieData,
|
||||||
const mozilla::OriginAttributes& aAttrs,
|
const OriginAttributes& aAttrs, nsIChannel* aChannel,
|
||||||
nsIChannel* aChannel, bool aFromHttp,
|
bool aFromHttp,
|
||||||
nsICookiePermission* aPermissionService);
|
nsICookiePermission* aPermissionService);
|
||||||
|
|
||||||
uint32_t CountCookiesFromHashTable(const nsCString& aBaseDomain,
|
uint32_t CountCookiesFromHashTable(const nsCString& aBaseDomain,
|
||||||
|
@ -21,7 +21,6 @@ using namespace mozilla::ipc;
|
|||||||
using mozilla::BasePrincipal;
|
using mozilla::BasePrincipal;
|
||||||
using mozilla::OriginAttributes;
|
using mozilla::OriginAttributes;
|
||||||
using mozilla::dom::PContentParent;
|
using mozilla::dom::PContentParent;
|
||||||
using mozilla::net::NeckoParent;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -105,7 +104,7 @@ void CookieServiceParent::TrackCookieLoad(nsIChannel* aChannel) {
|
|||||||
aChannel->GetURI(getter_AddRefs(uri));
|
aChannel->GetURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||||
mozilla::OriginAttributes attrs = loadInfo->GetOriginAttributes();
|
OriginAttributes attrs = loadInfo->GetOriginAttributes();
|
||||||
bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel);
|
bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel);
|
||||||
bool aIsSameSiteForeign = NS_IsSameSiteForeign(aChannel, uri);
|
bool aIsSameSiteForeign = NS_IsSameSiteForeign(aChannel, uri);
|
||||||
|
|
||||||
@ -146,7 +145,7 @@ void CookieServiceParent::SerialializeCookieList(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult CookieServiceParent::RecvPrepareCookieList(
|
IPCResult CookieServiceParent::RecvPrepareCookieList(
|
||||||
const URIParams& aHost, const bool& aIsForeign,
|
const URIParams& aHost, const bool& aIsForeign,
|
||||||
const bool& aIsThirdPartyTrackingResource,
|
const bool& aIsThirdPartyTrackingResource,
|
||||||
const bool& aIsThirdPartySocialTrackingResource,
|
const bool& aIsThirdPartySocialTrackingResource,
|
||||||
@ -176,7 +175,7 @@ void CookieServiceParent::ActorDestroy(ActorDestroyReason aWhy) {
|
|||||||
// non-refcounted class.
|
// non-refcounted class.
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult CookieServiceParent::RecvSetCookieString(
|
IPCResult CookieServiceParent::RecvSetCookieString(
|
||||||
const URIParams& aHost, const Maybe<URIParams>& aChannelURI,
|
const URIParams& aHost, const Maybe<URIParams>& aChannelURI,
|
||||||
const Maybe<LoadInfoArgs>& aLoadInfoArgs, const bool& aIsForeign,
|
const Maybe<LoadInfoArgs>& aLoadInfoArgs, const bool& aIsForeign,
|
||||||
const bool& aIsThirdPartyTrackingResource,
|
const bool& aIsThirdPartyTrackingResource,
|
||||||
|
@ -245,8 +245,8 @@ const nsTArray<RefPtr<Cookie>>* CookieStorage::GetCookiesFromHost(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CookieStorage::GetCookiesWithOriginAttributes(
|
void CookieStorage::GetCookiesWithOriginAttributes(
|
||||||
const mozilla::OriginAttributesPattern& aPattern,
|
const OriginAttributesPattern& aPattern, const nsACString& aBaseDomain,
|
||||||
const nsACString& aBaseDomain, nsTArray<RefPtr<nsICookie>>& aResult) {
|
nsTArray<RefPtr<nsICookie>>& aResult) {
|
||||||
for (auto iter = mHostTable.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mHostTable.Iter(); !iter.Done(); iter.Next()) {
|
||||||
CookieEntry* entry = iter.Get();
|
CookieEntry* entry = iter.Get();
|
||||||
|
|
||||||
@ -286,8 +286,7 @@ void CookieStorage::RemoveCookie(const nsACString& aBaseDomain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CookieStorage::RemoveCookiesWithOriginAttributes(
|
void CookieStorage::RemoveCookiesWithOriginAttributes(
|
||||||
const mozilla::OriginAttributesPattern& aPattern,
|
const OriginAttributesPattern& aPattern, const nsACString& aBaseDomain) {
|
||||||
const nsACString& aBaseDomain) {
|
|
||||||
// Iterate the hash table of CookieEntry.
|
// Iterate the hash table of CookieEntry.
|
||||||
for (auto iter = mHostTable.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mHostTable.Iter(); !iter.Done(); iter.Next()) {
|
||||||
CookieEntry* entry = iter.Get();
|
CookieEntry* entry = iter.Get();
|
||||||
@ -320,7 +319,7 @@ void CookieStorage::RemoveCookiesWithOriginAttributes(
|
|||||||
|
|
||||||
void CookieStorage::RemoveCookiesFromExactHost(
|
void CookieStorage::RemoveCookiesFromExactHost(
|
||||||
const nsACString& aHost, const nsACString& aBaseDomain,
|
const nsACString& aHost, const nsACString& aBaseDomain,
|
||||||
const mozilla::OriginAttributesPattern& aPattern) {
|
const OriginAttributesPattern& aPattern) {
|
||||||
// Iterate the hash table of CookieEntry.
|
// Iterate the hash table of CookieEntry.
|
||||||
for (auto iter = mHostTable.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mHostTable.Iter(); !iter.Done(); iter.Next()) {
|
||||||
CookieEntry* entry = iter.Get();
|
CookieEntry* entry = iter.Get();
|
||||||
@ -374,7 +373,7 @@ void CookieStorage::RemoveAll() {
|
|||||||
// cookies.
|
// cookies.
|
||||||
void CookieStorage::NotifyChanged(nsISupports* aSubject, const char16_t* aData,
|
void CookieStorage::NotifyChanged(nsISupports* aSubject, const char16_t* aData,
|
||||||
bool aOldCookieIsSession, bool aFromHttp) {
|
bool aOldCookieIsSession, bool aFromHttp) {
|
||||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||||
if (!os) {
|
if (!os) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ struct CookieListIter {
|
|||||||
: entry(aEntry), index(aIndex) {}
|
: entry(aEntry), index(aIndex) {}
|
||||||
|
|
||||||
// get the Cookie * the iterator currently points to.
|
// get the Cookie * the iterator currently points to.
|
||||||
Cookie* Cookie() const { return entry->GetCookies()[index]; }
|
mozilla::net::Cookie* Cookie() const { return entry->GetCookies()[index]; }
|
||||||
|
|
||||||
CookieEntry* entry;
|
CookieEntry* entry;
|
||||||
CookieEntry::IndexType index;
|
CookieEntry::IndexType index;
|
||||||
@ -91,9 +91,9 @@ class CookieStorage : public nsIObserver, public nsSupportsWeakReference {
|
|||||||
const nsTArray<RefPtr<Cookie>>* GetCookiesFromHost(
|
const nsTArray<RefPtr<Cookie>>* GetCookiesFromHost(
|
||||||
const nsACString& aBaseDomain, const OriginAttributes& aOriginAttributes);
|
const nsACString& aBaseDomain, const OriginAttributes& aOriginAttributes);
|
||||||
|
|
||||||
void GetCookiesWithOriginAttributes(
|
void GetCookiesWithOriginAttributes(const OriginAttributesPattern& aPattern,
|
||||||
const mozilla::OriginAttributesPattern& aPattern,
|
const nsACString& aBaseDomain,
|
||||||
const nsACString& aBaseDomain, nsTArray<RefPtr<nsICookie>>& aResult);
|
nsTArray<RefPtr<nsICookie>>& aResult);
|
||||||
|
|
||||||
void RemoveCookie(const nsACString& aBaseDomain,
|
void RemoveCookie(const nsACString& aBaseDomain,
|
||||||
const OriginAttributes& aOriginAttributes,
|
const OriginAttributes& aOriginAttributes,
|
||||||
@ -101,12 +101,11 @@ class CookieStorage : public nsIObserver, public nsSupportsWeakReference {
|
|||||||
const nsACString& aPath);
|
const nsACString& aPath);
|
||||||
|
|
||||||
virtual void RemoveCookiesWithOriginAttributes(
|
virtual void RemoveCookiesWithOriginAttributes(
|
||||||
const mozilla::OriginAttributesPattern& aPattern,
|
const OriginAttributesPattern& aPattern, const nsACString& aBaseDomain);
|
||||||
const nsACString& aBaseDomain);
|
|
||||||
|
|
||||||
virtual void RemoveCookiesFromExactHost(
|
virtual void RemoveCookiesFromExactHost(
|
||||||
const nsACString& aHost, const nsACString& aBaseDomain,
|
const nsACString& aHost, const nsACString& aBaseDomain,
|
||||||
const mozilla::OriginAttributesPattern& aPattern);
|
const OriginAttributesPattern& aPattern);
|
||||||
|
|
||||||
void RemoveAll();
|
void RemoveAll();
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ class CookieStorage : public nsIObserver, public nsSupportsWeakReference {
|
|||||||
|
|
||||||
void AddCookieToList(const nsACString& aBaseDomain,
|
void AddCookieToList(const nsACString& aBaseDomain,
|
||||||
const OriginAttributes& aOriginAttributes,
|
const OriginAttributes& aOriginAttributes,
|
||||||
mozilla::net::Cookie* aCookie,
|
Cookie* aCookie,
|
||||||
mozIStorageBindingParamsArray* aParamsArray,
|
mozIStorageBindingParamsArray* aParamsArray,
|
||||||
bool aWriteToDB = true);
|
bool aWriteToDB = true);
|
||||||
|
|
||||||
@ -145,7 +144,7 @@ class CookieStorage : public nsIObserver, public nsSupportsWeakReference {
|
|||||||
|
|
||||||
virtual void WriteCookieToDB(const nsACString& aBaseDomain,
|
virtual void WriteCookieToDB(const nsACString& aBaseDomain,
|
||||||
const OriginAttributes& aOriginAttributes,
|
const OriginAttributes& aOriginAttributes,
|
||||||
mozilla::net::Cookie* aCookie,
|
Cookie* aCookie,
|
||||||
mozIStorageBindingParamsArray* aParamsArray) = 0;
|
mozIStorageBindingParamsArray* aParamsArray) = 0;
|
||||||
|
|
||||||
virtual void RemoveAllInternal() = 0;
|
virtual void RemoveAllInternal() = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user