diff -r 7c90e6132015 -r 10e98eab6f85 webengine/osswebengine/cache/src/HttpCacheLookupTable.cpp --- a/webengine/osswebengine/cache/src/HttpCacheLookupTable.cpp Fri May 08 08:25:06 2009 +0300 +++ b/webengine/osswebengine/cache/src/HttpCacheLookupTable.cpp Fri Jul 03 15:54:40 2009 +0100 @@ -233,6 +233,27 @@ } // ----------------------------------------------------------------------------- +// CHttpCacheLookupTable::RemoveByPosition +// +// ----------------------------------------------------------------------------- +// +TInt CHttpCacheLookupTable::RemoveByPosition( TInt aPos ) + { + TInt status( KErrNotFound ); + + if ( Valid( aPos ) ) + { + CHttpCacheEntry* entry = iEntries->At( aPos ); + SetDeleted( aPos ); + delete entry; + iCount--; + status = KErrNone; + } + + return status; + } + +// ----------------------------------------------------------------------------- // CHttpCacheLookupTable::EraseCacheEntry // // ----------------------------------------------------------------------------- @@ -350,21 +371,26 @@ CHttpCacheEntry* entry = CHttpCacheEntry::NewLC( KNullDesC8, *iEvictionHandler ); // read it err = entry->Internalize( aReadStream ); - // leave only on no memory - if( err == KErrNone ) + + if ( err == KErrNone && entry->BodySize() > 0 ) { - // insert to the table + // cacheEntry is valid, insert into the table InsertL( entry ); contentSize += entry->HeaderSize(); contentSize += entry->BodySize(); } else if ( err == KErrNoMemory ) { + // Only leave if no memory User::Leave( KErrNoMemory ); } - else + else if ( entry->BodySize() == 0 ) { - // suggestions + // This is an empty cache entry, remove it from file system. + // Use CreateNewFilesL() to open file handles, so we can delete + // the files associated with the cache entry. + iStreamHandler->CreateNewFilesL( *entry ); + iStreamHandler->EraseCacheFile( *entry ); } // takes ownership @@ -690,8 +716,7 @@ // // ----------------------------------------------------------------------------- // -TBool CHttpCacheLookupTable::Valid( - TInt aPos ) +TBool CHttpCacheLookupTable::Valid( TInt aPos ) { return( BoundaryCheck( aPos ) && !Empty( aPos ) && !Deleted( aPos ) ); } @@ -701,8 +726,7 @@ // // ----------------------------------------------------------------------------- // -TBool CHttpCacheLookupTable::Empty( - TInt aPos ) +TBool CHttpCacheLookupTable::Empty( TInt aPos ) { return( BoundaryCheck( aPos ) && iEntries->At( aPos ) == NULL ); } @@ -809,4 +833,30 @@ } } } + +// ----------------------------------------------------------------------------- +// CHttpCacheLookupTable::FindCacheEntryIndex +// +// ----------------------------------------------------------------------------- +// +void CHttpCacheLookupTable::FindCacheEntryIndex( + const CHttpCacheEntry& aCacheEntry, + TInt* aIndex ) + { + *aIndex = -1; + for ( TInt i = 0; i < iEntries->Count(); i++ ) + { + CHttpCacheEntry* entry = iEntries->At( i ); + + if ( entry == &aCacheEntry ) + { + if ( aIndex ) + { + *aIndex = i; + } + break; + } + } + } + // End of File