Bug 385876 - DM should cache the query that nsDownload::UpdateDB uses. Patch by Ryan Jones <sciguyryan@gmail.com>. r=sdwilsh

This commit is contained in:
sdwilsh@shawnwilsher.com 2007-07-02 10:29:59 -07:00
Родитель 988c3cbf34
Коммит 21257f574d
2 изменённых файлов: 12 добавлений и 10 удалений

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

@ -63,7 +63,6 @@
#include "nsEmbedCID.h"
#include "mozStorageCID.h"
#include "mozIStorageService.h"
#include "mozIStorageStatement.h"
#include "mozStorageHelper.h"
#include "nsIMutableArray.h"
#include "nsIAlertsService.h"
@ -436,6 +435,13 @@ nsDownloadManager::Init()
mObserverService->AddObserver(this, "quit-application-requested", PR_FALSE);
mObserverService->AddObserver(this, "offline-requested", PR_FALSE);
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
"UPDATE moz_downloads "
"SET name = ?1, source = ?2, target = ?3, startTime = ?4, endTime = ?5,"
"state = ?6 "
"WHERE id = ?7"), getter_AddRefs(mUpdateDownloadStatement));
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -1581,16 +1587,10 @@ nsDownload::UpdateDB()
NS_ASSERTION(mID, "Download ID is stored as zero. This is bad!");
NS_ASSERTION(mDownloadManager, "Egads! We have no download manager!");
nsCOMPtr<mozIStorageStatement> stmt;
nsresult rv = mDownloadManager->mDBConn->CreateStatement(NS_LITERAL_CSTRING(
"UPDATE moz_downloads "
"SET name = ?1, source = ?2, target = ?3, startTime = ?4, endTime = ?5,"
"state = ?6 "
"WHERE id = ?7"), getter_AddRefs(stmt));
NS_ENSURE_SUCCESS(rv, rv);
mozIStorageStatement *stmt = mDownloadManager->mUpdateDownloadStatement;
// name
rv = stmt->BindStringParameter(0, mDisplayName);
nsresult rv = stmt->BindStringParameter(0, mDisplayName);
NS_ENSURE_SUCCESS(rv, rv);
// source

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

@ -60,6 +60,7 @@
#include "nsIMIMEInfo.h"
#include "nsITimer.h"
#include "mozIStorageConnection.h"
#include "mozIStorageStatement.h"
#include "nsISupportsArray.h"
#include "nsCOMArray.h"
#include "nsArrayEnumerator.h"
@ -184,6 +185,7 @@ private:
nsCOMPtr<mozIStorageConnection> mDBConn;
nsCOMArray<nsDownload> mCurrentDownloads;
nsCOMPtr<nsIObserverService> mObserverService;
nsCOMPtr<mozIStorageStatement> mUpdateDownloadStatement;
friend class nsDownload;
};