webengine/osswebengine/cache/inc/HttpCacheEvictionHandler.h
changeset 0 dd21522fd290
child 8 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 CHttpCacheEvictionHandler  
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CHTTPCACHEEVICTIONHANDLER_H
       
    19 #define CHTTPCACHEEVICTIONHANDLER_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include "HttpCacheUtil.h"
       
    24 
       
    25 // CONSTANTS
       
    26 
       
    27 // MACROS
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CHttpCacheEntry;
       
    31 
       
    32 // DATA TYPES
       
    33 typedef  TSglQue<CHttpCacheEntry> TBucket;
       
    34 typedef  TSglQueIter<CHttpCacheEntry> TBucketIter;
       
    35 
       
    36 // FUNCTION PROTOTYPES
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 *  
       
    42 *  @lib 
       
    43 *  @since 3.1
       
    44 */
       
    45 class CHttpCacheEvictionHandler : public CBase
       
    46     {
       
    47     public:  // Constructors and destructor        
       
    48 
       
    49         /**
       
    50         * Two-phased constructor.
       
    51         * @since 3.1
       
    52         * @param 
       
    53         * @param 
       
    54         * @return CHttpCacheEvictionHandler object.
       
    55         */
       
    56         static CHttpCacheEvictionHandler* NewL();
       
    57       
       
    58         /**
       
    59         * Destructor.
       
    60         */
       
    61         virtual ~CHttpCacheEvictionHandler();
       
    62         
       
    63     public: // new functions
       
    64         
       
    65         /**
       
    66         * 
       
    67         * @since 3.1
       
    68         * @param 
       
    69         * @return 
       
    70         */
       
    71         void Insert( CHttpCacheEntry& aCacheEntry ); 
       
    72 
       
    73         /**
       
    74         * 
       
    75         * @since 3.1
       
    76         * @param 
       
    77         * @return 
       
    78         */
       
    79         void Accessed( CHttpCacheEntry& aCacheEntry ); 
       
    80 
       
    81         /**
       
    82         * 
       
    83         * @since 3.1
       
    84         * @param 
       
    85         * @return 
       
    86         */
       
    87         void Changed( CHttpCacheEntry& aCacheEntry ); 
       
    88 
       
    89         /**
       
    90         * 
       
    91         * @since 3.1
       
    92         * @param 
       
    93         * @return 
       
    94         */
       
    95         void Remove( CHttpCacheEntry& aCacheEntry ); 
       
    96 
       
    97         /**
       
    98         * 
       
    99         * @since 3.1
       
   100         * @param 
       
   101         * @return 
       
   102         */
       
   103         void RemoveAll();
       
   104 
       
   105         /**
       
   106         * 
       
   107         * @since 3.1
       
   108         * @param 
       
   109         * @return 
       
   110         */
       
   111         CArrayPtrFlat<CHttpCacheEntry>* EvictL( TInt aSpaceNeeded );
       
   112 
       
   113     private:
       
   114         
       
   115         /**
       
   116         * Construct.
       
   117         * @since 3.1
       
   118         * @param 
       
   119         * @param 
       
   120         * @return CHttpCacheEvictionHandler object.
       
   121         */
       
   122         CHttpCacheEvictionHandler();
       
   123 
       
   124         /**
       
   125         * By default Symbian 2nd phase constructor is private.
       
   126         */
       
   127         void ConstructL();    
       
   128 
       
   129     private:
       
   130 
       
   131         /**
       
   132         * 
       
   133         * @since 3.1
       
   134         * @param 
       
   135         * @return 
       
   136         */
       
   137         TBucket* Bucket( TInt aBucketIndex );
       
   138 
       
   139         /**
       
   140         * 
       
   141         * @since 3.1
       
   142         * @param 
       
   143         * @return 
       
   144         */
       
   145         TInt BucketIndex( TInt aSizeFrequencyValue );
       
   146 
       
   147         /**
       
   148         * 
       
   149         * @since 3.1
       
   150         * @param 
       
   151         * @return 
       
   152         */
       
   153         TBool ItemIsInBucket( TInt aBucketIndex, const CHttpCacheEntry& aCacheEntry );
       
   154 
       
   155         /**
       
   156         * 
       
   157         * @since 3.1
       
   158         * @param 
       
   159         * @return 
       
   160         */
       
   161         TInt FastLog2( TUint aNum );
       
   162 
       
   163 #ifdef __CACHELOG__
       
   164         void LogBuckets();
       
   165 #endif // __CACHELOG__
       
   166 
       
   167     private:    // Data
       
   168 
       
   169         // array of 5 buckets each bucket is a linked list of 
       
   170         // cached items
       
   171         CArrayPtrFlat<TBucket>*            iBuckets;          // owned
       
   172     };
       
   173 
       
   174 #endif      // CHTTPCACHEEVICTIONHANDLER_H
       
   175             
       
   176 // End of File