webengine/osswebengine/cache/inc/HttpCacheUtil.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 CHttpCacheUtil
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CHTTPCACHEUTIL_H
       
    19 #define CHTTPCACHEUTIL_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 #include <http/rhttpheaders.h>
       
    25 
       
    26 // CONSTANTS
       
    27 enum TCacheLoadMethod
       
    28     {
       
    29     EMethodGet,
       
    30     EMethodConnect,
       
    31     EMethodDelete,
       
    32     EMethodHead,
       
    33     EMethodOptions,
       
    34     EMethodPut,
       
    35     EMethodPost,
       
    36     EMethodTrace,
       
    37     };
       
    38 
       
    39 const TInt KCacheVersionNumber = 1;
       
    40 //make 16 subdirectories named 0 through F for organizing cached files
       
    41 const TUint32 KCacheSubdirCount = 16;
       
    42 _LIT( KHttpCacheHeaderExt, ".h" );
       
    43 
       
    44 //#define __CACHELOG__
       
    45 
       
    46 // MACROS
       
    47 
       
    48 // DATA TYPES
       
    49 
       
    50 // FUNCTION PROTOTYPES
       
    51 
       
    52 // FORWARD DECLARATIONS
       
    53 class RHTTPHeaders;
       
    54 class RHTTPTransaction;
       
    55 class MHTTPDataSupplier;
       
    56 class RStringPool;
       
    57 class CHttpCacheEntry;
       
    58 
       
    59 // CLASS DECLARATION
       
    60 
       
    61 /**
       
    62 *
       
    63 *  @lib
       
    64 *  @since 3.1
       
    65 */
       
    66 class HttpCacheUtil
       
    67     {
       
    68     public:
       
    69 
       
    70         /**
       
    71         *
       
    72         * @since 3.1
       
    73         * @param
       
    74         * @return
       
    75         */
       
    76         static void SetEntryOnTransL( CHttpCacheEntry& aEntry, RHTTPTransaction& aTrans, RStringF& aCacheEntryStr );
       
    77 
       
    78         /**
       
    79         *
       
    80         * @since 3.1
       
    81         * @param
       
    82         * @return
       
    83         */
       
    84         static CHttpCacheEntry* EntryOnTransL( RHTTPTransaction& aTrans, RStringF& aCacheEntryStr );
       
    85 
       
    86         /**
       
    87         *
       
    88         * @since 3.1
       
    89         * @param
       
    90         * @return
       
    91         */
       
    92         static HBufC8* HeadersToBufferLC( RHTTPHeaders& aHttpHeaders, RStringPool& aStrP );
       
    93 
       
    94         /**
       
    95         *
       
    96         * @since 3.1
       
    97         * @param
       
    98         * @return
       
    99         */
       
   100         static void BufferToHeadersL( const TDesC8& aHeaderStr, RHTTPHeaders& aHttpHeaders, RStringPool& aStrP );
       
   101 
       
   102         /**
       
   103         *
       
   104         * @since 3.1
       
   105         * @param
       
   106         * @return
       
   107         */
       
   108         static HBufC8* BodyToBufferL( MHTTPDataSupplier& aBodySupplier );
       
   109 
       
   110         /**
       
   111         *
       
   112         * @since 3.1
       
   113         * @param
       
   114         * @return
       
   115         */
       
   116         static HBufC8* MergeHeadersLC( const TDesC8& aCachedHeaderStr, RHTTPHeaders& aResponseHeaders, RStringPool& aStrP );
       
   117 
       
   118         /**
       
   119         *
       
   120         * @since 3.1
       
   121         * @param
       
   122         * @return
       
   123         */
       
   124         static HBufC8* AddHeaderLC( const TDesC8& aName, const TDesC8& aValue, const TDesC8& aHeaders );
       
   125 
       
   126         /**
       
   127         *
       
   128         * @since 3.1
       
   129         * @param
       
   130         * @return
       
   131         */
       
   132         static HBufC8* HeaderFieldFromBufferLC( const TDesC8& aHeaders, const TDesC8& aKey );
       
   133 
       
   134         /**
       
   135         *
       
   136         * @since 3.1
       
   137         * @param
       
   138         * @return
       
   139         */
       
   140         static TCacheLoadMethod MethodFromStr( RStringF aMethodStr, RStringPool aStrP );
       
   141 
       
   142         /**
       
   143         *
       
   144         * @since 3.1
       
   145         * @param
       
   146         * @return
       
   147         */
       
   148         static TBool ProtectedEntry( RHTTPHeaders& aHttpHeaders, RStringPool& aStrP );
       
   149 
       
   150         /**
       
   151         *
       
   152         * @since 3.1
       
   153         * @param
       
   154         * @return
       
   155         */
       
   156         static TBool CacheTimeIsFresh( const RHTTPHeaders& aRequestHeaders, const RHTTPHeaders& aCachedHeaders,
       
   157             RStringPool aStrP );
       
   158 
       
   159         /**
       
   160         *
       
   161         * @since 3.1
       
   162         * @param
       
   163         * @return
       
   164         */
       
   165         static void AddValidationHeaders( const RHTTPHeaders aCachedHeaders, RHTTPHeaders& aRequestHeaders, RStringPool& aStrP );
       
   166 
       
   167         /**
       
   168         *
       
   169         * @since 3.1
       
   170         * @param
       
   171         * @return
       
   172         */
       
   173         static TBool OperatorCacheContent( const TDesC8& aOpDomain, const TDesC8& aUrl );
       
   174 
       
   175         /**
       
   176         *
       
   177         * @since 3.1
       
   178         * @param
       
   179         * @return
       
   180         */
       
   181         static TBool VSSCacheContent( const TDesC8& aUrl, const HBufC8* aWhiteList );
       
   182 
       
   183         /**
       
   184         *
       
   185         * @since 3.1
       
   186         * @param
       
   187         * @return
       
   188         */
       
   189         static TBool PragmaNoCache( RHTTPTransaction& aTrans );
       
   190 
       
   191         /**
       
   192         *
       
   193         * @since 3.1
       
   194         * @param
       
   195         * @return
       
   196         */
       
   197         static void GetHeaderFileName( const TDesC& aBodyFileName, TDes& aHeaderFileName );
       
   198         
       
   199         /**
       
   200         *
       
   201         * @since 3.1
       
   202         * @param
       
   203         * @return
       
   204         */
       
   205         static void AdjustExpirationTimeL( RHTTPHeaders& aResponseHeaders, RStringPool& aStrP );
       
   206 
       
   207         /**
       
   208         *
       
   209         * @since 3.1
       
   210         * @param
       
   211         * @param
       
   212         * @return
       
   213         */
       
   214         static TBool CacheNeedsUpdateL( RHTTPHeaders& aResponseHeader, const TDesC8& aCachedHeaderStr, RStringPool& aStrP );
       
   215 
       
   216         /**
       
   217         *
       
   218         * @since 3.1
       
   219         * @param
       
   220         * @return
       
   221         */
       
   222         static TBool IsCacheable( RHTTPTransaction& aTrans, TUint aMaxSize, TBool& aProtectedEntry );
       
   223 
       
   224         /**
       
   225         *
       
   226         * @since 3.1
       
   227         * @param
       
   228         * @return
       
   229         */
       
   230         static TInt GetCacheControls( const RHTTPHeaders& aHeaders, TInt64* aMaxAge, TInt64* aMinFresh, TInt64* aMaxStale, TBool* aMustRevalidate,
       
   231             TBool* aNoCache, TBool* aNoStore, RStringPool aStrP );
       
   232 
       
   233     /**
       
   234         *
       
   235         * @since 3.1
       
   236         * @param
       
   237         * @return
       
   238         */
       
   239         static HBufC* GenerateNameLC(const TDesC8& aUrl, const TDesC& aBaseDir );
       
   240 
       
   241         /**
       
   242         *
       
   243         * @since 3.1
       
   244         * @param
       
   245         * @return
       
   246         */
       
   247         static void WriteLog( TInt aLogLevel, TPtrC aBuf, TInt aAny = 0xffff );
       
   248 
       
   249         /**
       
   250         *
       
   251         * @since 3.1
       
   252         * @param
       
   253         * @return
       
   254         */
       
   255         static void WriteUrlToLog( TInt aLogLevel, const TDesC8& aUrl, TInt aAny = 0xffff );
       
   256 
       
   257         /**
       
   258         *
       
   259         * @since 3.1
       
   260         * @param
       
   261         * @return
       
   262         */
       
   263         static void WriteUrlToLog( TInt aLogLevel, const TDesC& aTxt, const TDesC8& aUrl, TInt aAny = 0xffff );
       
   264 
       
   265     private:
       
   266 
       
   267         /**
       
   268         *
       
   269         * @since 3.1
       
   270         * @param
       
   271         * @return
       
   272         */
       
   273         static TInt64 Freshness( const RHTTPHeaders& aHeaders, TTime aResponseTime, RStringPool aStrP );
       
   274 
       
   275         /**
       
   276         *
       
   277         * @since 3.1
       
   278         * @param
       
   279         * @return
       
   280         */
       
   281         static TInt64 Age( const RHTTPHeaders& aHeaders, TTime aRequestTime, TTime aResponseTime, RStringPool aStrP );
       
   282 
       
   283         /**
       
   284         *
       
   285         * @since 3.1
       
   286         * @param
       
   287         * @return
       
   288         */
       
   289         static TInt GetCacheControlDirective( const RHTTPHeaders& aHeaders, TInt aIndex, RStringF& aDirective, TInt64* aDirectiveValue,
       
   290             char** aExtraValue, RStringPool aStrP );
       
   291 
       
   292         /**
       
   293         *
       
   294         * @since 3.1
       
   295         * @param
       
   296         * @return
       
   297         */
       
   298         static TInt ExtractCacheControlDirectiveValue( RStringPool aStrP, RStringF& aDirective,  TDesC8& aValue, TInt64* aDirectiveValue,
       
   299             char** aExtraValue );
       
   300     };
       
   301 
       
   302 #endif      // CHTTPCACHEUTIL_H
       
   303 
       
   304 // End of File