browserutilities/downloadmgr/DownloadMgrServEng/Inc/BuffStorage.h
changeset 0 dd21522fd290
child 92 e1bea15f9a39
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:  Implements storage functionality in the DownloadManager
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef BUFFSTORAGE_H
       
    21 #define BUFFSTORAGE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CHttpDownload;
       
    29 class CHttpStorage;
       
    30 class RFotaEngineSession;
       
    31 class RWriteStream;
       
    32 class CDocumentHandler;
       
    33 class CBuffStorage;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 *  ?one_line_short_description.
       
    39 *  ?other_description_lines
       
    40 *
       
    41 *  @lib ?library
       
    42 *  @since Series 60 v2.8
       
    43 */
       
    44 
       
    45 
       
    46 NONSHARABLE_CLASS( CBuffStorage ) : public CActive
       
    47     {
       
    48     public:  // Constructors and destructor
       
    49     
       
    50             
       
    51     /**
       
    52      * Two-phased constructor.
       
    53      */
       
    54     static CBuffStorage* NewL( CHttpStorage* aStorage );
       
    55     
       
    56    /**
       
    57     * Destructor.
       
    58     */
       
    59     ~CBuffStorage();
       
    60     
       
    61     public: // Interface
       
    62     
       
    63     /**
       
    64     * Delets the storage buffers.
       
    65     * @param 
       
    66     * @return
       
    67     */
       
    68     void ResetBuffers();
       
    69     
       
    70 	/**
       
    71     * Persist received chunk
       
    72     * @since Series 60 v2.8
       
    73     * @param aBuf new chunk to be added
       
    74     * @return EFalse if content-length had to be updated.
       
    75     */
       
    76     TBool WriteOutNextBodyDataL( const TDesC8& aBuf );
       
    77     
       
    78     /**
       
    79     * If buffering enabled, flush data to disk
       
    80     */
       
    81     void FlushBuffersL();
       
    82     
       
    83     /**
       
    84     * Returns buffer size
       
    85     * @since Series 60 v2.8
       
    86     * @param 
       
    87     * @return  Buffer size.
       
    88     */
       
    89     const TInt& CurrentBufferSize() { return iBufferSize; }
       
    90     
       
    91     /**
       
    92     * Clear the error encountered during writing to file
       
    93     * @since Series 60 v2.8
       
    94     * @param 
       
    95     * @return  Buffer size.
       
    96     */
       
    97     void ClearErrors() { iLastWriteErrorCode = KErrNone; }
       
    98         
       
    99 
       
   100     protected:  // Functions from base classes
       
   101 
       
   102     
       
   103     private: // From CActive
       
   104 
       
   105     /**
       
   106     * Cancels the timer.
       
   107     * @param 
       
   108     * @return
       
   109     */
       
   110     void DoCancel();
       
   111     
       
   112     /**
       
   113     * Handles an active object’s request completion event.
       
   114     * @param 
       
   115     * @return
       
   116     */
       
   117     void RunL();
       
   118     
       
   119     /**
       
   120     * Persist received chunk
       
   121     * @since Series 60 v2.8
       
   122     * @param aBuf new chunk to be added
       
   123     * @return EFalse if content-length had to be updated.
       
   124     */
       
   125     void DoBufferingWriteL(const TDesC8& aBuf);
       
   126     void DoNonbufferingWriteL(const TDesC8& aBuf);
       
   127     
       
   128     private:              
       
   129     /**
       
   130      * C++ default constructor.
       
   131      */
       
   132     CBuffStorage(CHttpStorage*);
       
   133     
       
   134     /**
       
   135      * By default Symbian 2nd phase constructor is private.
       
   136      */
       
   137     void ConstructL();
       
   138 	
       
   139 	public:     // Data
       
   140 	
       
   141 	friend class CBuffStorage;
       
   142     
       
   143     
       
   144     protected:  // Data
       
   145 
       
   146 
       
   147     private:
       
   148     
       
   149     // Double-buffering
       
   150     HBufC8* iBuff1, *iBuff2;
       
   151     HBufC8* iClientBuffer;
       
   152     TPtr8 *iWritePtr;
       
   153     TInt iBufferSize;
       
   154     
       
   155     // For stalling condition handling
       
   156     TInt iLastWriteErrorCode;
       
   157     CActiveSchedulerWait iWait;
       
   158     
       
   159     // References to CHttpStorage data
       
   160     RFile*& iFile;
       
   161     TInt32& iDownloadedSize; // How much data actually written to finally
       
   162     TInt32& iBufferedSize;   // How much data received over the air (but not necessarily all in file yet)
       
   163     
       
   164     TInt& iHttpStorageBufferSize;
       
   165     TInt32& iHttpStorageLength;
       
   166     TBool& iBufferingEnabled;
       
   167     TBool& iProgressiveDownload;
       
   168     
       
   169 #ifdef __SYNCML_DM_FOTA
       
   170     RWriteStream*& iFotaStream;
       
   171 #endif // __SYNCML_DM_FOTA
       
   172 
       
   173     };
       
   174     
       
   175 
       
   176 
       
   177     
       
   178 #endif      // BUFFSTORAGE_H   
       
   179             
       
   180 // End of File