mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-26 17:17:31 +09:00
Merge remote-tracking branch 'origin/tracking' into custom
This commit is contained in:
commit
e5fa99d83c
3 changed files with 440 additions and 571 deletions
|
|
@ -1437,6 +1437,11 @@ nsIOService::Observe(nsISupports *subject,
|
||||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||||
GetPrefBranch(getter_AddRefs(prefBranch));
|
GetPrefBranch(getter_AddRefs(prefBranch));
|
||||||
PrefsChanged(prefBranch, MANAGE_OFFLINE_STATUS_PREF);
|
PrefsChanged(prefBranch, MANAGE_OFFLINE_STATUS_PREF);
|
||||||
|
|
||||||
|
// Issue #2672 - Read cookie database at an early-as-possible time
|
||||||
|
// off main thread. Hence, we have more chance to finish db query
|
||||||
|
// before something calls into the cookie service.
|
||||||
|
nsCOMPtr<nsISupports> cookieServ = do_GetService(NS_COOKIESERVICE_CONTRACTID);
|
||||||
}
|
}
|
||||||
} else if (!strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
} else if (!strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
||||||
// Remember we passed XPCOM shutdown notification to prevent any
|
// Remember we passed XPCOM shutdown notification to prevent any
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -28,9 +28,12 @@
|
||||||
#include "mozIStorageFunction.h"
|
#include "mozIStorageFunction.h"
|
||||||
#include "nsIVariant.h"
|
#include "nsIVariant.h"
|
||||||
#include "nsIFile.h"
|
#include "nsIFile.h"
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/BasePrincipal.h"
|
#include "mozilla/BasePrincipal.h"
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
#include "mozilla/Maybe.h"
|
#include "mozilla/Maybe.h"
|
||||||
|
#include "mozilla/Monitor.h"
|
||||||
|
#include "mozilla/UniquePtr.h"
|
||||||
|
|
||||||
using mozilla::NeckoOriginAttributes;
|
using mozilla::NeckoOriginAttributes;
|
||||||
using mozilla::OriginAttributes;
|
using mozilla::OriginAttributes;
|
||||||
|
|
@ -43,6 +46,7 @@ class nsIObserverService;
|
||||||
class nsIURI;
|
class nsIURI;
|
||||||
class nsIChannel;
|
class nsIChannel;
|
||||||
class nsIArray;
|
class nsIArray;
|
||||||
|
class nsIThread;
|
||||||
class mozIStorageService;
|
class mozIStorageService;
|
||||||
class mozIThirdPartyUtil;
|
class mozIThirdPartyUtil;
|
||||||
class ReadCookieDBListener;
|
class ReadCookieDBListener;
|
||||||
|
|
@ -145,13 +149,49 @@ class nsCookieEntry : public nsCookieKey
|
||||||
ArrayType mCookies;
|
ArrayType mCookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// struct for a constant cookie for threadsafe
|
||||||
|
struct ConstCookie
|
||||||
|
{
|
||||||
|
ConstCookie(const nsCString& aName,
|
||||||
|
const nsCString& aValue,
|
||||||
|
const nsCString& aHost,
|
||||||
|
const nsCString& aPath,
|
||||||
|
int64_t aExpiry,
|
||||||
|
int64_t aLastAccessed,
|
||||||
|
int64_t aCreationTime,
|
||||||
|
bool aIsSecure,
|
||||||
|
bool aIsHttpOnly,
|
||||||
|
const OriginAttributes &aOriginAttributes)
|
||||||
|
: name(aName)
|
||||||
|
, value(aValue)
|
||||||
|
, host(aHost)
|
||||||
|
, path(aPath)
|
||||||
|
, expiry(aExpiry)
|
||||||
|
, lastAccessed(aLastAccessed)
|
||||||
|
, creationTime(aCreationTime)
|
||||||
|
, isSecure(aIsSecure)
|
||||||
|
, isHttpOnly(aIsHttpOnly)
|
||||||
|
, originAttributes(aOriginAttributes)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const nsCString name;
|
||||||
|
const nsCString value;
|
||||||
|
const nsCString host;
|
||||||
|
const nsCString path;
|
||||||
|
const int64_t expiry;
|
||||||
|
const int64_t lastAccessed;
|
||||||
|
const int64_t creationTime;
|
||||||
|
const bool isSecure;
|
||||||
|
const bool isHttpOnly;
|
||||||
|
const OriginAttributes originAttributes;
|
||||||
|
};
|
||||||
|
|
||||||
// encapsulates a (key, nsCookie) tuple for temporary storage purposes.
|
// encapsulates a (key, nsCookie) tuple for temporary storage purposes.
|
||||||
struct CookieDomainTuple
|
struct CookieDomainTuple
|
||||||
{
|
{
|
||||||
nsCookieKey key;
|
nsCookieKey key;
|
||||||
RefPtr<nsCookie> cookie;
|
mozilla::UniquePtr<ConstCookie> cookie;
|
||||||
|
|
||||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// encapsulates in-memory and on-disk DB states, so we can
|
// encapsulates in-memory and on-disk DB states, so we can
|
||||||
|
|
@ -194,17 +234,9 @@ public:
|
||||||
// while the background read is taking place.
|
// while the background read is taking place.
|
||||||
nsCOMPtr<mozIStorageConnection> syncConn;
|
nsCOMPtr<mozIStorageConnection> syncConn;
|
||||||
nsCOMPtr<mozIStorageStatement> stmtReadDomain;
|
nsCOMPtr<mozIStorageStatement> stmtReadDomain;
|
||||||
nsCOMPtr<mozIStoragePendingStatement> pendingRead;
|
|
||||||
// The asynchronous read listener. This is a weak ref (storage has ownership)
|
// The asynchronous read listener. This is a weak ref (storage has ownership)
|
||||||
// since it may need to outlive the DBState's database connection.
|
// since it may need to outlive the DBState's database connection.
|
||||||
ReadCookieDBListener* readListener;
|
ReadCookieDBListener* readListener;
|
||||||
// An array of (baseDomain, cookie) tuples representing data read in
|
|
||||||
// asynchronously. This is merged into hostTable once read is complete.
|
|
||||||
nsTArray<CookieDomainTuple> hostArray;
|
|
||||||
// A hashset of baseDomains read in synchronously, while the async read is
|
|
||||||
// in flight. This is used to keep track of which data in hostArray is stale
|
|
||||||
// when the time comes to merge.
|
|
||||||
nsTHashtable<nsCookieKey> readSet;
|
|
||||||
|
|
||||||
// DB completion handlers.
|
// DB completion handlers.
|
||||||
nsCOMPtr<mozIStorageStatementCallback> insertListener;
|
nsCOMPtr<mozIStorageStatementCallback> insertListener;
|
||||||
|
|
@ -266,6 +298,8 @@ class nsCookieService final : public nsICookieService
|
||||||
void PrefChanged(nsIPrefBranch *aPrefBranch);
|
void PrefChanged(nsIPrefBranch *aPrefBranch);
|
||||||
void InitDBStates();
|
void InitDBStates();
|
||||||
OpenDBResult TryInitDB(bool aDeleteExistingDB);
|
OpenDBResult TryInitDB(bool aDeleteExistingDB);
|
||||||
|
void InitDBConn();
|
||||||
|
nsresult InitDBConnInternal();
|
||||||
nsresult CreateTable();
|
nsresult CreateTable();
|
||||||
nsresult CreateTableForSchemaVersion6();
|
nsresult CreateTableForSchemaVersion6();
|
||||||
nsresult CreateTableForSchemaVersion5();
|
nsresult CreateTableForSchemaVersion5();
|
||||||
|
|
@ -276,11 +310,8 @@ class nsCookieService final : public nsICookieService
|
||||||
void HandleCorruptDB(DBState* aDBState);
|
void HandleCorruptDB(DBState* aDBState);
|
||||||
void RebuildCorruptDB(DBState* aDBState);
|
void RebuildCorruptDB(DBState* aDBState);
|
||||||
OpenDBResult Read();
|
OpenDBResult Read();
|
||||||
template<class T> nsCookie* GetCookieFromRow(T &aRow, const OriginAttributes& aOriginAttributes);
|
mozilla::UniquePtr<ConstCookie> GetCookieFromRow(mozIStorageStatement *aRow, const OriginAttributes &aOriginAttributes);
|
||||||
void AsyncReadComplete();
|
void EnsureReadComplete(bool aInitDBConn);
|
||||||
void CancelAsyncRead(bool aPurgeReadSet);
|
|
||||||
void EnsureReadDomain(const nsCookieKey &aKey);
|
|
||||||
void EnsureReadComplete();
|
|
||||||
nsresult NormalizeHost(nsCString &aHost);
|
nsresult NormalizeHost(nsCString &aHost);
|
||||||
nsresult GetBaseDomain(nsIURI *aHostURI, nsCString &aBaseDomain, bool &aRequireHostMatch);
|
nsresult GetBaseDomain(nsIURI *aHostURI, nsCString &aBaseDomain, bool &aRequireHostMatch);
|
||||||
nsresult GetBaseDomainFromHost(const nsACString &aHost, nsCString &aBaseDomain);
|
nsresult GetBaseDomainFromHost(const nsACString &aHost, nsCString &aBaseDomain);
|
||||||
|
|
@ -351,6 +382,13 @@ class nsCookieService final : public nsICookieService
|
||||||
uint16_t mMaxCookiesPerHost;
|
uint16_t mMaxCookiesPerHost;
|
||||||
int64_t mCookiePurgeAge;
|
int64_t mCookiePurgeAge;
|
||||||
|
|
||||||
|
// thread props
|
||||||
|
nsCOMPtr<nsIThread> mThread;
|
||||||
|
mozilla::Monitor mMonitor;
|
||||||
|
mozilla::Atomic<bool> mInitializedDBStates;
|
||||||
|
mozilla::Atomic<bool> mInitializedDBConn;
|
||||||
|
nsTArray<CookieDomainTuple> mReadArray;
|
||||||
|
|
||||||
// friends!
|
// friends!
|
||||||
friend class DBListenerErrorHandler;
|
friend class DBListenerErrorHandler;
|
||||||
friend class ReadCookieDBListener;
|
friend class ReadCookieDBListener;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue