231 |
231 |
232 return status; |
232 return status; |
233 } |
233 } |
234 |
234 |
235 // ----------------------------------------------------------------------------- |
235 // ----------------------------------------------------------------------------- |
|
236 // CHttpCacheLookupTable::RemoveByPosition |
|
237 // |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 TInt CHttpCacheLookupTable::RemoveByPosition( TInt aPos ) |
|
241 { |
|
242 TInt status( KErrNotFound ); |
|
243 |
|
244 if ( Valid( aPos ) ) |
|
245 { |
|
246 CHttpCacheEntry* entry = iEntries->At( aPos ); |
|
247 SetDeleted( aPos ); |
|
248 delete entry; |
|
249 iCount--; |
|
250 status = KErrNone; |
|
251 } |
|
252 |
|
253 return status; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
236 // CHttpCacheLookupTable::EraseCacheEntry |
257 // CHttpCacheLookupTable::EraseCacheEntry |
237 // |
258 // |
238 // ----------------------------------------------------------------------------- |
259 // ----------------------------------------------------------------------------- |
239 // |
260 // |
240 void CHttpCacheLookupTable::EraseCacheEntry( const TDesC8& aUrl ) |
261 void CHttpCacheLookupTable::EraseCacheEntry( const TDesC8& aUrl ) |
348 { |
369 { |
349 // create empty object |
370 // create empty object |
350 CHttpCacheEntry* entry = CHttpCacheEntry::NewLC( KNullDesC8, *iEvictionHandler ); |
371 CHttpCacheEntry* entry = CHttpCacheEntry::NewLC( KNullDesC8, *iEvictionHandler ); |
351 // read it |
372 // read it |
352 err = entry->Internalize( aReadStream ); |
373 err = entry->Internalize( aReadStream ); |
353 // leave only on no memory |
374 |
354 if( err == KErrNone ) |
375 if ( err == KErrNone && entry->BodySize() > 0 ) |
355 { |
376 { |
356 // insert to the table |
377 // cacheEntry is valid, insert into the table |
357 InsertL( entry ); |
378 InsertL( entry ); |
358 contentSize += entry->HeaderSize(); |
379 contentSize += entry->HeaderSize(); |
359 contentSize += entry->BodySize(); |
380 contentSize += entry->BodySize(); |
360 } |
381 } |
361 else if ( err == KErrNoMemory ) |
382 else if ( err == KErrNoMemory ) |
362 { |
383 { |
|
384 // Only leave if no memory |
363 User::Leave( KErrNoMemory ); |
385 User::Leave( KErrNoMemory ); |
364 } |
386 } |
365 else |
387 else if ( entry->BodySize() == 0 ) |
366 { |
388 { |
367 // suggestions |
389 // This is an empty cache entry, remove it from file system. |
|
390 // Use CreateNewFilesL() to open file handles, so we can delete |
|
391 // the files associated with the cache entry. |
|
392 iStreamHandler->CreateNewFilesL( *entry ); |
|
393 iStreamHandler->EraseCacheFile( *entry ); |
368 } |
394 } |
369 |
395 |
370 // takes ownership |
396 // takes ownership |
371 CleanupStack::Pop(); // entry |
397 CleanupStack::Pop(); // entry |
372 } |
398 } |
688 // ----------------------------------------------------------------------------- |
714 // ----------------------------------------------------------------------------- |
689 // CHttpCacheLookupTable::Valid |
715 // CHttpCacheLookupTable::Valid |
690 // |
716 // |
691 // ----------------------------------------------------------------------------- |
717 // ----------------------------------------------------------------------------- |
692 // |
718 // |
693 TBool CHttpCacheLookupTable::Valid( |
719 TBool CHttpCacheLookupTable::Valid( TInt aPos ) |
694 TInt aPos ) |
|
695 { |
720 { |
696 return( BoundaryCheck( aPos ) && !Empty( aPos ) && !Deleted( aPos ) ); |
721 return( BoundaryCheck( aPos ) && !Empty( aPos ) && !Deleted( aPos ) ); |
697 } |
722 } |
698 |
723 |
699 // ----------------------------------------------------------------------------- |
724 // ----------------------------------------------------------------------------- |
700 // CHttpCacheLookupTable::Empty |
725 // CHttpCacheLookupTable::Empty |
701 // |
726 // |
702 // ----------------------------------------------------------------------------- |
727 // ----------------------------------------------------------------------------- |
703 // |
728 // |
704 TBool CHttpCacheLookupTable::Empty( |
729 TBool CHttpCacheLookupTable::Empty( TInt aPos ) |
705 TInt aPos ) |
|
706 { |
730 { |
707 return( BoundaryCheck( aPos ) && iEntries->At( aPos ) == NULL ); |
731 return( BoundaryCheck( aPos ) && iEntries->At( aPos ) == NULL ); |
708 } |
732 } |
709 |
733 |
710 // ----------------------------------------------------------------------------- |
734 // ----------------------------------------------------------------------------- |
807 delete newEntry; |
831 delete newEntry; |
808 aHttpCacheLookupTable->iCount--; |
832 aHttpCacheLookupTable->iCount--; |
809 } |
833 } |
810 } |
834 } |
811 } |
835 } |
|
836 |
|
837 // ----------------------------------------------------------------------------- |
|
838 // CHttpCacheLookupTable::FindCacheEntryIndex |
|
839 // |
|
840 // ----------------------------------------------------------------------------- |
|
841 // |
|
842 void CHttpCacheLookupTable::FindCacheEntryIndex( |
|
843 const CHttpCacheEntry& aCacheEntry, |
|
844 TInt* aIndex ) |
|
845 { |
|
846 *aIndex = -1; |
|
847 for ( TInt i = 0; i < iEntries->Count(); i++ ) |
|
848 { |
|
849 CHttpCacheEntry* entry = iEntries->At( i ); |
|
850 |
|
851 if ( entry == &aCacheEntry ) |
|
852 { |
|
853 if ( aIndex ) |
|
854 { |
|
855 *aIndex = i; |
|
856 } |
|
857 break; |
|
858 } |
|
859 } |
|
860 } |
|
861 |
812 // End of File |
862 // End of File |