browserutilities/downloadmgr/DownloadMgrServEng/Src/BuffStorage.cpp
branchRCL_3
changeset 48 79859ed3eea9
parent 47 e1bea15f9a39
child 49 919f36ff910f
equal deleted inserted replaced
47:e1bea15f9a39 48:79859ed3eea9
    26 
    26 
    27 #include "HttpDownloadManagerServerEngine.h"
    27 #include "HttpDownloadManagerServerEngine.h"
    28 #include "HttpDownloadMgrLogger.h"
    28 #include "HttpDownloadMgrLogger.h"
    29 #include "HeaderField.h"
    29 #include "HeaderField.h"
    30 
    30 
    31 #include <SysUtil.h>
    31 #include <sysutil.h>
    32 #include <DocumentHandler.h>
    32 #include <DocumentHandler.h>
    33 #include <APMSTD.H>
    33 #include <apmstd.h>
    34 
    34 
    35 #include "HttpDownloadMgrLogger.h"
    35 #include "HttpDownloadMgrLogger.h"
    36 
    36 
    37 #ifdef __SYNCML_DM_FOTA
    37 #ifdef __SYNCML_DM_FOTA
    38 #include <fotaengine.h>
    38 #include <fotaengine.h>
    77 //
    77 //
    78 void CBuffStorage::ConstructL()
    78 void CBuffStorage::ConstructL()
    79     {
    79     {
    80     LOGGER_ENTERFN( "ConstructL" );
    80     LOGGER_ENTERFN( "ConstructL" );
    81     CActiveScheduler::Add( this );
    81     CActiveScheduler::Add( this );
    82     iWait = new (ELeave) CActiveSchedulerWait;
       
    83     }
    82     }
    84 
    83 
    85 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    86 // CBuffStorage::NewL
    85 // CBuffStorage::NewL
    87 // Two-phased constructor.
    86 // Two-phased constructor.
   107     Cancel();
   106     Cancel();
   108 
   107 
   109 	ResetBuffers();
   108 	ResetBuffers();
   110 	
   109 	
   111 	delete iWritePtr; iWritePtr = 0;
   110 	delete iWritePtr; iWritePtr = 0;
   112 	if(iWait)
       
   113 	    {
       
   114 	     delete iWait;
       
   115 	     iWait = NULL;
       
   116 	    }
       
   117     }
   111     }
   118 
   112 
   119 
   113 
   120 
   114 
   121 // ---------------------------------------------------------
   115 // ---------------------------------------------------------
   138     else
   132     else
   139     	{
   133     	{
   140     	CLOG_WRITE_2( "(%08X) CBuffStorage::RunL DH-iStat: %d, ", this, iStatus.Int() );
   134     	CLOG_WRITE_2( "(%08X) CBuffStorage::RunL DH-iStat: %d, ", this, iStatus.Int() );
   141     	}
   135     	}
   142     	
   136     	
   143     if(iWait && iWait->IsStarted())
   137     if(iWait.IsStarted())
   144 		{
   138 		{
   145 		CLOG_WRITE_1 ( "(%08X) CBuffStorage::RunL() Stopping iWait", this );
   139 		CLOG_WRITE_1 ( "(%08X) CBuffStorage::RunL() Stopping iWait", this );
   146 		iWait->AsyncStop();
   140 		iWait.AsyncStop();
   147 		}
   141 		}
   148     }
   142     }
   149 
   143 
   150 void CBuffStorage::DoCancel()
   144 void CBuffStorage::DoCancel()
   151 	{
   145 	{
   161 //
   155 //
   162 void CBuffStorage::ResetBuffers()
   156 void CBuffStorage::ResetBuffers()
   163 	{	
   157 	{	
   164 	CLOG_WRITE_1("(%08X) CBuffStorage::ResetBuffers >>", this);
   158 	CLOG_WRITE_1("(%08X) CBuffStorage::ResetBuffers >>", this);
   165 	
   159 	
   166 	if(IsActive()&& iWait && !iWait->IsStarted())
   160 	if(IsActive())
   167 		{
   161 		{
   168 		// Make sure async writes are finished
   162 		// Make sure async writes are finished
   169 		iWait->Start();
   163 		iWait.Start();
   170 		}
   164 		}
   171 	
   165 	
   172 	// Cleanup
   166 	// Cleanup
   173     delete iBuff1; iBuff1 = NULL;
   167     delete iBuff1; iBuff1 = NULL;
   174     delete iBuff2; iBuff2 = NULL;
   168     delete iBuff2; iBuff2 = NULL;
   229 		}
   223 		}
   230 		
   224 		
   231 	CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL >>", this);
   225 	CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL >>", this);
   232 	
   226 	
   233 	// Make sure async writes are finished before doing anything
   227 	// Make sure async writes are finished before doing anything
   234 	if(IsActive() && iWait && !iWait->IsStarted())
   228 	if(IsActive())
   235 		{
   229 		{
   236 		CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling >>", this);
   230 		CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling >>", this);
   237 	 	iWait->Start();
   231 	 	iWait.Start();
   238 	 	CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling <<", this);
   232 	 	CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling <<", this);
   239 		}
   233 		}
   240 	
   234 	
   241 	if(iLastWriteErrorCode != KErrNone)
   235 	if(iLastWriteErrorCode != KErrNone)
   242 		{
   236 		{
   339 	    
   333 	    
   340 	    // Now we have a full client buffer, better do something with it
   334 	    // Now we have a full client buffer, better do something with it
   341 	    
   335 	    
   342 	    // Check if previous async write is still ongoing
   336 	    // Check if previous async write is still ongoing
   343 	    // Done here so if somebody switched on progressive download midway through we don't mix buffers
   337 	    // Done here so if somebody switched on progressive download midway through we don't mix buffers
   344 		if(IsActive()&& iWait && !iWait->IsStarted())
   338 		if(IsActive())
   345 			{
   339 			{
   346 			CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling >>", this);
   340 			CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling >>", this);
   347 		 	iWait->Start();
   341 		 	iWait.Start();
   348 		 	CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling <<", this);
   342 		 	CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling <<", this);
   349 			}
   343 			}
   350 		
   344 		
   351 		// In case of async writes we have to check if there was error previously
   345 		// In case of async writes we have to check if there was error previously
   352 		if(iLastWriteErrorCode != KErrNone)
   346 		if(iLastWriteErrorCode != KErrNone)
   419 //	
   413 //	
   420 void CBuffStorage::DoNonbufferingWriteL(const TDesC8& aBuf)
   414 void CBuffStorage::DoNonbufferingWriteL(const TDesC8& aBuf)
   421 	{
   415 	{
   422 	CLOG_WRITE_2("(%08X) CBuffStorage::DoNonbufferingWriteL: %d bytes", this, aBuf.Length());
   416 	CLOG_WRITE_2("(%08X) CBuffStorage::DoNonbufferingWriteL: %d bytes", this, aBuf.Length());
   423 	
   417 	
   424 	if(IsActive() && iWait && !iWait->IsStarted())
   418 	if(IsActive())
   425 		{
   419 		{
   426 		CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling >>", this);
   420 		CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling >>", this);
   427 		iWait->Start();
   421 		iWait.Start();
   428 		CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling <<", this);
   422 		CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling <<", this);
   429 		}
   423 		}
   430 		
   424 		
   431 	TInt len = aBuf.Length();
   425 	TInt len = aBuf.Length();
   432 	if(len)
   426 	if(len)