Backed out changeset eb2f0c1fffc2 (bug 820613) for xpcshell failures.

--HG--
extra : rebase_source : 7fff4cec5a4d7839cd3ede5cd0322631e11f9d38
This commit is contained in:
Ryan VanderMeulen 2013-01-26 14:05:31 -05:00
parent 434446ef94
commit 0c0f4a7dea
9 changed files with 61 additions and 7 deletions

View File

@ -1149,8 +1149,13 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aT
// The profile is about to change,
// or is going away because the application is shutting down.
mIsShuttingDown = true;
RemoveAllFromMemory();
CloseDB(false);
if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
// Clear the permissions file and close the db asynchronously
RemoveAllInternal(false);
} else {
RemoveAllFromMemory();
CloseDB(false);
}
}
else if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
// the profile has already changed; init the db from the new location

View File

@ -60,6 +60,13 @@ function do_run_test() {
do_check_eq(Services.cookies.countCookiesFromHost(uri1.host), 4);
do_check_eq(Services.cookies.countCookiesFromHost(uri2.host), 0);
// cleanse them
do_close_profile(test_generator, "shutdown-cleanse");
yield;
do_load_profile();
do_check_eq(Services.cookies.countCookiesFromHost(uri1.host), 0);
do_check_eq(Services.cookies.countCookiesFromHost(uri2.host), 0);
// test with cookies set to session-only
Services.prefs.setIntPref("network.cookie.lifetimePolicy", 2);
do_set_cookies(uri1, channel1, false, [1, 2, 3, 4]);

View File

@ -52,6 +52,13 @@ function do_run_test() {
do_check_eq(Services.cookies.countCookiesFromHost(uri1.host), 4);
do_check_eq(Services.cookies.countCookiesFromHost(uri2.host), 0);
// cleanse them
do_close_profile(test_generator, "shutdown-cleanse");
yield;
do_load_profile();
do_check_eq(Services.cookies.countCookiesFromHost(uri1.host), 0);
do_check_eq(Services.cookies.countCookiesFromHost(uri2.host), 0);
// test with third party cookies for session only.
Services.prefs.setBoolPref("network.cookie.thirdparty.sessionOnly", true);
do_set_cookies(uri1, channel2, false, [1, 2, 3, 4]);

View File

@ -412,7 +412,14 @@ Preferences::Observe(nsISupports *aSubject, const char *aTopic,
nsresult rv = NS_OK;
if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
rv = SavePrefFile(nullptr);
if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
if (mCurrentFile) {
mCurrentFile->Remove(false);
mCurrentFile = nullptr;
}
} else {
rv = SavePrefFile(nullptr);
}
} else if (!strcmp(aTopic, "load-extension-defaults")) {
pref_LoadPrefsInDirList(NS_EXT_PREFS_DEFAULTS_DIR_LIST);
} else if (!nsCRT::strcmp(aTopic, "reload-default-prefs")) {

View File

@ -400,7 +400,9 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject,
mHaveProfile = false;
// XXX shutdown devices
nsCacheService::OnProfileShutdown();
nsCacheService::OnProfileShutdown(!strcmp("shutdown-cleanse",
data.get()));
} else if (!strcmp("suspend_process_notification", topic)) {
// A suspended process may never return, so shutdown the cache to reduce
// cache corruption.
@ -2284,7 +2286,7 @@ nsCacheService::DoomEntry_Internal(nsCacheEntry * entry,
void
nsCacheService::OnProfileShutdown()
nsCacheService::OnProfileShutdown(bool cleanse)
{
if (!gService) return;
if (!gService->mInitialized) {
@ -2308,11 +2310,17 @@ nsCacheService::OnProfileShutdown()
(void) SyncWithCacheIOThread();
if (gService->mDiskDevice && gService->mEnableDiskDevice) {
if (cleanse)
gService->mDiskDevice->EvictEntries(nullptr);
gService->mDiskDevice->Shutdown();
}
gService->mEnableDiskDevice = false;
if (gService->mOfflineDevice && gService->mEnableOfflineDevice) {
if (cleanse)
gService->mOfflineDevice->EvictEntries(nullptr);
gService->mOfflineDevice->Shutdown();
}
gService->mCustomOfflineDevices.Enumerate(

View File

@ -172,7 +172,7 @@ public:
/**
* Methods called by nsCacheProfilePrefObserver
*/
static void OnProfileShutdown();
static void OnProfileShutdown(bool cleanse);
static void OnProfileChanged();
static void SetDiskCacheEnabled(bool enabled);

View File

@ -1442,6 +1442,12 @@ nsCookieService::Observe(nsISupports *aSubject,
if (!strcmp(aTopic, "profile-before-change")) {
// The profile is about to change,
// or is going away because the application is shutting down.
if (mDBState && mDBState->dbConn &&
!nsCRT::strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
// Clear the cookie db if we're in the default DBState.
RemoveAll();
}
// Close the default DB connection and null out our DBStates before
// changing.
CloseDBStates();

View File

@ -55,3 +55,7 @@ observer's Observe() method.
See https://wiki.mozilla.org/XPCOM_Shutdown for more details about the shutdown
process.
NOTE: Long ago there was be a "shutdown-cleanse" version of shutdown which was
intended to clear profile data. This is no longer sent and observer code should
remove support for it.

View File

@ -145,7 +145,17 @@ nsCertOverrideService::Observe(nsISupports *,
// or is going away because the application is shutting down.
ReentrantMonitorAutoEnter lock(monitor);
RemoveAllFromMemory();
if (!nsCRT::strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
RemoveAllFromMemory();
// delete the storage file
if (mSettingsFile) {
mSettingsFile->Remove(false);
}
} else {
RemoveAllFromMemory();
}
} else if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
// The profile has already changed.
// Now read from the new profile location.