Back out changeset 9e9e1e3a05a1 (bug 584316) for orange.
authorHenri Sivonen <hsivonen@iki.fi>
Fri, 01 Apr 2011 10:34:28 +0300
changeset 64601 9b459316a572021611242e9210b34b4d82deeb99
parent 64592 9e9e1e3a05a1528d9b4e613d127ab1d23e289db1
child 64602 7edef9fb11df93cd9120eb6326072c4c5edd004f
push idunknown
push userunknown
push dateunknown
bugs584316
milestone2.2a1pre
backs out9e9e1e3a05a1528d9b4e613d127ab1d23e289db1
Back out changeset 9e9e1e3a05a1 (bug 584316) for orange.
toolkit/components/downloads/nsDownloadManager.cpp
--- a/toolkit/components/downloads/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/nsDownloadManager.cpp
@@ -236,18 +236,17 @@ nsresult
 nsDownloadManager::RemoveDownloadsForURI(nsIURI *aURI)
 {
   mozStorageStatementScoper scope(mGetIdsForURIStatement);
 
   nsCAutoString source;
   nsresult rv = aURI->GetSpec(source);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = mGetIdsForURIStatement->BindUTF8StringByName(
-    NS_LITERAL_CSTRING("source"), source);
+  rv = mGetIdsForURIStatement->BindUTF8StringParameter(0, source);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRBool hasMore = PR_FALSE;
   nsAutoTArray<PRInt64, 4> downloads;
   // Get all the downloads that match the provided URI
   while (NS_SUCCEEDED(mGetIdsForURIStatement->ExecuteStep(&hasMore)) &&
          hasMore) {
     PRInt64 downloadId;
@@ -615,86 +614,89 @@ nsDownloadManager::CreateTable()
 nsresult
 nsDownloadManager::RestoreDatabaseState()
 {
   // Restore downloads that were in a scanning state.  We can assume that they
   // have been dealt with by the virus scanner
   nsCOMPtr<mozIStorageStatement> stmt;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "UPDATE moz_downloads "
-    "SET state = :state "
-    "WHERE state = :state_cond"), getter_AddRefs(stmt));
+    "SET state = ?1 "
+    "WHERE state = ?2"), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), nsIDownloadManager::DOWNLOAD_FINISHED);
+  PRInt32 i = 0;
+  rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_FINISHED);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state_cond"), nsIDownloadManager::DOWNLOAD_SCANNING);
+  rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_SCANNING);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stmt->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Convert supposedly-active downloads into downloads that should auto-resume
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "UPDATE moz_downloads "
-    "SET autoResume = :autoResume "
-    "WHERE state = :notStarted "
-      "OR state = :queued "
-      "OR state = :downloading"), getter_AddRefs(stmt));
+    "SET autoResume = ?1 "
+    "WHERE state = ?2 "
+      "OR state = ?3 "
+      "OR state = ?4"), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume"), nsDownload::AUTO_RESUME);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("notStarted"), nsIDownloadManager::DOWNLOAD_NOTSTARTED);
+  i = 0;
+  rv = stmt->BindInt32Parameter(i++, nsDownload::AUTO_RESUME);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("queued"), nsIDownloadManager::DOWNLOAD_QUEUED);
+  rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_NOTSTARTED);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("downloading"), nsIDownloadManager::DOWNLOAD_DOWNLOADING);
+  rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_QUEUED);
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_DOWNLOADING);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stmt->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Switch any download that is supposed to automatically resume and is in a
   // finished state to *not* automatically resume.  See Bug 409179 for details.
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "UPDATE moz_downloads "
-    "SET autoResume = :autoResume "
-    "WHERE state = :state "
-      "AND autoResume = :autoResume_cond"),
+    "SET autoResume = ?1 "
+    "WHERE state = ?2 "
+      "AND autoResume = ?3"),
     getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume"), nsDownload::DONT_RESUME);
+  i = 0;
+  rv = stmt->BindInt32Parameter(i++, nsDownload::DONT_RESUME);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), nsIDownloadManager::DOWNLOAD_FINISHED);
+  rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_FINISHED);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume_cond"), nsDownload::AUTO_RESUME);
+  rv = stmt->BindInt32Parameter(i++, nsDownload::AUTO_RESUME);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stmt->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 nsresult
 nsDownloadManager::RestoreActiveDownloads()
 {
   nsCOMPtr<mozIStorageStatement> stmt;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "SELECT id "
     "FROM moz_downloads "
-    "WHERE (state = :state AND LENGTH(entityID) > 0) "
-      "OR autoResume != :autoResume"), getter_AddRefs(stmt));
+    "WHERE (state = ?1 AND LENGTH(entityID) > 0) "
+      "OR autoResume != ?2"), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), nsIDownloadManager::DOWNLOAD_PAUSED);
+  rv = stmt->BindInt32Parameter(0, nsIDownloadManager::DOWNLOAD_PAUSED);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume"), nsDownload::DONT_RESUME);
+  rv = stmt->BindInt32Parameter(1, nsDownload::DONT_RESUME);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsresult retVal = NS_OK;
   PRBool hasResults;
   while (NS_SUCCEEDED(stmt->ExecuteStep(&hasResults)) && hasResults) {
     nsRefPtr<nsDownload> dl;
     // Keep trying to add even if we fail one, but make sure to return failure.
     // Additionally, be careful to not call anything that tries to change the
@@ -721,50 +723,59 @@ nsDownloadManager::AddDownloadToDB(const
                                    const nsACString &aMimeType,
                                    const nsACString &aPreferredApp,
                                    nsHandlerInfoAction aPreferredAction)
 {
   nsCOMPtr<mozIStorageStatement> stmt;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "INSERT INTO moz_downloads "
     "(name, source, target, tempPath, startTime, endTime, state, "
-     "mimeType, preferredApplication, preferredAction) VALUES "
-    "(:name, :source, :target, :tempPath, :startTime, :endTime, :state, "
-     ":mimeType, :preferredApplication, :preferredAction)"),
-    getter_AddRefs(stmt));
+     "mimeType, preferredApplication, preferredAction) "
+    "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)"), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), aName);
+  PRInt32 i = 0;
+  // name
+  rv = stmt->BindStringParameter(i++, aName);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("source"), aSource);
+  // source
+  rv = stmt->BindUTF8StringParameter(i++, aSource);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("target"), aTarget);
+  // target
+  rv = stmt->BindUTF8StringParameter(i++, aTarget);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindStringByName(NS_LITERAL_CSTRING("tempPath"), aTempPath);
+  // tempPath
+  rv = stmt->BindStringParameter(i++, aTempPath);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("startTime"), aStartTime);
+  // startTime
+  rv = stmt->BindInt64Parameter(i++, aStartTime);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("endTime"), aEndTime);
+  // endTime
+  rv = stmt->BindInt64Parameter(i++, aEndTime);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), nsIDownloadManager::DOWNLOAD_NOTSTARTED);
+  // state
+  rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_NOTSTARTED);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("mimeType"), aMimeType);
+  // mimeType
+  rv = stmt->BindUTF8StringParameter(i++, aMimeType);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("preferredApplication"), aPreferredApp);
+  // preferredApplication
+  rv = stmt->BindUTF8StringParameter(i++, aPreferredApp);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("preferredAction"), aPreferredAction);
+  // preferredAction
+  rv = stmt->BindInt32Parameter(i++, aPreferredAction);
   NS_ENSURE_SUCCESS(rv, 0);
 
   PRBool hasMore;
   rv = stmt->ExecuteStep(&hasMore); // we want to keep our lock
   NS_ENSURE_SUCCESS(rv, 0);
 
   PRInt64 id = 0;
   rv = mDBConn->GetLastInsertRowID(&id);
@@ -791,26 +802,26 @@ nsDownloadManager::InitDB()
     default:
       NS_ERROR("Unexpected value encountered for nsDownloadManager::mDBType");
       break;
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "UPDATE moz_downloads "
-    "SET tempPath = :tempPath, startTime = :startTime, endTime = :endTime, "
-      "state = :state, referrer = :referrer, entityID = :entityID, "
-      "currBytes = :currBytes, maxBytes = :maxBytes, autoResume = :autoResume "
-    "WHERE id = :id"), getter_AddRefs(mUpdateDownloadStatement));
+    "SET tempPath = ?1, startTime = ?2, endTime = ?3, state = ?4, "
+        "referrer = ?5, entityID = ?6, currBytes = ?7, maxBytes = ?8, "
+        "autoResume = ?9 "
+    "WHERE id = ?10"), getter_AddRefs(mUpdateDownloadStatement));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "SELECT id "
     "FROM moz_downloads "
-    "WHERE source = :source"), getter_AddRefs(mGetIdsForURIStatement));
+    "WHERE source = ?1"), getter_AddRefs(mGetIdsForURIStatement));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return rv;
 }
 
 nsresult
 nsDownloadManager::Init()
 {
@@ -942,20 +953,20 @@ nsDownloadManager::GetDownloadFromDB(PRU
 
   // First, let's query the database and see if it even exists
   nsCOMPtr<mozIStorageStatement> stmt;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "SELECT id, state, startTime, source, target, tempPath, name, referrer, "
            "entityID, currBytes, maxBytes, mimeType, preferredAction, "
            "preferredApplication, autoResume "
     "FROM moz_downloads "
-    "WHERE id = :id"), getter_AddRefs(stmt));
+    "WHERE id = ?1"), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), aID);
+  rv = stmt->BindInt64Parameter(0, aID);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRBool hasResults = PR_FALSE;
   rv = stmt->ExecuteStep(&hasResults);
   if (NS_FAILED(rv) || !hasResults)
     return NS_ERROR_NOT_AVAILABLE;
 
   // We have a download, so lets create it
@@ -1578,20 +1589,20 @@ nsDownloadManager::RemoveDownload(PRUint
   nsDownload *dl = FindDownload(aID);
   NS_ASSERTION(!dl, "Can't call RemoveDownload on a download in progress!");
   if (dl)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<mozIStorageStatement> stmt;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "DELETE FROM moz_downloads "
-    "WHERE id = :id"), getter_AddRefs(stmt));
+    "WHERE id = ?1"), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), aID); // unsigned; 64-bit to prevent overflow
+  rv = stmt->BindInt64Parameter(0, aID); // unsigned; 64-bit to prevent overflow
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stmt->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsISupportsPRUint32> id =
     do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1606,33 +1617,33 @@ nsDownloadManager::RemoveDownload(PRUint
 
 NS_IMETHODIMP
 nsDownloadManager::RemoveDownloadsByTimeframe(PRInt64 aStartTime,
                                               PRInt64 aEndTime)
 {
   nsCOMPtr<mozIStorageStatement> stmt;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "DELETE FROM moz_downloads "
-    "WHERE startTime >= :startTime "
-    "AND startTime <= :endTime "
-    "AND state NOT IN (:downloading, :paused, :queued)"), getter_AddRefs(stmt));
+    "WHERE startTime >= ?1 "
+    "AND startTime <= ?2 "
+    "AND state NOT IN (?3, ?4, ?5)"), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Bind the times
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("startTime"), aStartTime);
+  rv = stmt->BindInt64Parameter(0, aStartTime);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("endTime"), aEndTime);
+  rv = stmt->BindInt64Parameter(1, aEndTime);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Bind the active states
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("downloading"), nsIDownloadManager::DOWNLOAD_DOWNLOADING);
+  rv = stmt->BindInt32Parameter(2, nsIDownloadManager::DOWNLOAD_DOWNLOADING);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("paused"), nsIDownloadManager::DOWNLOAD_PAUSED);
+  rv = stmt->BindInt32Parameter(3, nsIDownloadManager::DOWNLOAD_PAUSED);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("queued"), nsIDownloadManager::DOWNLOAD_QUEUED);
+  rv = stmt->BindInt32Parameter(4, nsIDownloadManager::DOWNLOAD_QUEUED);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Execute
   rv = stmt->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Notify the UI with the topic and null subject to indicate "remove multiple"
   return mObserverService->NotifyObservers(nsnull,
@@ -1648,27 +1659,25 @@ nsDownloadManager::CleanUp()
                              nsIDownloadManager::DOWNLOAD_CANCELED,
                              nsIDownloadManager::DOWNLOAD_BLOCKED_PARENTAL,
                              nsIDownloadManager::DOWNLOAD_BLOCKED_POLICY,
                              nsIDownloadManager::DOWNLOAD_DIRTY };
 
   nsCOMPtr<mozIStorageStatement> stmt;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "DELETE FROM moz_downloads "
-    "WHERE state = :state1 "
-      "OR state = :state2 "
-      "OR state = :state3 "
-      "OR state = :state4 "
-      "OR state = :state5 "
-      "OR state = :state6"), getter_AddRefs(stmt));
+    "WHERE state = ?1 "
+      "OR state = ?2 "
+      "OR state = ?3 "
+      "OR state = ?4 "
+      "OR state = ?5 "
+      "OR state = ?6"), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
-  nsCString state(NS_LITERAL_CSTRING("state?"));
   for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(states); ++i) {
-    state.BeginWriting()[5] = '0' + i;
-    rv = stmt->BindInt32ByName(state, states[i]);
+    rv = stmt->BindInt32Parameter(i, states[i]);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   rv = stmt->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Notify the UI with the topic and null subject to indicate "remove multiple"
   return mObserverService->NotifyObservers(nsnull,
@@ -1687,27 +1696,25 @@ nsDownloadManager::GetCanCleanUp(PRBool 
                              nsIDownloadManager::DOWNLOAD_BLOCKED_PARENTAL,
                              nsIDownloadManager::DOWNLOAD_BLOCKED_POLICY,
                              nsIDownloadManager::DOWNLOAD_DIRTY };
 
   nsCOMPtr<mozIStorageStatement> stmt;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "SELECT COUNT(*) "
     "FROM moz_downloads "
-    "WHERE state = :state1 "
-      "OR state = :state2 "
-      "OR state = :state3 "
-      "OR state = :state4 "
-      "OR state = :state5 "
-      "OR state = :state6"), getter_AddRefs(stmt));
+    "WHERE state = ?1 "
+      "OR state = ?2 "
+      "OR state = ?3 "
+      "OR state = ?4 "
+      "OR state = ?5 "
+      "OR state = ?6"), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
-  nsCString state(NS_LITERAL_CSTRING("state?"));
   for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(states); ++i) {
-    state.BeginWriting()[5] = '0' + i;
-    rv = stmt->BindInt32ByName(state, states[i]);
+    rv = stmt->BindInt32Parameter(i, states[i]);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   PRBool moreResults; // We don't really care...
   rv = stmt->ExecuteStep(&moreResults);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRInt32 count;
@@ -2986,57 +2993,68 @@ nsDownload::IsFinished()
 nsresult
 nsDownload::UpdateDB()
 {
   NS_ASSERTION(mID, "Download ID is stored as zero.  This is bad!");
   NS_ASSERTION(mDownloadManager, "Egads!  We have no download manager!");
 
   mozIStorageStatement *stmt = mDownloadManager->mUpdateDownloadStatement;
 
+  PRInt32 i = 0;
+  // tempPath
   nsAutoString tempPath;
   if (mTempFile)
     (void)mTempFile->GetPath(tempPath);
-  nsresult rv = stmt->BindStringByName(NS_LITERAL_CSTRING("tempPath"), tempPath);
-
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("startTime"), mStartTime);
+  nsresult rv = stmt->BindStringParameter(i++, tempPath);
+
+  // startTime
+  rv = stmt->BindInt64Parameter(i++, mStartTime);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("endTime"), mLastUpdate);
+  // endTime
+  rv = stmt->BindInt64Parameter(i++, mLastUpdate);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("state"), mDownloadState);
+  // state
+  rv = stmt->BindInt32Parameter(i++, mDownloadState);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  // referrer
   if (mReferrer) {
     nsCAutoString referrer;
     rv = mReferrer->GetSpec(referrer);
     NS_ENSURE_SUCCESS(rv, rv);
-    rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("mimeType"), referrer);
+    rv = stmt->BindUTF8StringParameter(i++, referrer);
   } else {
-    rv = stmt->BindNullByName(NS_LITERAL_CSTRING("mimeType"));
+    rv = stmt->BindNullParameter(i++);
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("entityID"), mEntityID);
+  // entityID
+  rv = stmt->BindUTF8StringParameter(i++, mEntityID);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  // currBytes
   PRInt64 currBytes;
   (void)GetAmountTransferred(&currBytes);
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("currBytes"), currBytes);
+  rv = stmt->BindInt64Parameter(i++, currBytes);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  // maxBytes
   PRInt64 maxBytes;
   (void)GetSize(&maxBytes);
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("maxBytes"), maxBytes);
+  rv = stmt->BindInt64Parameter(i++, maxBytes);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("autoResume"), mAutoResume);
+  // autoResume
+  rv = stmt->BindInt32Parameter(i++, mAutoResume);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mID);
+  // id
+  rv = stmt->BindInt64Parameter(i++, mID);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return stmt->Execute();
 }
 
 nsresult
 nsDownload::FailDownload(nsresult aStatus, const PRUnichar *aMessage)
 {