зеркало из https://github.com/mozilla/pjs.git
bug 468744 - finalize sqlite statements before closing db to avoid sqlite warnings; r=sdwilsh
This commit is contained in:
Родитель
460fad9c68
Коммит
531c1c47b3
|
@ -409,11 +409,11 @@ NS_IMPL_ISUPPORTS5(nsCookieService,
|
|||
nsISupportsWeakReference)
|
||||
|
||||
nsCookieService::nsCookieService()
|
||||
: mCookieCount(0)
|
||||
: mHostTable(&mDefaultHostTable)
|
||||
, mCookieCount(0)
|
||||
, mCookiesPermissions(BEHAVIOR_ACCEPT)
|
||||
, mMaxNumberOfCookies(kMaxNumberOfCookies)
|
||||
, mMaxCookiesPerHost(kMaxCookiesPerHost)
|
||||
, mHostTable(&mDefaultHostTable)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -472,6 +472,9 @@ nsCookieService::Init()
|
|||
nsresult
|
||||
nsCookieService::InitDB()
|
||||
{
|
||||
// null out any existing connection
|
||||
CloseDB();
|
||||
|
||||
nsCOMPtr<nsIFile> cookieFile;
|
||||
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(cookieFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -618,8 +621,21 @@ nsCookieService::CreateTable()
|
|||
"expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER)"));
|
||||
}
|
||||
|
||||
void
|
||||
nsCookieService::CloseDB()
|
||||
{
|
||||
// finalize our statements and close the db connection.
|
||||
// since we own these objects, nulling the pointers is sufficient here.
|
||||
mStmtInsert = nsnull;
|
||||
mStmtDelete = nsnull;
|
||||
mStmtUpdate = nsnull;
|
||||
mDBConn = nsnull;
|
||||
}
|
||||
|
||||
nsCookieService::~nsCookieService()
|
||||
{
|
||||
CloseDB();
|
||||
|
||||
gCookieService = nsnull;
|
||||
}
|
||||
|
||||
|
@ -643,8 +659,7 @@ nsCookieService::Observe(nsISupports *aSubject,
|
|||
}
|
||||
|
||||
// Close the DB connection before changing
|
||||
mDBConn->Close();
|
||||
mDBConn = nsnull;
|
||||
CloseDB();
|
||||
}
|
||||
|
||||
} else if (!strcmp(aTopic, "profile-do-change")) {
|
||||
|
@ -664,10 +679,7 @@ nsCookieService::Observe(nsISupports *aSubject,
|
|||
NotifyChanged(nsnull, NS_LITERAL_STRING("reload").get());
|
||||
}
|
||||
// close the connection to the on-disk DB
|
||||
mStmtInsert = nsnull;
|
||||
mStmtDelete = nsnull;
|
||||
mStmtUpdate = nsnull;
|
||||
mDBConn = nsnull;
|
||||
CloseDB();
|
||||
// continue to use the in-memory DB
|
||||
} else if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_LEAVE).Equals(aData)) {
|
||||
// open the connection to the on-disk DB
|
||||
|
@ -831,8 +843,9 @@ nsCookieService::RemoveAll()
|
|||
// Database must be corrupted, so remove it completely.
|
||||
nsCOMPtr<nsIFile> dbFile;
|
||||
mDBConn->GetDatabaseFile(getter_AddRefs(dbFile));
|
||||
mDBConn->Close();
|
||||
CloseDB();
|
||||
dbFile->Remove(PR_FALSE);
|
||||
|
||||
InitDB();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,6 +166,7 @@ class nsCookieService : public nsICookieService
|
|||
void PrefChanged(nsIPrefBranch *aPrefBranch);
|
||||
nsresult InitDB();
|
||||
nsresult CreateTable();
|
||||
void CloseDB();
|
||||
nsresult Read();
|
||||
void GetCookieInternal(nsIURI *aHostURI, nsIChannel *aChannel, PRBool aHttpBound, char **aCookie);
|
||||
nsresult SetCookieStringInternal(nsIURI *aHostURI, nsIPrompt *aPrompt, const char *aCookieHeader, const char *aServerTime, nsIChannel *aChannel, PRBool aFromHttp);
|
||||
|
|
Загрузка…
Ссылка в новой задаче