Bug 188214 - Cookies are not getting saved on exit in GtkEmbed. This adds a new call to nsProfileDirServiceProvider which allows an app to shutdown the provider and it will send out profile shutdown notifications. r=dougt/sr=blizzard

This commit is contained in:
ccarlen%netscape.com 2003-02-26 15:01:19 +00:00
Родитель d211b4f11d
Коммит 7d0e12d707
4 изменённых файлов: 36 добавлений и 4 удалений

Просмотреть файл

@ -78,6 +78,7 @@ nsIPref *EmbedPrivate::sPrefs = nsnull;
GtkWidget *EmbedPrivate::sOffscreenWindow = 0;
GtkWidget *EmbedPrivate::sOffscreenFixed = 0;
nsIDirectoryServiceProvider *EmbedPrivate::sAppFileLocProvider = nsnull;
nsProfileDirServiceProvider *EmbedPrivate::sProfileDirServiceProvider = nsnull;
EmbedPrivate::EmbedPrivate(void)
{
@ -796,16 +797,14 @@ EmbedPrivate::StartupProfile(void)
NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(locProvider));
if (!locProvider)
return NS_ERROR_FAILURE;
// Directory service holds an strong reference to any
// provider that is registered with it. Let it hold the
// only ref. locProvider won't die when we leave this scope.
rv = locProvider->Register();
if (NS_FAILED(rv))
return rv;
rv = locProvider->SetProfileDir(profileDir);
if (NS_FAILED(rv))
return rv;
// Keep a ref so we can shut it down.
NS_ADDREF(sProfileDirServiceProvider = locProvider);
// get prefs
nsCOMPtr<nsIPref> pref;
@ -822,6 +821,11 @@ EmbedPrivate::StartupProfile(void)
void
EmbedPrivate::ShutdownProfile(void)
{
if (sProfileDirServiceProvider) {
sProfileDirServiceProvider->Shutdown();
NS_RELEASE(sProfileDirServiceProvider);
sProfileDirServiceProvider = 0;
}
if (sPrefs) {
NS_RELEASE(sPrefs);
sPrefs = 0;

Просмотреть файл

@ -46,6 +46,7 @@ class EmbedStream;
class nsPIDOMWindow;
class nsIDirectoryServiceProvider;
class nsProfileDirServiceProvider;
class EmbedPrivate {
@ -134,6 +135,7 @@ class EmbedPrivate {
static char *sProfileDir;
static char *sProfileName;
// for profiles
static nsProfileDirServiceProvider *sProfileDirServiceProvider;
static nsIPref *sPrefs;
static nsIDirectoryServiceProvider * sAppFileLocProvider;

Просмотреть файл

@ -79,6 +79,16 @@ public:
virtual nsresult Register();
/**
* Shutdown
*
* This method must be called before shutting down XPCOM if this object
* was created with aNotifyObservers == PR_TRUE. If this object was
* created with aNotifyObservers == PR_FALSE, this method is a no-op.
*/
virtual nsresult Shutdown();
protected:
nsProfileDirServiceProvider(PRBool aNotifyObservers = PR_TRUE);
virtual ~nsProfileDirServiceProvider();

Просмотреть файл

@ -155,6 +155,22 @@ nsProfileDirServiceProvider::Register()
return directoryService->RegisterProvider(this);
}
nsresult
nsProfileDirServiceProvider::Shutdown()
{
if (!mNotifyObservers)
return NS_OK;
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
if (!observerService)
return NS_ERROR_FAILURE;
NS_NAMED_LITERAL_STRING(context, "shutdown-persist");
observerService->NotifyObservers(nsnull, "profile-before-change", context.get());
return NS_OK;
}
//*****************************************************************************
// nsProfileDirServiceProvider::nsISupports
//*****************************************************************************