mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1184395 - Remove nsCookieService::mObserverService; r=jdm
This is done to ensure that the cookie service cannot hold the observer service alive.
This commit is contained in:
parent
70bc152a44
commit
82a433cdd6
@ -751,11 +751,11 @@ nsCookieService::Init()
|
||||
|
||||
RegisterWeakMemoryReporter(this);
|
||||
|
||||
mObserverService = mozilla::services::GetObserverService();
|
||||
NS_ENSURE_STATE(mObserverService);
|
||||
mObserverService->AddObserver(this, "profile-before-change", true);
|
||||
mObserverService->AddObserver(this, "profile-do-change", true);
|
||||
mObserverService->AddObserver(this, "last-pb-context-exited", true);
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
NS_ENSURE_STATE(os);
|
||||
os->AddObserver(this, "profile-before-change", true);
|
||||
os->AddObserver(this, "profile-do-change", true);
|
||||
os->AddObserver(this, "last-pb-context-exited", true);
|
||||
|
||||
mPermissionService = do_GetService(NS_COOKIEPERMISSION_CONTRACTID);
|
||||
if (!mPermissionService) {
|
||||
@ -1358,10 +1358,14 @@ nsCookieService::HandleDBClosed(DBState* aDBState)
|
||||
COOKIE_LOGSTRING(LogLevel::Debug,
|
||||
("HandleDBClosed(): DBState %x closed", aDBState));
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
|
||||
switch (aDBState->corruptFlag) {
|
||||
case DBState::OK: {
|
||||
// Database is healthy. Notify of closure.
|
||||
mObserverService->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
|
||||
if (os) {
|
||||
os->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DBState::CLOSING_FOR_REBUILD: {
|
||||
@ -1382,7 +1386,9 @@ nsCookieService::HandleDBClosed(DBState* aDBState)
|
||||
COOKIE_LOGSTRING(LogLevel::Warning,
|
||||
("HandleDBClosed(): DBState %x encountered error rebuilding db; move to "
|
||||
"'cookies.sqlite.bak-rebuild' gave rv 0x%x", aDBState, rv));
|
||||
mObserverService->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
|
||||
if (os) {
|
||||
os->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1469,6 +1475,8 @@ nsCookieService::RebuildCorruptDB(DBState* aDBState)
|
||||
NS_ASSERTION(aDBState->corruptFlag == DBState::CLOSING_FOR_REBUILD,
|
||||
"should be in CLOSING_FOR_REBUILD state");
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
|
||||
aDBState->corruptFlag = DBState::REBUILDING;
|
||||
|
||||
if (mDefaultDBState != aDBState) {
|
||||
@ -1478,7 +1486,9 @@ nsCookieService::RebuildCorruptDB(DBState* aDBState)
|
||||
// do so now.
|
||||
COOKIE_LOGSTRING(LogLevel::Warning,
|
||||
("RebuildCorruptDB(): DBState %x is stale, aborting", aDBState));
|
||||
mObserverService->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
|
||||
if (os) {
|
||||
os->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1496,12 +1506,16 @@ nsCookieService::RebuildCorruptDB(DBState* aDBState)
|
||||
CleanupCachedStatements();
|
||||
CleanupDefaultDBConnection();
|
||||
mDefaultDBState->corruptFlag = DBState::OK;
|
||||
mObserverService->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
|
||||
if (os) {
|
||||
os->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Notify observers that we're beginning the rebuild.
|
||||
mObserverService->NotifyObservers(nullptr, "cookie-db-rebuilding", nullptr);
|
||||
if (os) {
|
||||
os->NotifyObservers(nullptr, "cookie-db-rebuilding", nullptr);
|
||||
}
|
||||
|
||||
// Enumerate the hash, and add cookies to the params array.
|
||||
mozIStorageAsyncStatement* stmt = aDBState->stmtInsert;
|
||||
@ -1784,8 +1798,9 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
void
|
||||
nsCookieService::NotifyRejected(nsIURI *aHostURI)
|
||||
{
|
||||
if (mObserverService) {
|
||||
mObserverService->NotifyObservers(aHostURI, "cookie-rejected", nullptr);
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(aHostURI, "cookie-rejected", nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1794,7 +1809,8 @@ nsCookieService::NotifyRejected(nsIURI *aHostURI)
|
||||
void
|
||||
nsCookieService::NotifyThirdParty(nsIURI *aHostURI, bool aIsAccepted, nsIChannel *aChannel)
|
||||
{
|
||||
if (!mObserverService) {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1834,16 +1850,12 @@ nsCookieService::NotifyThirdParty(nsIURI *aHostURI, bool aIsAccepted, nsIChannel
|
||||
}
|
||||
|
||||
nsAutoString referringHostUTF16 = NS_ConvertUTF8toUTF16(referringHost);
|
||||
mObserverService->NotifyObservers(aHostURI,
|
||||
topic,
|
||||
referringHostUTF16.get());
|
||||
os->NotifyObservers(aHostURI, topic, referringHostUTF16.get());
|
||||
return;
|
||||
} while (0);
|
||||
|
||||
// This can fail for a number of reasons, in which kind we fallback to "?"
|
||||
mObserverService->NotifyObservers(aHostURI,
|
||||
topic,
|
||||
MOZ_UTF16("?"));
|
||||
os->NotifyObservers(aHostURI, topic, MOZ_UTF16("?"));
|
||||
}
|
||||
|
||||
// notify observers that the cookie list changed. there are five possible
|
||||
@ -1860,8 +1872,10 @@ nsCookieService::NotifyChanged(nsISupports *aSubject,
|
||||
{
|
||||
const char* topic = mDBState == mPrivateDBState ?
|
||||
"private-cookie-changed" : "cookie-changed";
|
||||
if (mObserverService)
|
||||
mObserverService->NotifyObservers(aSubject, topic, aData);
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(aSubject, topic, aData);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsIArray>
|
||||
@ -2215,7 +2229,10 @@ nsCookieService::AsyncReadComplete()
|
||||
COOKIE_LOGSTRING(LogLevel::Debug, ("Read(): %ld cookies read",
|
||||
mDefaultDBState->cookieCount));
|
||||
|
||||
mObserverService->NotifyObservers(nullptr, "cookie-db-read", nullptr);
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(nullptr, "cookie-db-read", nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -333,7 +333,6 @@ class nsCookieService final : public nsICookieService
|
||||
|
||||
protected:
|
||||
// cached members.
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
nsCOMPtr<nsICookiePermission> mPermissionService;
|
||||
nsCOMPtr<mozIThirdPartyUtil> mThirdPartyUtil;
|
||||
nsCOMPtr<nsIEffectiveTLDService> mTLDService;
|
||||
|
Loading…
Reference in New Issue
Block a user