webengine/osswebengine/cache/inc/HttpCacheLookupTable.h
changeset 0 dd21522fd290
child 1 7c90e6132015
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Definition of CHttpCacheLookupTable
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CHTTPCACHELOOKUPTABLE_H
       
    19 #define CHTTPCACHELOOKUPTABLE_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <s32file.h>
       
    24 
       
    25 // CONSTANTS
       
    26 
       
    27 // MACROS
       
    28 
       
    29 // DATA TYPES
       
    30 
       
    31 // FUNCTION PROTOTYPES
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class CHttpCacheEntry;
       
    35 class RFileWriteStream;
       
    36 class RFileReadStream;
       
    37 class CHttpCacheEvictionHandler;
       
    38 class CHttpCacheStreamHandler;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *
       
    44 *  @lib
       
    45 *  @since 3.1
       
    46 */
       
    47 class CHttpCacheLookupTable : public CBase
       
    48     {
       
    49     public:  // Constructors and destructor
       
    50         
       
    51         /**
       
    52         * Two-phased constructor.
       
    53         * @since 3.1
       
    54         * @param
       
    55         * @param
       
    56         * @return CHttpCacheLookupTable object.
       
    57         */
       
    58         static CHttpCacheLookupTable* NewL( CHttpCacheEvictionHandler& aEvictionHandler, CHttpCacheStreamHandler& aStreamHandler );
       
    59         
       
    60         /**
       
    61         * Destructor.
       
    62         */
       
    63         virtual ~CHttpCacheLookupTable();
       
    64         
       
    65     public: // new functions
       
    66     
       
    67         /**
       
    68         *
       
    69         * @since 3.1
       
    70         * @param
       
    71         * @return
       
    72         */
       
    73         CHttpCacheEntry* InsertL( const TDesC8& aUrl );
       
    74         
       
    75         /**
       
    76         *
       
    77         * @since 3.1
       
    78         * @param
       
    79         * @return
       
    80         */
       
    81         CHttpCacheEntry* Find( const TDesC8& aUrl );
       
    82         
       
    83         /**
       
    84         *
       
    85         * @since 3.1
       
    86         * @param
       
    87         * @return
       
    88         */
       
    89         TInt Remove( const TDesC8& aUrl );
       
    90         
       
    91         /**
       
    92         *
       
    93         * @since 3.1
       
    94         * @param
       
    95         * @return
       
    96         */
       
    97         TInt RemoveAll();
       
    98         
       
    99         /**
       
   100         *
       
   101         * @since 7.1
       
   102         * @param
       
   103         * @return
       
   104         */
       
   105         TInt CHttpCacheLookupTable::ListFiles( RPointerArray<TDesC>& aFilenameList );
       
   106         
       
   107         /**
       
   108         *
       
   109         * @since 3.1
       
   110         * @param
       
   111         * @return
       
   112         */
       
   113         const CArrayPtrFlat<CHttpCacheEntry>& Entries() const { return *iEntries; }
       
   114         
       
   115         /**
       
   116         *
       
   117         * @since 3.1
       
   118         * @param
       
   119         * @return
       
   120         */
       
   121         void EraseCorruptEntry( const TDesC8& aUrl );
       
   122         
       
   123         /**
       
   124         *
       
   125         * @since 3.1
       
   126         * @param
       
   127         * @return
       
   128         */
       
   129         void InternalizeL( RFileReadStream& aReadStream, const TDesC& aDirectory );
       
   130         
       
   131         /**
       
   132         *
       
   133         * @since 3.1
       
   134         * @param
       
   135         * @return
       
   136         */
       
   137         void ExternalizeL( RFileWriteStream& aWriteStream );
       
   138         
       
   139         /**
       
   140         *
       
   141         * @since 3.1
       
   142         * @param
       
   143         * @return
       
   144         */
       
   145         void MergeL( CHttpCacheLookupTable* aHttpCacheLookupTable, RFs aRfs  );
       
   146         
       
   147     private:
       
   148         
       
   149         /**
       
   150         * Construct.
       
   151         * @since 3.1
       
   152         * @param
       
   153         * @param
       
   154         * @return CHttpCacheLookupTable object.
       
   155         */
       
   156         CHttpCacheLookupTable( CHttpCacheEvictionHandler& aEvictionHandler, CHttpCacheStreamHandler& aStreamHandler );
       
   157         
       
   158         /**
       
   159         * By default Symbian 2nd phase constructor is private.
       
   160         */
       
   161         void ConstructL();
       
   162         
       
   163     private: //
       
   164         
       
   165         /**
       
   166         *
       
   167         * @since 3.1
       
   168         * @param
       
   169         * @return
       
   170         */
       
   171         TInt InsertL( CHttpCacheEntry* aCacheEntry );
       
   172         
       
   173         /**
       
   174         *
       
   175         * @since 3.1
       
   176         * @param
       
   177         * @return
       
   178         */
       
   179         TInt Probe( const TDesC8& aKey, TBool aInsert );
       
   180         
       
   181         /**
       
   182         *
       
   183         * @since 3.1
       
   184         * @param
       
   185         * @return
       
   186         */
       
   187         TInt HashUrl( const TDesC8& aUrl );
       
   188         
       
   189         /**
       
   190         *
       
   191         * @since 3.1
       
   192         * @param
       
   193         * @return
       
   194         */
       
   195         void ReHashL();
       
   196         
       
   197         /**
       
   198         *
       
   199         * @since 3.1
       
   200         * @param
       
   201         * @return
       
   202         */
       
   203         TUint NextPrime( TUint aNum );
       
   204         
       
   205         /**
       
   206         *
       
   207         * @since 3.1
       
   208         * @param
       
   209         * @return
       
   210         */
       
   211         void Erase( TInt aPos );
       
   212         
       
   213         /**
       
   214         *
       
   215         * @since 3.1
       
   216         * @param
       
   217         * @return
       
   218         */
       
   219         TBool Valid( TInt aPos );
       
   220         
       
   221         /**
       
   222         *
       
   223         * @since 3.1
       
   224         * @param
       
   225         * @return
       
   226         */
       
   227         TBool Empty( TInt aPos );
       
   228         
       
   229         /**
       
   230         *
       
   231         * @since 3.1
       
   232         * @param
       
   233         * @return
       
   234         */
       
   235         TBool Deleted( TInt aPos );
       
   236         
       
   237         /**
       
   238         *
       
   239         * @since 3.1
       
   240         * @param
       
   241         * @return
       
   242         */
       
   243         void SetDeleted( TInt aPos );
       
   244         
       
   245         /**
       
   246         *
       
   247         * @since 3.1
       
   248         * @param
       
   249         * @return
       
   250         */
       
   251         TBool BoundaryCheck( TInt aPos );
       
   252         
       
   253     private:    // Data
       
   254         
       
   255         // hash table for cache entries
       
   256         CArrayPtrFlat<CHttpCacheEntry>* iEntries;
       
   257         // number of entries in the hashtable
       
   258         TInt                            iCount;
       
   259         //
       
   260         CHttpCacheEvictionHandler*      iEvictionHandler;         // not owned
       
   261         //
       
   262         CHttpCacheStreamHandler*        iStreamHandler;           // not owned
       
   263     };
       
   264     
       
   265 #endif      // CHTTPCACHELOOKUPTABLE_H
       
   266     
       
   267     // End of File