зеркало из https://github.com/mozilla/pjs.git
Bug 584316 Fix DownloadManager usage of deprecated Storage binding APIs
r=sdwilsh
This commit is contained in:
Родитель
660df9ffc2
Коммит
4a50e4e7f5
|
@ -241,7 +241,8 @@ nsDownloadManager::RemoveDownloadsForURI(nsIURI *aURI)
|
||||||
nsresult rv = aURI->GetSpec(source);
|
nsresult rv = aURI->GetSpec(source);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = mGetIdsForURIStatement->BindUTF8StringParameter(0, source);
|
rv = mGetIdsForURIStatement->BindUTF8StringByName(
|
||||||
|
NS_LITERAL_CSTRING("source"), source);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
PRBool hasMore = PR_FALSE;
|
PRBool hasMore = PR_FALSE;
|
||||||
|
@ -619,14 +620,13 @@ nsDownloadManager::RestoreDatabaseState()
|
||||||
nsCOMPtr<mozIStorageStatement> stmt;
|
nsCOMPtr<mozIStorageStatement> stmt;
|
||||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"UPDATE moz_downloads "
|
"UPDATE moz_downloads "
|
||||||
"SET state = ?1 "
|
"SET state = :state "
|
||||||
"WHERE state = ?2"), getter_AddRefs(stmt));
|
"WHERE state = :state_cond"), getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
PRInt32 i = 0;
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), nsIDownloadManager::DOWNLOAD_FINISHED);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_FINISHED);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_SCANNING);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state_cond"), nsIDownloadManager::DOWNLOAD_SCANNING);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = stmt->Execute();
|
rv = stmt->Execute();
|
||||||
|
@ -635,20 +635,19 @@ nsDownloadManager::RestoreDatabaseState()
|
||||||
// Convert supposedly-active downloads into downloads that should auto-resume
|
// Convert supposedly-active downloads into downloads that should auto-resume
|
||||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"UPDATE moz_downloads "
|
"UPDATE moz_downloads "
|
||||||
"SET autoResume = ?1 "
|
"SET autoResume = :autoResume "
|
||||||
"WHERE state = ?2 "
|
"WHERE state = :notStarted "
|
||||||
"OR state = ?3 "
|
"OR state = :queued "
|
||||||
"OR state = ?4"), getter_AddRefs(stmt));
|
"OR state = :downloading"), getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
i = 0;
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume"), nsDownload::AUTO_RESUME);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsDownload::AUTO_RESUME);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_NOTSTARTED);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("notStarted"), nsIDownloadManager::DOWNLOAD_NOTSTARTED);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_QUEUED);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("queued"), nsIDownloadManager::DOWNLOAD_QUEUED);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_DOWNLOADING);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("downloading"), nsIDownloadManager::DOWNLOAD_DOWNLOADING);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = stmt->Execute();
|
rv = stmt->Execute();
|
||||||
|
@ -658,18 +657,17 @@ nsDownloadManager::RestoreDatabaseState()
|
||||||
// finished state to *not* automatically resume. See Bug 409179 for details.
|
// finished state to *not* automatically resume. See Bug 409179 for details.
|
||||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"UPDATE moz_downloads "
|
"UPDATE moz_downloads "
|
||||||
"SET autoResume = ?1 "
|
"SET autoResume = :autoResume "
|
||||||
"WHERE state = ?2 "
|
"WHERE state = :state "
|
||||||
"AND autoResume = ?3"),
|
"AND autoResume = :autoResume_cond"),
|
||||||
getter_AddRefs(stmt));
|
getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
i = 0;
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume"), nsDownload::DONT_RESUME);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsDownload::DONT_RESUME);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_FINISHED);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), nsIDownloadManager::DOWNLOAD_FINISHED);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsDownload::AUTO_RESUME);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume_cond"), nsDownload::AUTO_RESUME);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = stmt->Execute();
|
rv = stmt->Execute();
|
||||||
|
@ -685,13 +683,13 @@ nsDownloadManager::RestoreActiveDownloads()
|
||||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"SELECT id "
|
"SELECT id "
|
||||||
"FROM moz_downloads "
|
"FROM moz_downloads "
|
||||||
"WHERE (state = ?1 AND LENGTH(entityID) > 0) "
|
"WHERE (state = :state AND LENGTH(entityID) > 0) "
|
||||||
"OR autoResume != ?2"), getter_AddRefs(stmt));
|
"OR autoResume != :autoResume"), getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = stmt->BindInt32Parameter(0, nsIDownloadManager::DOWNLOAD_PAUSED);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), nsIDownloadManager::DOWNLOAD_PAUSED);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt32Parameter(1, nsDownload::DONT_RESUME);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume"), nsDownload::DONT_RESUME);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsresult retVal = NS_OK;
|
nsresult retVal = NS_OK;
|
||||||
|
@ -728,49 +726,40 @@ nsDownloadManager::AddDownloadToDB(const nsAString &aName,
|
||||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"INSERT INTO moz_downloads "
|
"INSERT INTO moz_downloads "
|
||||||
"(name, source, target, tempPath, startTime, endTime, state, "
|
"(name, source, target, tempPath, startTime, endTime, state, "
|
||||||
"mimeType, preferredApplication, preferredAction) "
|
"mimeType, preferredApplication, preferredAction) VALUES "
|
||||||
"VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)"), getter_AddRefs(stmt));
|
"(:name, :source, :target, :tempPath, :startTime, :endTime, :state, "
|
||||||
|
":mimeType, :preferredApplication, :preferredAction)"),
|
||||||
|
getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
PRInt32 i = 0;
|
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), aName);
|
||||||
// name
|
|
||||||
rv = stmt->BindStringParameter(i++, aName);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
// source
|
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("source"), aSource);
|
||||||
rv = stmt->BindUTF8StringParameter(i++, aSource);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
// target
|
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("target"), aTarget);
|
||||||
rv = stmt->BindUTF8StringParameter(i++, aTarget);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
// tempPath
|
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("tempPath"), aTempPath);
|
||||||
rv = stmt->BindStringParameter(i++, aTempPath);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
// startTime
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("startTime"), aStartTime);
|
||||||
rv = stmt->BindInt64Parameter(i++, aStartTime);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
// endTime
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("endTime"), aEndTime);
|
||||||
rv = stmt->BindInt64Parameter(i++, aEndTime);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
// state
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), nsIDownloadManager::DOWNLOAD_NOTSTARTED);
|
||||||
rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_NOTSTARTED);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
// mimeType
|
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("mimeType"), aMimeType);
|
||||||
rv = stmt->BindUTF8StringParameter(i++, aMimeType);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
// preferredApplication
|
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("preferredApplication"), aPreferredApp);
|
||||||
rv = stmt->BindUTF8StringParameter(i++, aPreferredApp);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
// preferredAction
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("preferredAction"), aPreferredAction);
|
||||||
rv = stmt->BindInt32Parameter(i++, aPreferredAction);
|
|
||||||
NS_ENSURE_SUCCESS(rv, 0);
|
NS_ENSURE_SUCCESS(rv, 0);
|
||||||
|
|
||||||
PRBool hasMore;
|
PRBool hasMore;
|
||||||
|
@ -807,16 +796,16 @@ nsDownloadManager::InitDB()
|
||||||
|
|
||||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"UPDATE moz_downloads "
|
"UPDATE moz_downloads "
|
||||||
"SET tempPath = ?1, startTime = ?2, endTime = ?3, state = ?4, "
|
"SET tempPath = :tempPath, startTime = :startTime, endTime = :endTime, "
|
||||||
"referrer = ?5, entityID = ?6, currBytes = ?7, maxBytes = ?8, "
|
"state = :state, referrer = :referrer, entityID = :entityID, "
|
||||||
"autoResume = ?9 "
|
"currBytes = :currBytes, maxBytes = :maxBytes, autoResume = :autoResume "
|
||||||
"WHERE id = ?10"), getter_AddRefs(mUpdateDownloadStatement));
|
"WHERE id = :id"), getter_AddRefs(mUpdateDownloadStatement));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"SELECT id "
|
"SELECT id "
|
||||||
"FROM moz_downloads "
|
"FROM moz_downloads "
|
||||||
"WHERE source = ?1"), getter_AddRefs(mGetIdsForURIStatement));
|
"WHERE source = :source"), getter_AddRefs(mGetIdsForURIStatement));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -958,10 +947,10 @@ nsDownloadManager::GetDownloadFromDB(PRUint32 aID, nsDownload **retVal)
|
||||||
"entityID, currBytes, maxBytes, mimeType, preferredAction, "
|
"entityID, currBytes, maxBytes, mimeType, preferredAction, "
|
||||||
"preferredApplication, autoResume "
|
"preferredApplication, autoResume "
|
||||||
"FROM moz_downloads "
|
"FROM moz_downloads "
|
||||||
"WHERE id = ?1"), getter_AddRefs(stmt));
|
"WHERE id = :id"), getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = stmt->BindInt64Parameter(0, aID);
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), aID);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
PRBool hasResults = PR_FALSE;
|
PRBool hasResults = PR_FALSE;
|
||||||
|
@ -1594,10 +1583,10 @@ nsDownloadManager::RemoveDownload(PRUint32 aID)
|
||||||
nsCOMPtr<mozIStorageStatement> stmt;
|
nsCOMPtr<mozIStorageStatement> stmt;
|
||||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"DELETE FROM moz_downloads "
|
"DELETE FROM moz_downloads "
|
||||||
"WHERE id = ?1"), getter_AddRefs(stmt));
|
"WHERE id = :id"), getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = stmt->BindInt64Parameter(0, aID); // unsigned; 64-bit to prevent overflow
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), aID); // unsigned; 64-bit to prevent overflow
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = stmt->Execute();
|
rv = stmt->Execute();
|
||||||
|
@ -1622,23 +1611,23 @@ nsDownloadManager::RemoveDownloadsByTimeframe(PRInt64 aStartTime,
|
||||||
nsCOMPtr<mozIStorageStatement> stmt;
|
nsCOMPtr<mozIStorageStatement> stmt;
|
||||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"DELETE FROM moz_downloads "
|
"DELETE FROM moz_downloads "
|
||||||
"WHERE startTime >= ?1 "
|
"WHERE startTime >= :startTime "
|
||||||
"AND startTime <= ?2 "
|
"AND startTime <= :endTime "
|
||||||
"AND state NOT IN (?3, ?4, ?5)"), getter_AddRefs(stmt));
|
"AND state NOT IN (:downloading, :paused, :queued)"), getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Bind the times
|
// Bind the times
|
||||||
rv = stmt->BindInt64Parameter(0, aStartTime);
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("startTime"), aStartTime);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt64Parameter(1, aEndTime);
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("endTime"), aEndTime);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Bind the active states
|
// Bind the active states
|
||||||
rv = stmt->BindInt32Parameter(2, nsIDownloadManager::DOWNLOAD_DOWNLOADING);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("downloading"), nsIDownloadManager::DOWNLOAD_DOWNLOADING);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt32Parameter(3, nsIDownloadManager::DOWNLOAD_PAUSED);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("paused"), nsIDownloadManager::DOWNLOAD_PAUSED);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindInt32Parameter(4, nsIDownloadManager::DOWNLOAD_QUEUED);
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("queued"), nsIDownloadManager::DOWNLOAD_QUEUED);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
|
@ -1664,15 +1653,17 @@ nsDownloadManager::CleanUp()
|
||||||
nsCOMPtr<mozIStorageStatement> stmt;
|
nsCOMPtr<mozIStorageStatement> stmt;
|
||||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"DELETE FROM moz_downloads "
|
"DELETE FROM moz_downloads "
|
||||||
"WHERE state = ?1 "
|
"WHERE state = :state1 "
|
||||||
"OR state = ?2 "
|
"OR state = :state2 "
|
||||||
"OR state = ?3 "
|
"OR state = :state3 "
|
||||||
"OR state = ?4 "
|
"OR state = :state4 "
|
||||||
"OR state = ?5 "
|
"OR state = :state5 "
|
||||||
"OR state = ?6"), getter_AddRefs(stmt));
|
"OR state = :state6"), getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
nsCString state(NS_LITERAL_CSTRING("state?"));
|
||||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(states); ++i) {
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(states); ++i) {
|
||||||
rv = stmt->BindInt32Parameter(i, states[i]);
|
state.BeginWriting()[5] = '0' + i;
|
||||||
|
rv = stmt->BindInt32ByName(state, states[i]);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1701,15 +1692,17 @@ nsDownloadManager::GetCanCleanUp(PRBool *aResult)
|
||||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"SELECT COUNT(*) "
|
"SELECT COUNT(*) "
|
||||||
"FROM moz_downloads "
|
"FROM moz_downloads "
|
||||||
"WHERE state = ?1 "
|
"WHERE state = :state1 "
|
||||||
"OR state = ?2 "
|
"OR state = :state2 "
|
||||||
"OR state = ?3 "
|
"OR state = :state3 "
|
||||||
"OR state = ?4 "
|
"OR state = :state4 "
|
||||||
"OR state = ?5 "
|
"OR state = :state5 "
|
||||||
"OR state = ?6"), getter_AddRefs(stmt));
|
"OR state = :state6"), getter_AddRefs(stmt));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
nsCString state(NS_LITERAL_CSTRING("state?"));
|
||||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(states); ++i) {
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(states); ++i) {
|
||||||
rv = stmt->BindInt32Parameter(i, states[i]);
|
state.BeginWriting()[5] = '0' + i;
|
||||||
|
rv = stmt->BindInt32ByName(state, states[i]);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2998,58 +2991,47 @@ nsDownload::UpdateDB()
|
||||||
|
|
||||||
mozIStorageStatement *stmt = mDownloadManager->mUpdateDownloadStatement;
|
mozIStorageStatement *stmt = mDownloadManager->mUpdateDownloadStatement;
|
||||||
|
|
||||||
PRInt32 i = 0;
|
|
||||||
// tempPath
|
|
||||||
nsAutoString tempPath;
|
nsAutoString tempPath;
|
||||||
if (mTempFile)
|
if (mTempFile)
|
||||||
(void)mTempFile->GetPath(tempPath);
|
(void)mTempFile->GetPath(tempPath);
|
||||||
nsresult rv = stmt->BindStringParameter(i++, tempPath);
|
nsresult rv = stmt->BindStringByName(NS_LITERAL_CSTRING("tempPath"), tempPath);
|
||||||
|
|
||||||
// startTime
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("startTime"), mStartTime);
|
||||||
rv = stmt->BindInt64Parameter(i++, mStartTime);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// endTime
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("endTime"), mLastUpdate);
|
||||||
rv = stmt->BindInt64Parameter(i++, mLastUpdate);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// state
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), mDownloadState);
|
||||||
rv = stmt->BindInt32Parameter(i++, mDownloadState);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// referrer
|
|
||||||
if (mReferrer) {
|
if (mReferrer) {
|
||||||
nsCAutoString referrer;
|
nsCAutoString referrer;
|
||||||
rv = mReferrer->GetSpec(referrer);
|
rv = mReferrer->GetSpec(referrer);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = stmt->BindUTF8StringParameter(i++, referrer);
|
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("mimeType"), referrer);
|
||||||
} else {
|
} else {
|
||||||
rv = stmt->BindNullParameter(i++);
|
rv = stmt->BindNullByName(NS_LITERAL_CSTRING("mimeType"));
|
||||||
}
|
}
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// entityID
|
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("entityID"), mEntityID);
|
||||||
rv = stmt->BindUTF8StringParameter(i++, mEntityID);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// currBytes
|
|
||||||
PRInt64 currBytes;
|
PRInt64 currBytes;
|
||||||
(void)GetAmountTransferred(&currBytes);
|
(void)GetAmountTransferred(&currBytes);
|
||||||
rv = stmt->BindInt64Parameter(i++, currBytes);
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("currBytes"), currBytes);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// maxBytes
|
|
||||||
PRInt64 maxBytes;
|
PRInt64 maxBytes;
|
||||||
(void)GetSize(&maxBytes);
|
(void)GetSize(&maxBytes);
|
||||||
rv = stmt->BindInt64Parameter(i++, maxBytes);
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("maxBytes"), maxBytes);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// autoResume
|
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume"), mAutoResume);
|
||||||
rv = stmt->BindInt32Parameter(i++, mAutoResume);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// id
|
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mID);
|
||||||
rv = stmt->BindInt64Parameter(i++, mID);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
return stmt->Execute();
|
return stmt->Execute();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче