mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 23:38:38 +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;
|
||||
GetPrefBranch(getter_AddRefs(prefBranch));
|
||||
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)) {
|
||||
// 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 "nsIVariant.h"
|
||||
#include "nsIFile.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
using mozilla::NeckoOriginAttributes;
|
||||
using mozilla::OriginAttributes;
|
||||
|
|
@ -43,6 +46,7 @@ class nsIObserverService;
|
|||
class nsIURI;
|
||||
class nsIChannel;
|
||||
class nsIArray;
|
||||
class nsIThread;
|
||||
class mozIStorageService;
|
||||
class mozIThirdPartyUtil;
|
||||
class ReadCookieDBListener;
|
||||
|
|
@ -145,13 +149,49 @@ class nsCookieEntry : public nsCookieKey
|
|||
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.
|
||||
struct CookieDomainTuple
|
||||
{
|
||||
nsCookieKey key;
|
||||
RefPtr<nsCookie> cookie;
|
||||
|
||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
mozilla::UniquePtr<ConstCookie> cookie;
|
||||
};
|
||||
|
||||
// encapsulates in-memory and on-disk DB states, so we can
|
||||
|
|
@ -194,17 +234,9 @@ public:
|
|||
// while the background read is taking place.
|
||||
nsCOMPtr<mozIStorageConnection> syncConn;
|
||||
nsCOMPtr<mozIStorageStatement> stmtReadDomain;
|
||||
nsCOMPtr<mozIStoragePendingStatement> pendingRead;
|
||||
// The asynchronous read listener. This is a weak ref (storage has ownership)
|
||||
// since it may need to outlive the DBState's database connection.
|
||||
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.
|
||||
nsCOMPtr<mozIStorageStatementCallback> insertListener;
|
||||
|
|
@ -266,6 +298,8 @@ class nsCookieService final : public nsICookieService
|
|||
void PrefChanged(nsIPrefBranch *aPrefBranch);
|
||||
void InitDBStates();
|
||||
OpenDBResult TryInitDB(bool aDeleteExistingDB);
|
||||
void InitDBConn();
|
||||
nsresult InitDBConnInternal();
|
||||
nsresult CreateTable();
|
||||
nsresult CreateTableForSchemaVersion6();
|
||||
nsresult CreateTableForSchemaVersion5();
|
||||
|
|
@ -276,11 +310,8 @@ class nsCookieService final : public nsICookieService
|
|||
void HandleCorruptDB(DBState* aDBState);
|
||||
void RebuildCorruptDB(DBState* aDBState);
|
||||
OpenDBResult Read();
|
||||
template<class T> nsCookie* GetCookieFromRow(T &aRow, const OriginAttributes& aOriginAttributes);
|
||||
void AsyncReadComplete();
|
||||
void CancelAsyncRead(bool aPurgeReadSet);
|
||||
void EnsureReadDomain(const nsCookieKey &aKey);
|
||||
void EnsureReadComplete();
|
||||
mozilla::UniquePtr<ConstCookie> GetCookieFromRow(mozIStorageStatement *aRow, const OriginAttributes &aOriginAttributes);
|
||||
void EnsureReadComplete(bool aInitDBConn);
|
||||
nsresult NormalizeHost(nsCString &aHost);
|
||||
nsresult GetBaseDomain(nsIURI *aHostURI, nsCString &aBaseDomain, bool &aRequireHostMatch);
|
||||
nsresult GetBaseDomainFromHost(const nsACString &aHost, nsCString &aBaseDomain);
|
||||
|
|
@ -351,6 +382,13 @@ class nsCookieService final : public nsICookieService
|
|||
uint16_t mMaxCookiesPerHost;
|
||||
int64_t mCookiePurgeAge;
|
||||
|
||||
// thread props
|
||||
nsCOMPtr<nsIThread> mThread;
|
||||
mozilla::Monitor mMonitor;
|
||||
mozilla::Atomic<bool> mInitializedDBStates;
|
||||
mozilla::Atomic<bool> mInitializedDBConn;
|
||||
nsTArray<CookieDomainTuple> mReadArray;
|
||||
|
||||
// friends!
|
||||
friend class DBListenerErrorHandler;
|
||||
friend class ReadCookieDBListener;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue