diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index 39fbea6b5bce..20eb987f12f4 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -421,7 +421,6 @@ struct nsOfflineCacheRecord const PRUint8 *metaData; PRUint32 metaDataLen; PRInt32 generation; - PRInt32 flags; PRInt32 dataSize; PRInt32 fetchCount; PRInt64 lastFetched; @@ -434,12 +433,6 @@ CreateCacheEntry(nsOfflineCacheDevice *device, const nsCString *fullKey, const nsOfflineCacheRecord &rec) { - if (rec.flags != 0) - { - LOG(("refusing to load busy entry\n")); - return nsnull; - } - nsCacheEntry *entry; nsresult rv = nsCacheEntry::Create(fullKey->get(), // XXX enable sharing @@ -895,7 +888,6 @@ nsOfflineCacheDevice::UpdateEntry(nsCacheEntry *entry) nsOfflineCacheRecord rec; rec.metaData = (const PRUint8 *) md; rec.metaDataLen = mdSize; - rec.flags = 0; // mark entry as inactive rec.dataSize = entry->DataSize(); rec.fetchCount = entry->FetchCount(); rec.lastFetched = PRTimeFromSeconds(entry->LastFetched()); @@ -906,14 +898,13 @@ nsOfflineCacheDevice::UpdateEntry(nsCacheEntry *entry) nsresult rv; rv = statement->BindBlobByIndex(0, rec.metaData, rec.metaDataLen); - rv |= statement->BindInt32ByIndex(1, rec.flags); - rv |= statement->BindInt32ByIndex(2, rec.dataSize); - rv |= statement->BindInt32ByIndex(3, rec.fetchCount); - rv |= statement->BindInt64ByIndex(4, rec.lastFetched); - rv |= statement->BindInt64ByIndex(5, rec.lastModified); - rv |= statement->BindInt64ByIndex(6, rec.expirationTime); - rv |= statement->BindUTF8StringByIndex(7, nsDependentCString(cid)); - rv |= statement->BindUTF8StringByIndex(8, nsDependentCString(key)); + rv |= statement->BindInt32ByIndex(1, rec.dataSize); + rv |= statement->BindInt32ByIndex(2, rec.fetchCount); + rv |= statement->BindInt64ByIndex(3, rec.lastFetched); + rv |= statement->BindInt64ByIndex(4, rec.lastModified); + rv |= statement->BindInt64ByIndex(5, rec.expirationTime); + rv |= statement->BindUTF8StringByIndex(6, nsDependentCString(cid)); + rv |= statement->BindUTF8StringByIndex(7, nsDependentCString(key)); NS_ENSURE_SUCCESS(rv, rv); bool hasRows; @@ -1043,7 +1034,6 @@ nsOfflineCacheDevice::Init() // build the table // // "Generation" is the data file generation number. - // "Flags" is a bit-field indicating the state of the entry. // rv = mDB->ExecuteSimpleSQL( NS_LITERAL_CSTRING("CREATE TABLE IF NOT EXISTS moz_cache (\n" @@ -1051,7 +1041,6 @@ nsOfflineCacheDevice::Init() " Key TEXT,\n" " MetaData BLOB,\n" " Generation INTEGER,\n" - " Flags INTEGER,\n" " DataSize INTEGER,\n" " FetchCount INTEGER,\n" " LastFetched INTEGER,\n" @@ -1134,12 +1123,11 @@ nsOfflineCacheDevice::Init() StatementSql ( mStatement_CacheSize, "SELECT Sum(DataSize) from moz_cache;" ), StatementSql ( mStatement_ApplicationCacheSize, "SELECT Sum(DataSize) from moz_cache WHERE ClientID = ?;" ), StatementSql ( mStatement_EntryCount, "SELECT count(*) from moz_cache;" ), - StatementSql ( mStatement_UpdateEntry, "UPDATE moz_cache SET MetaData = ?, Flags = ?, DataSize = ?, FetchCount = ?, LastFetched = ?, LastModified = ?, ExpirationTime = ? WHERE ClientID = ? AND Key = ?;" ), + StatementSql ( mStatement_UpdateEntry, "UPDATE moz_cache SET MetaData = ?, DataSize = ?, FetchCount = ?, LastFetched = ?, LastModified = ?, ExpirationTime = ? WHERE ClientID = ? AND Key = ?;" ), StatementSql ( mStatement_UpdateEntrySize, "UPDATE moz_cache SET DataSize = ? WHERE ClientID = ? AND Key = ?;" ), - StatementSql ( mStatement_UpdateEntryFlags, "UPDATE moz_cache SET Flags = ? WHERE ClientID = ? AND Key = ?;" ), StatementSql ( mStatement_DeleteEntry, "DELETE FROM moz_cache WHERE ClientID = ? AND Key = ?;" ), - StatementSql ( mStatement_FindEntry, "SELECT MetaData, Generation, Flags, DataSize, FetchCount, LastFetched, LastModified, ExpirationTime, ItemType FROM moz_cache WHERE ClientID = ? AND Key = ?;" ), - StatementSql ( mStatement_BindEntry, "INSERT INTO moz_cache (ClientID, Key, MetaData, Generation, Flags, DataSize, FetchCount, LastFetched, LastModified, ExpirationTime) VALUES(?,?,?,?,?,?,?,?,?,?);" ), + StatementSql ( mStatement_FindEntry, "SELECT MetaData, Generation, DataSize, FetchCount, LastFetched, LastModified, ExpirationTime, ItemType FROM moz_cache WHERE ClientID = ? AND Key = ?;" ), + StatementSql ( mStatement_BindEntry, "INSERT INTO moz_cache (ClientID, Key, MetaData, Generation, DataSize, FetchCount, LastFetched, LastModified, ExpirationTime) VALUES(?,?,?,?,?,?,?,?,?);" ), StatementSql ( mStatement_MarkEntry, "UPDATE moz_cache SET ItemType = (ItemType | ?) WHERE ClientID = ? AND Key = ?;" ), StatementSql ( mStatement_UnmarkEntry, "UPDATE moz_cache SET ItemType = (ItemType & ~?) WHERE ClientID = ? AND Key = ?;" ), @@ -1175,13 +1163,6 @@ nsOfflineCacheDevice::Init() NS_ENSURE_SUCCESS(rv, rv); } - // Clear up any dangling active flags - rv = mDB->ExecuteSimpleSQL( - NS_LITERAL_CSTRING("UPDATE moz_cache" - " SET Flags=(Flags & ~1)" - " WHERE (Flags & 1);")); - NS_ENSURE_SUCCESS(rv, rv); - rv = InitActiveCaches(); NS_ENSURE_SUCCESS(rv, rv); @@ -1277,7 +1258,6 @@ nsOfflineCacheDevice::Shutdown() mStatement_EntryCount = nsnull; mStatement_UpdateEntry = nsnull; mStatement_UpdateEntrySize = nsnull; - mStatement_UpdateEntryFlags = nsnull; mStatement_DeleteEntry = nsnull; mStatement_FindEntry = nsnull; mStatement_BindEntry = nsnull; @@ -1355,17 +1335,15 @@ nsOfflineCacheDevice::FindEntry(nsCString *fullKey, bool *collision) statement->GetSharedBlob(0, &rec.metaDataLen, (const PRUint8 **) &rec.metaData); rec.generation = statement->AsInt32(1); - rec.flags = statement->AsInt32(2); - rec.dataSize = statement->AsInt32(3); - rec.fetchCount = statement->AsInt32(4); - rec.lastFetched = statement->AsInt64(5); - rec.lastModified = statement->AsInt64(6); - rec.expirationTime = statement->AsInt64(7); + rec.dataSize = statement->AsInt32(2); + rec.fetchCount = statement->AsInt32(3); + rec.lastFetched = statement->AsInt64(4); + rec.lastModified = statement->AsInt64(5); + rec.expirationTime = statement->AsInt64(6); - LOG(("entry: [%u %d %d %d %d %lld %lld %lld]\n", + LOG(("entry: [%u %d %d %d %lld %lld %lld]\n", rec.metaDataLen, rec.generation, - rec.flags, rec.dataSize, rec.fetchCount, rec.lastFetched, @@ -1386,29 +1364,6 @@ nsOfflineCacheDevice::FindEntry(nsCString *fullKey, bool *collision) delete entry; return nsnull; } - - statement->Reset(); - - // mark as active - AutoResetStatement updateStatement(mStatement_UpdateEntryFlags); - rec.flags |= 0x1; - rv |= updateStatement->BindInt32ByIndex(0, rec.flags); - rv |= updateStatement->BindUTF8StringByIndex(1, nsDependentCString(cid)); - rv |= updateStatement->BindUTF8StringByIndex(2, nsDependentCString(key)); - if (NS_FAILED(rv)) - { - delete entry; - return nsnull; - } - - rv = updateStatement->ExecuteStep(&hasRows); - if (NS_FAILED(rv)) - { - delete entry; - return nsnull; - } - - NS_ASSERTION(!hasRows, "UPDATE should not result in output"); } return entry; @@ -1483,7 +1438,6 @@ nsOfflineCacheDevice::BindEntry(nsCacheEntry *entry) rec.metaData = NULL; // don't write any metadata now. rec.metaDataLen = 0; rec.generation = binding->mGeneration; - rec.flags = 0x1; // mark entry as active, we'll reset this in DeactivateEntry rec.dataSize = 0; rec.fetchCount = entry->FetchCount(); rec.lastFetched = PRTimeFromSeconds(entry->LastFetched()); @@ -1497,12 +1451,11 @@ nsOfflineCacheDevice::BindEntry(nsCacheEntry *entry) rv |= statement->BindUTF8StringByIndex(1, nsDependentCString(rec.key)); rv |= statement->BindBlobByIndex(2, rec.metaData, rec.metaDataLen); rv |= statement->BindInt32ByIndex(3, rec.generation); - rv |= statement->BindInt32ByIndex(4, rec.flags); - rv |= statement->BindInt32ByIndex(5, rec.dataSize); - rv |= statement->BindInt32ByIndex(6, rec.fetchCount); - rv |= statement->BindInt64ByIndex(7, rec.lastFetched); - rv |= statement->BindInt64ByIndex(8, rec.lastModified); - rv |= statement->BindInt64ByIndex(9, rec.expirationTime); + rv |= statement->BindInt32ByIndex(4, rec.dataSize); + rv |= statement->BindInt32ByIndex(5, rec.fetchCount); + rv |= statement->BindInt64ByIndex(6, rec.lastFetched); + rv |= statement->BindInt64ByIndex(7, rec.lastModified); + rv |= statement->BindInt64ByIndex(8, rec.expirationTime); NS_ENSURE_SUCCESS(rv, rv); bool hasRows; @@ -1705,12 +1658,11 @@ nsOfflineCacheDevice::Visit(nsICacheVisitor *visitor) statement->GetSharedBlob(2, &rec.metaDataLen, (const PRUint8 **) &rec.metaData); rec.generation = statement->AsInt32(3); - rec.flags = statement->AsInt32(4); - rec.dataSize = statement->AsInt32(5); - rec.fetchCount = statement->AsInt32(6); - rec.lastFetched = statement->AsInt64(7); - rec.lastModified = statement->AsInt64(8); - rec.expirationTime = statement->AsInt64(9); + rec.dataSize = statement->AsInt32(4); + rec.fetchCount = statement->AsInt32(5); + rec.lastFetched = statement->AsInt64(6); + rec.lastModified = statement->AsInt64(7); + rec.expirationTime = statement->AsInt64(8); bool keepGoing; rv = visitor->VisitEntry(OFFLINE_CACHE_DEVICE_ID, info, &keepGoing); @@ -1738,7 +1690,7 @@ nsOfflineCacheDevice::EvictEntries(const char *clientID) nsresult rv; if (clientID) { - rv = mDB->CreateStatement(NS_LITERAL_CSTRING("DELETE FROM moz_cache WHERE ClientID=? AND Flags = 0;"), + rv = mDB->CreateStatement(NS_LITERAL_CSTRING("DELETE FROM moz_cache WHERE ClientID=?;"), getter_AddRefs(statement)); NS_ENSURE_SUCCESS(rv, rv); @@ -1760,7 +1712,7 @@ nsOfflineCacheDevice::EvictEntries(const char *clientID) } else { - rv = mDB->CreateStatement(NS_LITERAL_CSTRING("DELETE FROM moz_cache WHERE Flags = 0;"), + rv = mDB->CreateStatement(NS_LITERAL_CSTRING("DELETE FROM moz_cache;"), getter_AddRefs(statement)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.h b/netwerk/cache/nsDiskCacheDeviceSQL.h index 1c76fa42dddc..f507e5e807f6 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.h +++ b/netwerk/cache/nsDiskCacheDeviceSQL.h @@ -236,7 +236,6 @@ private: nsCOMPtr mStatement_EntryCount; nsCOMPtr mStatement_UpdateEntry; nsCOMPtr mStatement_UpdateEntrySize; - nsCOMPtr mStatement_UpdateEntryFlags; nsCOMPtr mStatement_DeleteEntry; nsCOMPtr mStatement_FindEntry; nsCOMPtr mStatement_BindEntry;