зеркало из https://github.com/mozilla/pjs.git
bug 162129 (leak in cookie module) & bug 158216 (cookies written out too often), r=sgehani, sr=jag
This commit is contained in:
Родитель
01e040b718
Коммит
48a3076ed0
|
@ -123,7 +123,7 @@ nsresult nsCookieManager::Init()
|
|||
|
||||
NS_IMETHODIMP nsCookieManager::RemoveAll(void) {
|
||||
::COOKIE_RemoveAll();
|
||||
::COOKIE_Write(PR_FALSE);
|
||||
::COOKIE_Write();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ nsCookieService::nsCookieService()
|
|||
|
||||
nsCookieService::~nsCookieService(void)
|
||||
{
|
||||
COOKIE_Write(PR_FALSE); /* in case any deleted cookies didn't get removed from file yet */
|
||||
COOKIE_Write();
|
||||
COOKIE_RemoveAll();
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ nsCookieService::OnStateChange(nsIWebProgress* aWebProgress,
|
|||
{
|
||||
if (progressStateFlags & STATE_IS_DOCUMENT)
|
||||
if (progressStateFlags & STATE_STOP)
|
||||
COOKIE_Write(PR_TRUE);
|
||||
COOKIE_Notify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1578,7 +1578,7 @@ COOKIE_SetCookieStringFromHttp(nsIURI * curURL, nsIURI * firstURL, nsIPrompt *aP
|
|||
|
||||
/* saves out the HTTP cookies to disk */
|
||||
PUBLIC nsresult
|
||||
COOKIE_Write(PRBool notify = PR_TRUE) {
|
||||
COOKIE_Write() {
|
||||
if (!cookie_changed) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1654,14 +1654,16 @@ COOKIE_Write(PRBool notify = PR_TRUE) {
|
|||
strm.flush();
|
||||
strm.close();
|
||||
|
||||
/* Notify cookie manager dialog to update its display */
|
||||
if (notify) {
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
||||
if (os) {
|
||||
os->NotifyObservers(nsnull, "cookieChanged", NS_LITERAL_STRING("cookies").get());
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* Notify cookie manager dialog to update its display */
|
||||
PUBLIC nsresult
|
||||
COOKIE_Notify() {
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
||||
if (os) {
|
||||
os->NotifyObservers(nsnull, "cookieChanged", NS_LITERAL_STRING("cookies").get());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1756,6 +1758,7 @@ COOKIE_Read() {
|
|||
/* check for bad legacy cookies (domain not starting with a dot) */
|
||||
if (new_cookie->isDomain && *new_cookie->host != '.') {
|
||||
/* bad cookie, discard it */
|
||||
deleteCookie((void*)new_cookie, nsnull);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1763,6 +1766,7 @@ COOKIE_Read() {
|
|||
if (!cookie_list) {
|
||||
cookie_list = new nsVoidArray();
|
||||
if (!cookie_list) {
|
||||
deleteCookie((void*)new_cookie, nsnull);
|
||||
strm.close();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1930,7 +1934,7 @@ COOKIE_Remove
|
|||
cookie_list->RemoveElementAt(count);
|
||||
deleteCookie((void*)cookie, nsnull);
|
||||
cookie_changed = PR_TRUE;
|
||||
COOKIE_Write(PR_FALSE); // don't update cookie-manager display
|
||||
COOKIE_Write();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ class nsIPrompt;
|
|||
class nsIHttpChannel;
|
||||
|
||||
extern nsresult COOKIE_Read();
|
||||
extern nsresult COOKIE_Write(PRBool notify);
|
||||
extern nsresult COOKIE_Write();
|
||||
extern nsresult COOKIE_Notify();
|
||||
//XXX these should operate on |const char*|
|
||||
extern char * COOKIE_GetCookie(nsIURI * address);
|
||||
extern char * COOKIE_GetCookieFromHttp(nsIURI * address, nsIURI * firstAddress);
|
||||
|
|
Загрузка…
Ссылка в новой задаче