webengine/osswebengine/cache/inc/HttpCacheStreamHandler.h
changeset 1 7c90e6132015
parent 0 dd21522fd290
child 10 a359256acfc6
equal deleted inserted replaced
0:dd21522fd290 1:7c90e6132015
    41 /**
    41 /**
    42 *
    42 *
    43 *  @lib
    43 *  @lib
    44 *  @since 3.1
    44 *  @since 3.1
    45 */
    45 */
    46 class CHttpCacheStreamEntry : public CBase
       
    47     {
       
    48     public:  // Constructors and destructor
       
    49 
       
    50         /**
       
    51         * Two-phased constructor.
       
    52         * @since 3.1
       
    53         * @param
       
    54         * @param
       
    55         * @return CHttpCacheStreamEntry object.
       
    56         */
       
    57         static CHttpCacheStreamEntry* NewL( RFs& aRfs, CHttpCacheEntry& aHttpCacheEntry, TDriveUnit aDrive,
       
    58             TInt64 aCriticalLevel );
       
    59 
       
    60         /**
       
    61         * Destructor.
       
    62         */
       
    63         virtual ~CHttpCacheStreamEntry();
       
    64 
       
    65     public: // new functions
       
    66 
       
    67         /**
       
    68         *
       
    69         * @since 3.1
       
    70         * @param
       
    71         * @return
       
    72         */
       
    73         inline CHttpCacheEntry* CacheEntry() const { return iHttpCacheEntry; }
       
    74 
       
    75         /**
       
    76         *
       
    77         * @since 3.1
       
    78         * @param
       
    79         * @return
       
    80         */
       
    81         void Erase();
       
    82 
       
    83         /**
       
    84         *
       
    85         * @since 3.1
       
    86         * @param
       
    87         * @return
       
    88         */
       
    89         HBufC8* HeadersL();
       
    90 
       
    91         /**
       
    92         *
       
    93         * @since 3.1
       
    94         * @param
       
    95         * @return
       
    96         */
       
    97         HBufC8* NextChunkL( TBool& aLastChunk );
       
    98 
       
    99         /**
       
   100         *
       
   101         * @since 3.1
       
   102         * @param
       
   103         * @return
       
   104         */
       
   105         TInt SaveHeaders( const TDesC8& aHeaderStr );
       
   106 
       
   107         /**
       
   108         *
       
   109         * @since 3.1
       
   110         * @param
       
   111         * @return
       
   112         */
       
   113         void RemoveHeaders();
       
   114 
       
   115         /**
       
   116         *
       
   117         * @since 3.1
       
   118         * @param
       
   119         * @return
       
   120         */
       
   121         TInt SaveBodyData( const TDesC8& aBodyStr );
       
   122 
       
   123         /**
       
   124         *
       
   125         * @since 3.1
       
   126         * @param
       
   127         * @return
       
   128         */
       
   129         void RemoveBodyData();
       
   130 
       
   131         /**
       
   132         * Flush
       
   133         * @since 3.1
       
   134         * @param
       
   135         * @return
       
   136         */
       
   137         TInt Flush();
       
   138 
       
   139     private:
       
   140 
       
   141         /**
       
   142         * Construct.
       
   143         * @since 3.1
       
   144         * @param
       
   145         * @param
       
   146         * @return CHttpCacheStreamEntry object.
       
   147         */
       
   148         CHttpCacheStreamEntry( RFs& aRfs, CHttpCacheEntry& aHttpCacheEntry, TDriveUnit aDrive,
       
   149             TInt64 aCriticalLevel );
       
   150 
       
   151         /**
       
   152         * By default Symbian 2nd phase constructor is private.
       
   153         */
       
   154         void ConstructL();
       
   155 
       
   156     private: //
       
   157 
       
   158         /**
       
   159         *
       
   160         * @since 3.1
       
   161         * @param
       
   162         * @return
       
   163         */
       
   164         void GetHeaderFileName( const TFileName& aBodyFileName, TFileName& aHeaderFileName );
       
   165 
       
   166         /**
       
   167         *
       
   168         * @since 3.1
       
   169         * @param
       
   170         * @return
       
   171         */
       
   172         TBool OpenCacheFiles();
       
   173 
       
   174         /**
       
   175         *
       
   176         * @since 3.1
       
   177         * @param
       
   178         * @return
       
   179         */
       
   180         TBool CreateNewFilesL();
       
   181 
       
   182         /**
       
   183         *
       
   184         * @since 3.1
       
   185         * @param
       
   186         * @return
       
   187         */
       
   188         void BodyFileName( TFileName& aBodyFileName );
       
   189 
       
   190         /**
       
   191         *
       
   192         * @since 3.1
       
   193         * @param
       
   194         * @return
       
   195         */
       
   196         TBool DiskSpaceBelowCriticalLevel( TInt aContentSize );
       
   197 
       
   198     private:    // Data
       
   199 
       
   200         //
       
   201         TBool               iFileOk;
       
   202         //
       
   203         RFs                 iRfs;       // not owned
       
   204         //
       
   205         RFile               iHeaderFile;      // owned
       
   206         //
       
   207         RFile               iBodyFile;      // owned
       
   208         //
       
   209         CHttpCacheEntry*    iHttpCacheEntry; // not owned
       
   210         //
       
   211         TDriveUnit          iDrive;
       
   212         //
       
   213         TInt64              iCriticalLevel;
       
   214         //
       
   215         HBufC8*             iCacheBuffer;   // owned
       
   216     };
       
   217 
       
   218 /**
       
   219 *
       
   220 *  @lib
       
   221 *  @since 3.1
       
   222 */
       
   223 class CHttpCacheStreamHandler : public CBase
    46 class CHttpCacheStreamHandler : public CBase
   224     {
    47     {
   225     public:  // Constructors and destructor
    48     public:  // Constructors and destructor
   226 
    49 
   227         /**
    50         /**
   252         *
    75         *
   253         * @since 3.1
    76         * @since 3.1
   254         * @param
    77         * @param
   255         * @return
    78         * @return
   256         */
    79         */
       
    80         inline void SetSavedContentSize( TInt aContentSize ) { iContentSize = aContentSize; }
       
    81 
       
    82         /**
       
    83         *
       
    84         * @since 3.1
       
    85         * @param
       
    86         * @return
       
    87         */
   257         TBool AttachL( CHttpCacheEntry& aCacheEntry );
    88         TBool AttachL( CHttpCacheEntry& aCacheEntry );
   258 
    89 
   259         /**
    90         /**
   260         *
    91         *
   261         * @since 3.1
    92         * @since 3.1
   262         * @param
    93         * @param
   263         * @return
    94         * @return
   264         */
    95         */
   265         void Detach( const CHttpCacheEntry& aCacheEntry );
    96         void Detach( CHttpCacheEntry& aCacheEntry );
   266 
    97 
   267         /**
    98         /**
   268         *
    99         *
   269         * @since 3.1
   100         * @since 3.1
   270         * @param
   101         * @param
   271         * @return
   102         * @return
   272         */
   103         */
   273         void Erase( const CHttpCacheEntry& aCacheEntry );
   104         void EraseCacheFile( CHttpCacheEntry& aCacheEntry );
   274 
   105 
   275         /**
   106         /**
   276         *
   107         *
   277         * @since 3.1
   108         * @since 3.1
   278         * @param
   109         * @param
   332         *
   163         *
   333         * @since 3.1
   164         * @since 3.1
   334         * @param
   165         * @param
   335         * @return
   166         * @return
   336         */
   167         */
   337         inline void SetStartupCacheSize( TInt aContentSize ) { iContentSize = aContentSize; }
   168         TBool OpenCacheFiles( CHttpCacheEntry& aCacheEntry );
   338 
   169 
   339 #ifdef _DEBUG
   170         /**
   340         /**
   171         *
   341         *
   172         * @since 3.1
   342         * @since 3.1
   173         * @param
   343         * @param
   174         * @return
   344         * @return
   175         */
   345         */
   176         TBool CreateNewFilesL( CHttpCacheEntry& aCacheEntry );
   346         inline TBool Find( const CHttpCacheEntry& aCacheEntry ) { return ( FindStreamEntry( aCacheEntry ) != NULL );  }
   177 
   347 #endif // _DEBUG
       
   348     private:
   178     private:
   349 
   179 
   350         /**
   180         /**
   351         * Construct.
   181         * Construct.
   352         * @since 3.1
   182         * @since 3.1
   367         *
   197         *
   368         * @since 3.1
   198         * @since 3.1
   369         * @param
   199         * @param
   370         * @return
   200         * @return
   371         */
   201         */
   372         CHttpCacheStreamEntry* FindStreamEntry( const CHttpCacheEntry& aCacheEntry, TInt* aIndex = NULL );
   202         TBool IsDiskSpaceAvailable( TInt aContentSize );
   373 
   203         
   374 
   204         /**
       
   205         *
       
   206         * @since 7.1
       
   207         * @param
       
   208         * @return
       
   209         */
       
   210         void FindCacheEntryIndex( const CHttpCacheEntry& aCacheEntry, TInt* aIndex );
   375 
   211 
   376     private:    // Data
   212     private:    // Data
   377 
   213 
   378         //
   214         //
   379         RFs                                         iRfs;               // owned
   215         RFs                                 iRfs;               // owned
   380         // attached entries
   216         // attached entries
   381         CArrayPtrFlat<CHttpCacheStreamEntry>*       iActiveEntries;     // owned
   217         CArrayPtrFlat<CHttpCacheEntry>*     iActiveEntries;     // owned
   382         //
   218         //
   383         TInt                                        iContentSize;
   219         TInt                                iContentSize;
   384         //
   220         //
   385         TDriveUnit          iDrive;
   221         TDriveUnit                          iDrive;
   386         //
   222         //
   387         TInt64              iCriticalLevel;
   223         TInt64                              iCriticalLevel;
   388         //
       
   389         TInt                iDiskFull;
       
   390     };
   224     };
   391 
   225 
   392 #endif      // CHTTPCACHESTREAMHANDLER_H
   226 #endif      // CHTTPCACHESTREAMHANDLER_H
   393 
   227 
   394 // End of File
   228 // End of File