webengine/osswebengine/cache/inc/HttpCacheUtil.h
changeset 11 c8a366e56285
parent 10 a359256acfc6
child 46 30342f40acbf
equal deleted inserted replaced
10:a359256acfc6 11:c8a366e56285
    18 #ifndef CHTTPCACHEUTIL_H
    18 #ifndef CHTTPCACHEUTIL_H
    19 #define CHTTPCACHEUTIL_H
    19 #define CHTTPCACHEUTIL_H
    20 
    20 
    21 //  INCLUDES
    21 //  INCLUDES
    22 #include <e32base.h>
    22 #include <e32base.h>
       
    23 #include <e32hashtab.h>
    23 #include <f32file.h>
    24 #include <f32file.h>
    24 #include <http/rhttpheaders.h>
    25 #include <http/rhttpheaders.h>
    25 
    26 
    26 // CONSTANTS
    27 // CONSTANTS
    27 enum TCacheLoadMethod
    28 enum TCacheLoadMethod
    52 const TUint32 KSubdirNameLength = 2;
    53 const TUint32 KSubdirNameLength = 2;
    53 // The filename is calculated in HttpCacheUtil::GenerateNameLC()
    54 // The filename is calculated in HttpCacheUtil::GenerateNameLC()
    54 const TUint32 KFilenameLength = 8;
    55 const TUint32 KFilenameLength = 8;
    55 _LIT( KHttpCacheHeaderExt, ".h" );
    56 _LIT( KHttpCacheHeaderExt, ".h" );
    56 
    57 
    57 #ifdef _DEBUG
    58 const TInt KCacheFileNeedsDelete( 1 );    
       
    59 const TInt KCacheFileNoDelete( 0 );
       
    60 
       
    61 
       
    62 #ifdef HTTP_CACHE_LOGGING
    58 #define __CACHELOG__
    63 #define __CACHELOG__
    59 #endif
    64 #endif
    60 
    65 
    61 // MACROS
    66 // MACROS
    62 
    67 
    68 class RHTTPHeaders;
    73 class RHTTPHeaders;
    69 class RHTTPTransaction;
    74 class RHTTPTransaction;
    70 class MHTTPDataSupplier;
    75 class MHTTPDataSupplier;
    71 class RStringPool;
    76 class RStringPool;
    72 class CHttpCacheEntry;
    77 class CHttpCacheEntry;
    73 
    78 class CHttpCacheFileHash;
       
    79 class TFileInfo;
       
    80 
       
    81 typedef TPtrHashMapIter<TDesC, TFileInfo> THttpCacheFileHashIter;
       
    82 typedef RPtrHashMap<TDesC, TFileInfo> RHttpCacheFileHashMap;
    74 // CLASS DECLARATION
    83 // CLASS DECLARATION
    75 
    84 
    76 /**
    85 /**
    77 *
    86 *
    78 *  @lib
    87 *  @lib
   295         * @param
   304         * @param
   296         * @return
   305         * @return
   297         */
   306         */
   298         static void WriteUrlToLog( TInt aLogLevel, const TDesC& aTxt, const TDesC8& aUrl, TInt aAny = 0xffff );
   307         static void WriteUrlToLog( TInt aLogLevel, const TDesC& aTxt, const TDesC8& aUrl, TInt aAny = 0xffff );
   299 
   308 
       
   309         /**
       
   310          * @since 7.1
       
   311          * 
       
   312          * example:
       
   313          * CCacheFileHash *hash;
       
   314          * GenerateCacheContentHashMapL(hash, rfs, _L("Cachelocation"), <a TInt you can use for whatever you like>);
       
   315          * When you return, you should push onto the cleanup stack as usual.
       
   316          * When you're finished with the hash just do:
       
   317          * CleanupStack::PopAndDestroy(); to clean up both hash and string array.
       
   318          */
       
   319         static void GenerateCacheContentHashMapL(CHttpCacheFileHash*& aHashMap, RFs& aRfs, const TDesC& aCacheFolder, const TInt aInitialValue);
       
   320 
       
   321         /**
       
   322          * @since 7.1
       
   323          * 
       
   324          * Ensure trailing slash on paths
       
   325          */
       
   326         static void EnsureTrailingSlash( TDes& aPath );
       
   327         
   300     private:
   328     private:
   301 
   329 
   302         /**
   330         /**
   303         *
   331         *
   304         * @since 3.1
   332         * @since 3.1
   332         */
   360         */
   333         static TInt ExtractCacheControlDirectiveValue( RStringPool aStrP, RStringF& aDirective,  TDesC8& aValue, TInt64* aDirectiveValue,
   361         static TInt ExtractCacheControlDirectiveValue( RStringPool aStrP, RStringF& aDirective,  TDesC8& aValue, TInt64* aDirectiveValue,
   334             char** aExtraValue );
   362             char** aExtraValue );
   335     };
   363     };
   336 
   364 
       
   365 NONSHARABLE_CLASS( TFileInfo )
       
   366     {
       
   367     public:
       
   368         TInt iUserInt;
       
   369         TUint32 iFileSize;
       
   370     };
       
   371 
       
   372 NONSHARABLE_CLASS( CHttpCacheFileHash ) : public CBase
       
   373     {
       
   374     friend class HttpCacheUtil;
       
   375     protected:
       
   376         static CHttpCacheFileHash* NewLC(const TInt aInitialValue);
       
   377         void InsertAndStoreL(const TEntry& aEntry, const TDesC& aDir);
       
   378         
       
   379     private:
       
   380         void ConstructL();
       
   381         CHttpCacheFileHash(const TInt aInitialValue, const THashFunction32<TDesC>& aHash, const TIdentityRelation<TDesC>& aIdentity);
       
   382         
       
   383     public:
       
   384         ~CHttpCacheFileHash();
       
   385         RHttpCacheFileHashMap& HashMap() { return iHashMap; };
       
   386         
       
   387     private:
       
   388         RHttpCacheFileHashMap   iHashMap;
       
   389         RPointerArray<HBufC> iStringStorage;
       
   390         CArrayFixSeg<TFileInfo>* iFileInfoStorage;
       
   391         const TInt iInitialValue;
       
   392     };
       
   393 
       
   394 
       
   395 
   337 #endif      // CHTTPCACHEUTIL_H
   396 #endif      // CHTTPCACHEUTIL_H
   338 
   397 
   339 // End of File
   398 // End of File