[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-filesystem-dev
Subject:    [Filesystem-dev] CR: (hxclient_2_1_0_cayennes Changes) Porting of
From:       <Praveen.Thimmashetty () nokia ! com>
Date:       2008-02-03 23:56:39
Message-ID: 2A15C07EF7DF6243A092FB438FD4B366C2D098 () daebe103 ! NOE ! Nokia ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


"Nokia submits this code under the terms of a commercial contribution
agreement with Real Networks, and I am authorized to contribute this
code under said agreement."

	Modified by:  Praveen.Thimmashetty@nokia.com

	Reviewed by: 

	Date: 03-February-2008

	Project: SymbianMmf

      ErrorId: SUB 409-795
	            
	Synopsis:  CR: Porting of HTTP 1.1 from head to Symbian
(hxclient_2_1_0_cayennes)
				This CR has changes that needs to go to
hxclient_2_1_0_cayennes. I will do the separate CR for HEAD changes.
Symbian will not be using data file system/cache file system. It will
just make use of Cchunkres to process data from network. 
			
	Root Cause of the problem: New Feature
	 
	Files Modified:
	Common\fileio\chunkres.cpp
	Common\fileio\pub\chunkres.h
	Common\include\hxresult.h

	filesystem\http\Umakefil
	filesystem\http\factory.cpp
	filesystem\http\factory.h
	filesystem\http\httpfsys.cpp
	filesystem\http\httpfsys.h
	filesystem\http\pub\http_debug.h

	New files added:
	filesystem\http\symbian.pcf


	Image Size and Heap Use impact: no major impact (added
httpfsys.dll (112k))

	Module Release testing (STIF) :  Passed.

	Test case(s) Added  :  No. 

	Memory leak check performed : Yes.  No new leaks introduced. 

	Platforms and Profiles Build Verified:
helix-client-s60-32-mmf-mdf-arm

	Platforms and Profiles Functionality verified: armv5,winscw

      Branch: hxclient_2_1_0_cayennes
 
 <<diff.txt>>  <<210changes.zip>> 


[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.3">
<TITLE>CR: (hxclient_2_1_0_cayennes Changes) Porting of HTTP 1.1 from head to Symbian \
(hxclient_2_1_0_cayennes) </TITLE> </HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<BR>

<P><FONT SIZE=2 FACE="Arial">&quot;Nokia submits this code under the terms of a \
commercial contribution agreement with Real Networks, and I am authorized to \
contribute this code under said agreement.&quot;</FONT></P> <UL>
<P><FONT SIZE=2 FACE="Arial">Modified by:&nbsp; Praveen.Thimmashetty@nokia.com</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Reviewed by: </FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Date: 03-February-2008</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Project: SymbianMmf</FONT>
</P>
</UL>
<P><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
ErrorId<B></B></FONT><B><FONT FACE="Arial">:</FONT></B> <FONT SIZE=2 FACE="Arial">SUB \
409-795</FONT> <UL>
<P><FONT FACE="Helv">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT> \


<BR><FONT SIZE=2 FACE="Arial">Synopsis:&nbsp; CR: Porting of HTTP 1.1 from head to \
Symbian (hxclient_2_1_0_cayennes)</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<FONT SIZE=2 FACE="Arial">This CR has changes that needs to go to \
hxclient_2_1_0_cayennes. I will do the separate CR for HEAD changes. Symbian will not \
be using data file system/cache file system. It will just make use of Cchunkres to \
process data from network. </FONT></P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

<BR><FONT SIZE=2 FACE="Nokia Sans Wide">Root Cause of the problem:</FONT> <FONT \
SIZE=2 FACE="Arial">New Feature</FONT>

<BR><FONT SIZE=2 FACE="Arial"></FONT>&nbsp;

<BR><FONT SIZE=2 FACE="Arial">Files Modified:</FONT>

<BR><FONT SIZE=2 FACE="Arial">Common\fileio\chunkres.cpp</FONT>

<BR><FONT SIZE=2 FACE="Arial">Common\fileio\pub\chunkres.h</FONT>

<BR><FONT SIZE=2 FACE="Arial">Common\include\hxresult.h</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">filesystem\http\Umakefil</FONT>

<BR><FONT SIZE=2 FACE="Arial">filesystem\http\factory.cpp</FONT>

<BR><FONT SIZE=2 FACE="Arial">filesystem\http\factory.h</FONT>

<BR><FONT SIZE=2 FACE="Arial">filesystem\http\httpfsys.cpp</FONT>

<BR><FONT SIZE=2 FACE="Arial">filesystem\http\httpfsys.h</FONT>

<BR><FONT SIZE=2 FACE="Arial">filesystem\http\pub\http_debug.h</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">New files added:</FONT>

<BR><FONT SIZE=2 FACE="Arial">filesystem\http\symbian.pcf</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">Image Size and Heap Use impact: no major impact (added \
httpfsys.dll (112k))</FONT> </P>

<P><FONT SIZE=2 FACE="Arial">Module Release testing (STIF) :&nbsp; Passed.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Test case(s) Added&nbsp; :&nbsp; No. </FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Memory leak check performed : Yes.&nbsp; No new leaks \
introduced. </FONT> </P>

<P><FONT SIZE=2 FACE="Arial">Platforms and Profiles Build Verified: \
helix-client-s60-32-mmf-mdf-arm</FONT> </P>

<P><FONT SIZE=2 FACE="Arial">Platforms and Profiles Functionality verified: \
armv5,winscw</FONT> </P>
</UL>
<P><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Branch: \
hxclient_2_1_0_cayennes</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;</FONT>

<BR><FONT FACE="Arial" SIZE=2 COLOR="#000000"> &lt;&lt;diff.txt&gt;&gt; </FONT><FONT \
FACE="Arial" SIZE=2 COLOR="#000000"> &lt;&lt;210changes.zip&gt;&gt; </FONT> </P>

</BODY>
</HTML>


["diff.txt" (text/plain)]

Index: Umakefil
===================================================================
RCS file: /cvsroot/filesystem/http/Umakefil,v
retrieving revision 1.9
diff -w -u -b -r1.9 Umakefil
@@ -57,15 +57,16 @@
 # here for testing purposes.
 #project.AddDefines("HELIX_FEATURE_HTTP_GZIP")
 
-project.AddModuleIncludes("common/include")
+project.AddModuleIncludes("common/include","common/util/pub")
 
 project.AddSources("factory.cpp",
-                   "httpfsys.cpp",
-                   "cache.cpp",
-                   "fsdb.cpp")
+                   "httpfsys.cpp")
 
-project.AddModuleLibraries("filesystem/data[datafsys]",
-                           "protocol/http[httplib]",
+if not project.IsDefined("_SYMBIAN"):
+    project.AddSources("fsdb.cpp",
+                       "cache.cpp")
+
+project.AddModuleLibraries("protocol/http[httplib]",
                            "protocol/common/util[protutillib]",
                            "common/dbgtool[debuglib]",
                            "common/fileio[fileiolib]",
@@ -76,6 +77,9 @@
                            "common/netio[netiolib]",
                            "common/log/logutil[logutillib]")
 
+if not project.IsDefined("_SYMBIAN"):
+    project.AddModuleLibraries("filesystem/data[datafsys]")                          \
 +
 if project.IsDefined("HELIX_FEATURE_HTTP_GZIP"):
     project.AddSources("decoder.cpp")
     project.AddModuleLibraries("common/import/zlib[zlib]")

Index: factory.cpp
===================================================================
RCS file: /cvsroot/filesystem/http/factory.cpp,v
retrieving revision 1.8
diff -w -u -b -r1.8 factory.cpp
@@ -107,24 +107,32 @@
 #undef HX_THIS_FILE		
 static const char HX_THIS_FILE[] = __FILE__;
 #endif
+#if !defined(_SYMBIAN)
 #include "datafsys.h"
+#endif
 #include "httpfsys.h"
 #include "factory.h"
 #include "ihxcookies2.h"
 
-HX_RESULT (STDAPICALLTYPE  *HTTPPluginFactory::m_fpEntryArray[])(IUnknown**)={
+HX_RESULT (STDAPICALLTYPE  * const \
HTTPPluginFactory::m_fpEntryArray[])(IUnknown**)={  \
CHTTPFileSystem::HXCreateInstance, +#if !defined(_SYMBIAN)	
 	DataFileSystem::HXCreateInstance,
+#endif	
 	0};
 
-HX_RESULT (STDAPICALLTYPE  *HTTPPluginFactory::m_fpExitArray[])()={
+HX_RESULT (STDAPICALLTYPE  * const HTTPPluginFactory::m_fpExitArray[])()={
 	CHTTPFileSystem::HXShutdown,
+#if !defined(_SYMBIAN)	
 	DataFileSystem::HXShutdown,
+#endif	
 	0};
 
-HX_RESULT (*HTTPPluginFactory::m_fpUnloadArray[])()={
+HX_RESULT (* const HTTPPluginFactory::m_fpUnloadArray[])()={
 	CHTTPFileSystem::CanUnload,
+#if !defined(_SYMBIAN)	
 	DataFileSystem::CanUnload,
+#endif	
 	0};
 
 
@@ -146,7 +154,7 @@
  *	situation.
  * 
  */
-STDAPI ENTRYPOINT(HXCREATEINSTANCE)
+STDAPI HXEXPORT ENTRYPOINT(HXCREATEINSTANCE)
 (   
     IUnknown**  /*OUT*/	ppIUnknown  
 )   
@@ -173,7 +181,7 @@
  *
  */
 
-STDAPI ENTRYPOINT(HXSHUTDOWN)()	
+STDAPI HXEXPORT ENTRYPOINT(HXSHUTDOWN)()	
 {   
    int i = 0;
 
@@ -198,7 +206,7 @@
  *	then the pluginhandler can unload the DLL
  *
  */
-STDAPI ENTRYPOINT(CanUnload)(void)
+STDAPI HXEXPORT ENTRYPOINT(CanUnload)(void)
 {
     int i = 0;
 
Index: factory.h
===================================================================
RCS file: /cvsroot/filesystem/http/factory.h,v
retrieving revision 1.2
diff -w -u -b -r1.2 factory.h
@@ -68,9 +68,10 @@
 
     LONG32 m_lRefCount;
     UINT16  m_usNumOfPlugins;
-    static HX_RESULT (STDAPICALLTYPE  *m_fpEntryArray[])(IUnknown**);
-    static HX_RESULT (STDAPICALLTYPE  *m_fpExitArray[])();
-    static HX_RESULT (*m_fpUnloadArray[])();
+    static HX_RESULT (STDAPICALLTYPE * const m_fpEntryArray [])(IUnknown**);
+    static HX_RESULT (STDAPICALLTYPE * const m_fpExitArray [])();
+    static HX_RESULT (* const  m_fpUnloadArray [])();
+        
 };
 
 /****************************************************************************
Index: httpfsys.cpp
===================================================================
RCS file: /cvsroot/filesystem/http/httpfsys.cpp,v
retrieving revision 1.88.2.2
diff -w -u -b -r1.88.2.2 httpfsys.cpp
@@ -113,6 +113,8 @@
 #include "httpfsys.h"
 #include "ihxcookies2.h"
 #include "hxtlogutil.h"
+#include "hxdir.h"
+
 
 #ifdef _MACINTOSH
 //#include "../dcondev/dcon.h"
@@ -153,6 +155,10 @@
 
 #define REDIRECT_LIMIT          20
 
+// For PR 152375
+#define LARGEST_CHUNK_SIZE_WE_ACCEPT_CONFIG_KEY \
"config.HTTPChunkedEncodingMaxChunkSize" +#define LARGEST_CHUNK_SIZE_WE_ACCEPT (256L \
* 1024L) +
 #undef  LOG_DATA
 #define MAX_CACHE_SIZE          (64 * 1024 * 1024)
 #define CACHE_DEFAULT_TTL_SECS  (1 * 60 * 60)
@@ -164,7 +170,9 @@
 
 #include <string.h>
 
+#if !defined(HELIX_CONFIG_NOSTATICS) 
 UINT32 g_ulDefTtl;
+#endif
 
 #ifndef USE_TEMP_CACHE_LOCATION
 #define DEF_CACHE_DB            "cache_db"
@@ -175,8 +183,10 @@
 
 #define HTTP_MAX_BUFFER_BEFORE_PROCESSIDLE (64 * 1024)
 
+#if !defined(HELIX_CONFIG_NOSTATICS) 
 CCacheEntry*   g_pCacheEntry = NULL;
 IHXBuffer*    CreateBufferFromValues (IHXValues *pHeaderValues);
+#endif
 
 // default if no timeouts in preferences.
 #define DEF_HTTP_SERVER_TIMEOUT     (20 * MILLISECS_PER_SECOND)
@@ -189,6 +199,35 @@
 // just wait for old-fashioned reading to catch up
 #define BYTE_RANGE_SEEK_THRESHHOLD (4 * 1024)
 
+// #define HELIX_FEATURE_HTTP_MEMCACHE
+
+// MemCache Setting
+#if defined(HELIX_FEATURE_HTTP_MEMCACHE)
+#if defined(HELIX_FEATURE_MIN_HEAP)
+#define DFLT_MEM_CACHE_SIZE	0x00080000  // 0.5MB
+#define MIN_MEM_CACHE_SIZE	0x00010000  //  64KB
+#else	// HELIX_FEATURE_MIN_HEAP
+#define DFLT_MEM_CACHE_SIZE	0x00400000  //   4MB
+#define MIN_MEM_CACHE_SIZE	0x00040000  // 256KB
+#endif	// HELIX_FEATURE_MIN_HEAP
+#else	// HELIX_FEATURE_HTTP_MEMCACHE
+#define DFLT_MEM_CACHE_SIZE	0x00000000
+#define MIN_MEM_CACHE_SIZE	0x00000000
+#endif	// HELIX_FEATURE_HTTP_MEMCACHE
+
+#define MEM_CACHE_TRIM_THRESHOLD_DENOM	    4	    // Denominator indicating fraction \
of the +						    // mem cache capacity that needs to be
+						    // present in direct path of data read
+						    // to avoid trimming the memory to make
+						    // room for additional data.
+						    // It also indicates the fraction by which
+						    // the mem-cache will be trimmed when
+						    // more room is needed.
+						    // Must be >= 2  (>= 50% of mem cache capacity).
+						    
+#define DFLT_MEM_CACHE_CONTIG_LENGTH_TRIM_THRESHOLD (DFLT_MEM_CACHE_SIZE / \
MEM_CACHE_TRIM_THRESHOLD_DENOM) +#define DFLT_MEM_CACHE_TRIM_SIZE		    \
(DFLT_MEM_CACHE_SIZE / MEM_CACHE_TRIM_THRESHOLD_DENOM) +
 // Tresholds for the amount of data to receive before attempting to make
 // sense of the response and associated headers
 #define HTTP_MIN_STARTUP_LENGTH_NEEDED              5       // bytes
@@ -196,11 +235,10 @@
 
 #define ICECAST_META_SIZE_MULTIPLE                  16      // bytes
 
-
-const char* CHTTPFileSystem::zm_pDescription    = "RealNetworks HTTP File System \
                with CHTTP Support";
-const char* CHTTPFileSystem::zm_pCopyright      = HXVER_COPYRIGHT;
-const char* CHTTPFileSystem::zm_pMoreInfoURL    = HXVER_MOREINFO;
-const char* CHTTPFileSystem::zm_pShortName      = "pn-http";
+const char* const CHTTPFileSystem::zm_pDescription    = "RealNetworks HTTP File \
System with CHTTP Support"; +const char* const CHTTPFileSystem::zm_pCopyright      = \
HXVER_COPYRIGHT; +const char* const CHTTPFileSystem::zm_pMoreInfoURL    = \
HXVER_MOREINFO; +const char* const CHTTPFileSystem::zm_pShortName      = "pn-http";
 
 /// This name is used to indicate the http server is
 /// actually RealServer. If the server team changes
@@ -213,20 +251,17 @@
 //#define LOG_DUMP_FILE "c:/temp/avi.txt"
 
 #ifdef SUPPORT_SECURE_SOCKETS
-const char* CHTTPFileSystem::zm_pProtocol       = "http|chttp|https";
+const char* const CHTTPFileSystem::zm_pProtocol       = "http|chttp|https";
 #else
-const char* CHTTPFileSystem::zm_pProtocol       = "http|chttp";
+const char* const CHTTPFileSystem::zm_pProtocol       = "http|chttp";
 #endif
 
+#if !defined(HELIX_CONFIG_NOSTATICS) 
 HXBOOL CHTTPFileSystem::m_bSaveNextStream = FALSE;
 //CHXString CHTTPFileSystem::m_SaveFileName( "" );
 CHXString CHTTPFileSystem::m_SaveFileName;
-
-
-static INT32 g_nRefCount_http  = 0;
-
 static CChunkyResMap g_ChunkyResMap;
-
+#endif //_SYMBIAN
 
 #define WWW_AUTHENTICATION_RECENT_KEY "authentication.http.realm.recent"
 #define PROXY_AUTHENTICATION_RECENT_KEY "proxy-authentication.http.realm.recent"
@@ -262,13 +297,17 @@
 }
 
 CChunkyRes*
-CChunkyResMap::GetChunkyResForURL(const char* pURL, void* pCursorOwner)
+CChunkyResMap::GetChunkyResForURL(const char* pURL, void* pCursorOwner, IUnknown* \
pContext)  {
     CChunkyRes* pChunkyRes = NULL;
 
     if ( !m_pChunkyResURLMap->Lookup( pURL, (void*&)pChunkyRes ) )
     {
+#if !defined(_SYMBIAN)         
+        pChunkyRes = new CChunkyRes(pContext);
+#else        
         pChunkyRes = new CChunkyRes();
+#endif        
         m_pChunkyResURLMap->SetAt(pURL, pChunkyRes);
     }
 
@@ -368,14 +407,14 @@
     {
         return HXR_OK;
     }
-
+#if !defined(HELIX_CONFIG_NOSTATICS) 
     if (g_pCacheEntry)
     {
         g_pCacheEntry->close();
         delete g_pCacheEntry;
         g_pCacheEntry = NULL;
     }
-
+#endif
     return HXR_OK;
 }
 
@@ -393,14 +432,17 @@
  */
 HX_RESULT CHTTPFileSystem::CanUnload(void)
 {
-    return (g_nRefCount_http ? HXR_FAIL : HXR_OK);
+    HX_RESULT result = (CHXBaseCountingObject::ObjectsActive() > 0) ? HXR_FAIL : \
HXR_OK; +    return (result);
 }
 
 
 BEGIN_INTERFACE_LIST(CHTTPFileSystem)
     INTERFACE_LIST_ENTRY(IID_IHXPlugin, IHXPlugin)
     INTERFACE_LIST_ENTRY(IID_IHXFileSystemObject, IHXFileSystemObject)
+#if !defined(_SYMBIAN)    
     INTERFACE_LIST_ENTRY(IID_IHXFileSystemCache, IHXFileSystemCache)
+#endif    
     INTERFACE_LIST_ENTRY(IID_IHXHTTPAutoStream, IHXHTTPAutoStream)
 END_INTERFACE_LIST
 
@@ -408,12 +450,10 @@
     m_pContext(NULL)
     , m_pOptions(NULL)
 {
-    g_nRefCount_http++;
 }
 
 CHTTPFileSystem::~CHTTPFileSystem()
 {
-    g_nRefCount_http--;
     HX_RELEASE(m_pContext);
     HX_RELEASE(m_pOptions);
 }
@@ -551,7 +591,7 @@
 
 
 
-
+#if !defined(_SYMBIAN)
 /////////////////////////////////////////////////////////////////////////
 //  Method:
 //      CHTTPFileSystem::RefreshCache
@@ -688,7 +728,7 @@
 
     return HXR_OK;
 }
-
+#endif //_SYMBIAN
 
 STDMETHODIMP_(void)
 CHTTPFileSystem::SetDestinationFile( const char *pFilename )
@@ -799,9 +839,10 @@
     {
         AddRef();
         *ppvObj = (IHXPendingStatus*)(this);
-
+#if !defined _SYMBIAN
         //FNH This is probably not needed
         ProcessCacheCompletions(FALSE);
+#endif        
         return HXR_OK;
     }
     if (IsEqualIID(IID_IHXRequestHandler, riid))
@@ -913,12 +954,16 @@
 
     , m_bInitialized(FALSE)
     , m_bInDestructor(FALSE)
+    , m_bClosed(FALSE)
 
     , m_ulCurrentReadPosition (0)
     , m_ulLastKnownEndOfValidContiguousRange(0)
 
     , m_pDecoder(NULL)
     , m_pChunkyRes(NULL)
+#if defined(_SYMBIAN)    
+    , m_pChunkyResMap(NULL)
+#endif    
     , m_pMutex(NULL)
 
     , m_nPort(DEF_HTTP_PORT)
@@ -937,6 +982,9 @@
     , m_bConvertFailedSeeksToLinear(TRUE)
     , m_bHaltSocketReadTemporarily(FALSE)
     , m_ulMaxBufSize(MAX_CHUNK_SIZE)
+    , m_ulMemCacheSize(DFLT_MEM_CACHE_SIZE)
+    , m_ulMemCacheContigLengthTrimThreshold(DFLT_MEM_CACHE_CONTIG_LENGTH_TRIM_THRESHOLD)
 +    , m_ulMemCacheTrimSize(DFLT_MEM_CACHE_TRIM_SIZE)
 
 #if defined(HELIX_FEATURE_PROGRESSIVE_DOWNLD_STATUS)
     , m_bDownloadCompleteReported(FALSE)
@@ -975,6 +1023,7 @@
 
     , m_bKnowContentSize(FALSE)
     , m_nContentSize(0)
+    , m_nOriginalContentSize(0)
     , m_bEncoded(FALSE)
 
     , m_bChunkedEncoding(FALSE)
@@ -1046,7 +1095,6 @@
     , m_bByteRangeSeekPending(FALSE)
     , m_bCheckingWhetherByteRangeWorks(FALSE)
     , m_bServerPresumablyWorksWithByteRangeRequests(TRUE)
-    , m_bClosed(FALSE)
     , m_pLastHeader(NULL)
     , m_ulMinStartupLengthNeeded(HTTP_MIN_STARTUP_LENGTH_NEEDED)
     , m_ulIgnoreBytesYetToBeDownloaded(0)
@@ -1055,12 +1103,6 @@
 /*************************/
 {
     SetSupportsByteRanges(m_bSupportsByteRanges);
-
-#if defined(THREADS_SUPPORTED)
-    HXMutex::MakeMutex(m_pMutex);
-#else
-    HXMutex::MakeStubMutex(m_pMutex);
-#endif
 }
 
 void
@@ -1088,6 +1130,7 @@
 void
 CHTTPFileObject::SetReadContentsDone(HXBOOL bReadContentsDone)
 {
+    HXLOGL4(HXLOG_HTTP, "CHTTPFileObject::SetReadContentsDone");
     m_bReadContentsDone = bReadContentsDone;
 #if defined(HELIX_FEATURE_PROGRESSIVE_DOWNLD_STATUS)
     if (m_pBytesToDur  &&  bReadContentsDone)
@@ -1152,6 +1195,12 @@
     {
         m_pContext = pContext;
         m_pContext->AddRef();
+    	#if defined(THREADS_SUPPORTED) || defined(_UNIX_THREADS_SUPPORTED)
+            HXMutex::MakeMutex(m_pMutex);
+        #else
+            HXMutex::MakeStubMutex(m_pMutex);
+        #endif
+        HX_ASSERT( m_pMutex );
 
         m_pContext->QueryInterface(IID_IHXScheduler, (void**) &m_pScheduler);
         m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void \
**)&m_pCommonClassFactory); @@ -1270,11 +1319,21 @@
 
 //      if (szBaseURL && ::strncmp (szBaseURL, "http:", 5) == 0)
         {
+#if !defined _SYMBIAN            
             CacheSupport_InitObject();
+#endif            
         }
 
         // buffer ahead amount for throttling download if desired
         ReadPrefUINT32(m_pPreferences, "HTTPBufferAheadAmount", \
m_ulBufferAheadAmount); +	
+	// Use memory cache only if desired of indicated size
+        ReadPrefUINT32(m_pPreferences, "HTTPMemCacheSize", m_ulMemCacheSize);
+    }
+    
+    if ((m_ulMemCacheSize != 0) && (m_ulMemCacheSize < MIN_MEM_CACHE_SIZE))
+    {
+	m_ulMemCacheSize = MIN_MEM_CACHE_SIZE;
     }
 
     if (m_pCallback && m_pCallback->IsCallbackPending())
@@ -1472,6 +1531,11 @@
  */
 STDMETHODIMP CHTTPFileObject::Close()
 {
+    if (m_bClosed)
+    {
+	return HXR_OK;
+    }
+
     m_pMutex->Lock();
 
     HXLOGL1(HXLOG_HTTP, "Close(%s)", NULLOK(m_pFilename));
@@ -1481,8 +1545,13 @@
         m_bGetProxyInfoPending = FALSE;
         m_pPAC->AbortProxyInfo(this);
     }
-
+#if !defined(HELIX_CONFIG_NOSTATICS) 
     g_ChunkyResMap.RelinquishChunkyRes(m_pChunkyRes, this);
+#else    
+    m_pChunkyResMap->RelinquishChunkyRes(m_pChunkyRes, this);
+    delete m_pChunkyResMap;
+    m_pChunkyResMap = NULL;
+#endif    
     m_pChunkyRes = NULL;
 
     HX_RELEASE(m_pFileSystem);
@@ -1662,6 +1731,7 @@
  */
 STDMETHODIMP CHTTPFileObject::Read(ULONG32 ulCount)
 {
+    HXLOGL4(HXLOG_HTTP, "CHTTPFileObject::Read");
     HXScopeLock lock(m_pMutex);
 
     HX_RESULT           lResult      = HXR_OK;
@@ -1731,7 +1801,9 @@
 
         while (ulCount > ulCurrentContig && lSocketReadResult == HXR_OK)
         {
+		    m_pMutex->Unlock();
             lSocketReadResult = _DoSomeReadingFromSocket(TRUE);
+		    m_pMutex->Lock();
 
             if (SUCCEEDED(lSocketReadResult))
             {
@@ -1822,6 +1894,8 @@
         _SetCurrentReadPos(ulOffset);
     }
 
+    TrimMemCacheIfNeeded();
+
     /* check if there were any pending reads */
     if (m_bSeekPending || m_bReadPending)
     {
@@ -2020,6 +2094,10 @@
     {
         m_bConvertFailedSeeksToLinear = TRUE;
     }
+    else if (HX_FILEADVISE_NETWORKACCESS == ulInfo)
+    {
+	pnr = HXR_ADVISE_NETWORK_ACCESS;
+    }
 
     return pnr;
 }
@@ -2268,10 +2346,8 @@
             CHXString statusDesc = "Contacting ";
             statusDesc += m_strHost;
             statusDesc += "...";
-            pStatusDesc = new CHXBuffer;
-            pStatusDesc->AddRef();
-            pStatusDesc->Set((UCHAR*)(const char*) statusDesc,
-                             strlen((const char*)statusDesc)+1);
+	    CreateAndSetBufferCCF(pStatusDesc, (UCHAR*)(const char*) statusDesc,
+                             strlen((const char*)statusDesc)+1, m_pContext);
         }
         ulPercentDone   = 0;
     }
@@ -2313,17 +2389,46 @@
  */
 HX_RESULT CHTTPFileObject::_InitializeChunkyRes(const char* url)
 {
+    HXLOGL4(HXLOG_HTTP, "CHTTPFileObject::_InitializeChunkyRes");
+    HX_RESULT theErr = HXR_OK;
+    
     if (!m_pChunkyRes)
     {
+#if !defined(HELIX_CONFIG_NOSTATICS) 
         m_pChunkyRes = g_ChunkyResMap.GetChunkyResForURL(url, this);
-
+#else        
+        if(!m_pChunkyResMap)
+        {
+            m_pChunkyResMap = new CChunkyResMap;
+        }
+        if(m_pChunkyResMap)
+        {
+            m_pChunkyRes = m_pChunkyResMap->GetChunkyResForURL(url, this, \
m_pContext); +        }
+#endif
+        if(m_pChunkyRes)
+        {
         HXLOGL1(HXLOG_HTTP, "_InitializeChunkyRes(%s) ==> %lx", NULLOK(url), \
m_pChunkyRes);  
-        if (m_bOnServer)
+            if (m_bOnServer || (m_ulMemCacheSize != 0))
         {
             m_pChunkyRes->DisableDiskIO();
-        }
 
+        	    if (m_ulMemCacheSize != 0)
+        	    {
+        		// We set here by how much to trim the memory cache once trimming is \
needed +        		m_ulMemCacheTrimSize = (m_ulMemCacheSize / \
MEM_CACHE_TRIM_THRESHOLD_DENOM); +        					
+        		// Also set when to trigger the mem cache trimming
+        		m_ulMemCacheContigLengthTrimThreshold = (m_ulMemCacheSize / \
MEM_CACHE_TRIM_THRESHOLD_DENOM); +        	    }
+            }
+        }
+        else
+        {
+            HXLOGL1(HXLOG_HTTP, "_InitializeChunkyRes(%s) ==> %lx FAILED", \
NULLOK(url), m_pChunkyRes); +            theErr = HXR_OUTOFMEMORY;
+        }
 #if defined(HELIX_FEATURE_HTTP_GZIP)
         m_pDecoder = new CDecoder;
         if (m_pDecoder && m_pChunkyRes)
@@ -2333,7 +2438,7 @@
 #endif
 
     }
-    return HXR_OK;
+    return theErr;
 }
 
 /************************************************************************
@@ -2347,7 +2452,7 @@
 {
     HX_RESULT       theErr  = HXR_OK;
     HX_RESULT       lResult = HXR_OK;
-    UINT16          un16Temp = 0;
+    UINT16          un16Temp = 1;
     char*           pTemp   = NULL;
     IHXBuffer*      pBuffer = NULL;
     IHXBuffer*      pProxyName = NULL;
@@ -2591,9 +2696,9 @@
 CHTTPFileObject::_OpenFileExt()
 {
     HX_RESULT   theErr = HXR_OK;
-
+#if !defined _SYMBIAN
     CacheSupport_OpenFile();
-
+#endif
     if (m_bCached)
     {
         m_bInitPending = FALSE;
@@ -2717,10 +2822,11 @@
         }
     }
 
+    TrimMemCacheIfNeeded();
 
+    m_pMutex->Unlock();
     _DoSomeReadingFromSocket(TRUE);
 
-    m_pMutex->Unlock();
     HX_RESULT ReadErr = ProcessPendingReads();
     m_pMutex->Lock();
 
@@ -3197,8 +3303,11 @@
                 HX_DELETE(pHXURL);
             }
 
-            IHXValues* pValuesRequestHeaders = new CHXHeader();
-            pValuesRequestHeaders->AddRef();
+            IHXValues* pValuesRequestHeaders = NULL;	    
+	    if (HXR_OK != CreateValuesCCF(pValuesRequestHeaders, m_pContext))
+	    {
+		goto exit;
+	    }
 
             CHXHeader::mergeHeaders(pValuesRequestHeaders, pHeaders);
 
@@ -3529,7 +3638,7 @@
 
 
     m_strRequest += "\r\n\r\n";
-
+    m_nTotalRequestSize = (UINT16)m_strRequest.GetLength();
     HX_VECTOR_DELETE(pOutBuffer);
 
     if (!m_pSocket)
@@ -3577,7 +3686,6 @@
         }
     }
 
-    m_nTotalRequestSize = (UINT16)m_strRequest.GetLength();
 
     HXLOGL2(HXLOG_HTTP, "BeginGet: request size is %lu",m_nTotalRequestSize);
 
@@ -3611,9 +3719,8 @@
             FAILED(m_pOptions->GetPropertyBuffer("Agent", pBuffer)))
         {
             // Finally, fall back to the default User Agent value
-            pBuffer = new CHXBuffer();
-            pBuffer->AddRef();
-            pBuffer->Set((UCHAR*)DEF_USER_AGENT, strlen(DEF_USER_AGENT) + 1);
+	    CreateAndSetBufferCCF(pBuffer, (UCHAR*)DEF_USER_AGENT, 
+				  strlen(DEF_USER_AGENT) + 1, m_pContext);
         }
     }
 
@@ -3770,8 +3877,10 @@
                     bHandleReadImmediately = TRUE;
                 }
                 
+                    m_pMutex->Unlock();
                 _DoSomeReadingFromSocket(bHandleReadImmediately);
                 
+                    m_pMutex->Lock();
                 if (bHandleReadImmediately)
                 {
                     m_pMutex->Unlock();
@@ -3923,11 +4032,10 @@
         }
         else
         {
-            IHXBuffer* pRedirectURL = new CHXBuffer();
+            IHXBuffer* pRedirectURL = NULL;
 
-            pRedirectURL->AddRef();
-            pRedirectURL->Set((const UCHAR*)(const char*)sLocation,
-                sLocation.GetLength()+1);
+	    CreateAndSetBufferCCF(pRedirectURL, (UCHAR*)(const char*)sLocation,
+				  sLocation.GetLength()+1, m_pContext);
 
             if (HXR_NOTIMPL == m_pRedirectResponse->RedirectDone(pRedirectURL))
                 bContinueRedirect = TRUE;
@@ -4025,8 +4133,9 @@
             theErr = _ReOpen();
         }
     }
-
+#if !defined _SYMBIAN
     ProcessCacheCompletions(TRUE);
+#endif    
     return theErr;
 }
 
@@ -4045,11 +4154,6 @@
 
     if (!m_bSeekPending && !m_bByteRangeSeekPending && m_pChunkyRes)
     {
-        // xxxbobclark assert that it either has some data or it's
-        // at the very end of the resource.
-
-        HX_ASSERT((_GetContiguousLength() > 0) || (m_ulCurrentReadPosition == \
                m_nContentSize));
-
         if (m_nContentRead >= m_ulCurrentReadPosition)
         {
             ULONG32 ulLength = _GetContiguousLength();
@@ -4354,13 +4458,6 @@
 
     bShouldReadSocket = FALSE;
 
-    if (bHandleBuffersImmediately && ulPreProcessedAmount > 0)
-    {
-        // as we're being called from Process Idle, we'll
-        // go ahead and process accumulated preprocessed content.
-        bShouldReadSocket = TRUE;
-    }
-
     if (m_ulBufferAheadAmount > 0)
     {
         // if m_ulBufferAheadAmount is nonzero, that will tell how
@@ -4383,6 +4480,11 @@
         bShouldReadSocket = TRUE;
     }
 
+    if (bShouldReadSocket)
+    {
+	bShouldReadSocket = (!IsMemCacheFull());
+    }
+    
     if (bShouldReadSocket && !bHandleBuffersImmediately)
     {
         // if it's NOT processidle and we're starting to accrue too
@@ -4491,13 +4593,19 @@
         }
         else if (HXR_SOCK_ENDSTREAM == retVal)
         {
+            if (!m_bKnowContentSize)
+            {
+                // if "Content-Length" is not set in HTTP Reponse, 
+                // we need to assume we have read all the content if the socket was \
closed by the server. +                SetReadContentsDone(TRUE);
+            }
+
             // normal end of data reached
             if( m_pSocket )
             {
                 m_pSocket->Close();
                 HX_RELEASE(m_pSocket);
                 HXLOGL1(HXLOG_HTTP, "_DoSomeReadingFromSocket END OF STREAM (closing \
                socket)");
-                SetReadContentsDone(TRUE);
 
                 // we should still kick-start a callback, since we may need to \
                process reads
                 // if another owner (like in a surestream file) is reading for us.
@@ -4573,7 +4681,79 @@
     return retVal;
 }
 
+HXBOOL
+CHTTPFileObject::IsMemCacheFull(void)
+{
+    HXBOOL bRetVal = FALSE;
+    
+    if (m_ulMemCacheSize)
+    {
+	bRetVal = ((!m_pChunkyRes) ||
+		   (m_pChunkyRes->GetCurrentMemoryUsage() >= m_ulMemCacheSize));
+    }
+    
+    return bRetVal;
+}
+
+HXBOOL
+CHTTPFileObject::TrimMemCacheIfNeeded(void)
+{
+    HXBOOL bRetVal = FALSE;
+    
+    if (m_pChunkyRes && IsMemCacheFull())
+    {
+	UINT32 ulCurrentContigLength = _GetContiguousLength();
+	UINT32 ulCursorCount = (UINT32) m_pChunkyRes->CountCursors();
+	
+	if (ulCursorCount == 0)
+	{
+	    ulCursorCount = 1;
+	}
+
+	if ((ulCurrentContigLength < (m_ulMemCacheContigLengthTrimThreshold / \
ulCursorCount)) && +	    ((!m_bKnowContentSize) ||
+	     ((m_ulCurrentReadPosition + ulCurrentContigLength) < m_nContentSize)))
+	{
+	    // We do not have enogh contiguous length ahead of the current read positions
+	    // and mem-cache is full thus disallowing more data to be read.
+	    // We must trim the mem-cache
+	    
+	    // First - make sure to make data ahead of read positions most recent
+	    // to prevent deletion of this data
+	    if (ulCursorCount == 1)
+	    {
+		m_pChunkyRes->TouchRange(m_ulCurrentReadPosition, m_ulMemCacheTrimSize);
+	    }
+	    else
+	    {
+		UINT32 ulCursorIndex;
+		void* pCursorOwner;
+		UINT32 ulCursorLocation;
+	    
+		for (ulCursorIndex = 0; ulCursorIndex < ulCursorCount; ulCursorIndex++)
+		{
+		    ulCursorLocation = 0;
+		    if (SUCCEEDED(m_pChunkyRes->GetNthCursorInformation(ulCursorIndex, \
pCursorOwner, ulCursorLocation))) +		    {
+			m_pChunkyRes->TouchRange(ulCursorLocation, m_ulMemCacheTrimSize / ulCursorCount);
+			if (pCursorOwner)
+			{
+			    CHTTPFileObject* pHTTPFileObject = (CHTTPFileObject*) pCursorOwner;
+			    pHTTPFileObject->m_ulLastKnownEndOfValidContiguousRange = 0;
+			}
+		    }
+		}
+	    }
+	    
+	    m_pChunkyRes->SetMemUsageThreshold(m_ulMemCacheSize - m_ulMemCacheTrimSize);
+	    m_ulLastKnownEndOfValidContiguousRange = 0;
+	    
+	    bRetVal = TRUE;
+	}
+    }
 
+    return bRetVal;
+}
 
 void
 CHTTPFileObject::_SetCurrentReadPos(UINT32 ulNewCurrentReadPosition)
@@ -4736,6 +4916,9 @@
             IHXBuffer* pServerHeaderBuffer = NULL;
             HX_RESULT retVal = HXR_OK;
 
+            const char* pszHost = GetActualHost();
+            SetCStringPropertyCCF(pResponseHeaders, "_host", pszHost, m_pContext);
+
             // Keep this connection alive?
             pResponseHeaders->GetPropertyCString
             (
@@ -5132,7 +5315,7 @@
         UINT32 ulValue = 0;
         if (pMessage->getHeaderValue("content-length", ulValue))
         {
-            m_nContentSize = ulValue;
+            m_nOriginalContentSize = m_nContentSize = ulValue;
 
             // xxxbobclark the problem is that m_nContentSize is really
             // the content size of this particular GET. And if we're getting
@@ -5157,7 +5340,7 @@
                 if (numFields == 2)
                 {
                     CHXString theDenominator = theContentRange.NthField('/', 2);
-                    m_nContentSize = strtol((const char*)theDenominator, 0, 10);
+                    m_nOriginalContentSize = m_nContentSize = strtol((const \
char*)theDenominator, 0, 10);  }
             }
 
@@ -5172,7 +5355,7 @@
                 m_ulPrgDnTotalFileSize != HX_PROGDOWNLD_UNKNOWN_FILE_SIZE)
         {
             m_bKnowContentSize = TRUE;
-            m_nContentSize = m_ulPrgDnTotalFileSize;
+            m_nOriginalContentSize = m_nContentSize = m_ulPrgDnTotalFileSize;
         }
         else if (m_bKnowContentSize)
         {
@@ -5182,7 +5365,9 @@
 
         if (m_pCacheEntry)
         {
+#if !defined _SYMBIAN          
             CacheSupport_HandleSuccess(pMessage);
+#endif            
         }
 
         // Find the mime type to support mime reporting...
@@ -5376,6 +5561,31 @@
             bLive = TRUE;
         }
     }
+    else if (!m_bKnowHTTPResponseContentSize && !m_bEncoded)
+    {
+        // We add this case because we have encountered live HTTP streams
+        // for which there is no Content-Length, and we have no other
+        // indication that this is a live stream. Currently, httpfsys
+        // uses IsLiveStream to determine two things:
+        // a) If IsLiveStream() == TRUE, then return PREFER_LINEAR to
+        //    the Advise(RANDOM_ACCESS) query. Fileformats use this
+        //    information to know not to seek to the end of the file.
+        // b) If IsLiveStream() == TRUE, then we tell chunky-res to
+        //    throw data away after it has read it once.
+        // For truly live streams, we want to do both (a) and (b). 
+        // However, we may encounter a case that a web server is
+        // mis-configured and does not report a Content-Length for
+        // on-demand files. For such mis-configured web servers, we
+        // really want to do just (a) and not (b). However, we currently
+        // don't have any way to distinguish between these truly
+        // live streams and mis-configured on-demand streams. The
+        // downside to declaring these streams live is that
+        // some data may have to be downloaded twice if the
+        // data needs to be read twice. However, this seems like
+        // a reasonable trade-off, since if a server is mis-configured,
+        // it is expected that clients would have to be less efficient.
+        bLive = TRUE;
+    }
 
     return bLive;
 }
@@ -5538,6 +5748,7 @@
         LOGX((szDbgTemp, "    m_pFilename='%s'", m_pFilename));
         LOGX((szDbgTemp, "    m_pCacheFile='%s'", (char \
*)m_pCacheFile->GetBuffer()));  
+#if !defined(HELIX_CONFIG_NOSTATICS)
         // Create the cache database if need be
         if (g_pCacheEntry == NULL)
         {
@@ -5547,6 +5758,7 @@
         }
         if (m_pCacheEntry == NULL)
             m_pCacheEntry = g_pCacheEntry;
+#endif        
     }
 
     // Strip off any URL parameters and store them
@@ -5872,6 +6084,7 @@
 /*
  * This supplies the bulk of processing needed by the _OpenFile method
  */
+#if !defined _SYMBIAN
 STDMETHODIMP_(void)
 CHTTPFileObject::CacheSupport_InitObject (void)
 {
@@ -6548,7 +6761,7 @@
     return HXR_OK;
 }
 
-
+#endif //_SYMBIAN
 STDMETHODIMP_( void )
 CHTTPFileObject::SetDestinationFile( const char *pFilename )
 {
@@ -7187,8 +7400,7 @@
             pTemp = new char[pCookie->GetSize()];
 
             // Create the final output buffer
-            pFinalBuf = new CHXBuffer();
-            pFinalBuf->AddRef();
+	    CreateBufferCCF(pFinalBuf, m_pContext);
 
             pFinalBuf->SetSize(pCookie->GetSize());
             pFinal = (char*)pFinalBuf->GetBuffer();
@@ -7304,8 +7516,7 @@
         if (*pInput != '!')
         {
             // Copy the real domain into a new buffer
-            pDomain = new CHXBuffer();
-            pDomain->AddRef();
+	    CreateBufferCCF(pDomain, m_pContext);
 
             pDomain->SetSize(ulCookieLen);
             pData = (char*)pDomain->GetBuffer();
@@ -7359,8 +7570,7 @@
                             pInput += 5;
 
                             // Copy the real path into a new buffer
-                            pPath = new CHXBuffer();
-                            pPath->AddRef();
+			    CreateBufferCCF(pPath, m_pContext);
 
                             pPath->SetSize(ulCookieLen);
                             pData = (char*)pPath->GetBuffer();
@@ -7776,7 +7986,9 @@
 
         if (m_pCacheEntry)
         {
+#if !defined _SYMBIAN        
             CacheSupport_ReadDone();
+#endif            
         }
 
         // Saving a copy of the file if appropriate
@@ -8020,8 +8232,14 @@
         //
         if (ulLength >= m_ulMinStartupLengthNeeded)
         {
+#if !defined HELIX_FEATURE_SERVER
             pMessage = (HTTPResponseMessage*) Parser.parse((const char*) szHeader,
                                                            ulHeaderLength);
+#else
+            BOOL bMsgTooLarge = FALSE;
+            pMessage = (HTTPResponseMessage*) Parser.parse((const char*) szHeader,
+                                                           ulHeaderLength, \
bMsgTooLarge); +#endif /* !HELIX_FEATURE_SERVER */
         }
 
         if (pMessage &&
@@ -8089,16 +8307,16 @@
                         pResponseHeaders->AddKeyValue(pHeader->name(),pTmpBuffer);
 
                         // Disable http 1.1 support if the server explicitly says to
-                        if (!strcmpi(pHeader->name(), "Accept-Ranges"))
+                        if (!stricmp(pHeader->name(), "Accept-Ranges"))
                         {
-                            if (!strcmpi((const char*)pTmpBuffer->GetBuffer(), \
"none")) +                            if (!stricmp((const \
char*)pTmpBuffer->GetBuffer(), "none"))  {
                                 bNotAcceptRanges = TRUE;
                             }
                         }
-                        else if (!strcmpi(pHeader->name(), "Server"))
+                        else if (!stricmp(pHeader->name(), "Server"))
                         {
-                            if (!strcmpi((const char*)pTmpBuffer->GetBuffer(), \
REALSERVER_RESPONSE_NAME)) +                            if (!stricmp((const \
char*)pTmpBuffer->GetBuffer(), REALSERVER_RESPONSE_NAME))  {
                                 bRealServer = TRUE;
                             }
@@ -8635,6 +8853,27 @@
     return theErr;
 }
 
+unsigned long
+CHTTPFileObject::GetMaxChunkSizeAccepted()
+{
+    INT32 max = LARGEST_CHUNK_SIZE_WE_ACCEPT;
+    if (m_pRegistry)
+    {
+        if (HXR_OK != m_pRegistry->GetIntByName(
+                LARGEST_CHUNK_SIZE_WE_ACCEPT_CONFIG_KEY, max))
+        {
+            max = LARGEST_CHUNK_SIZE_WE_ACCEPT;
+        }
+
+        if (max < 0)
+        {
+          max = LARGEST_CHUNK_SIZE_WE_ACCEPT;
+        }
+    }
+
+    return max;
+}
+
 #ifdef HELIX_FEATURE_HTTPFSYS_MEM_GROWTH_LIMIT
 
 HX_RESULT

Index: httpfsys.h
===================================================================
RCS file: /cvsroot/filesystem/http/httpfsys.h,v
retrieving revision 1.34
diff -w -u -b -r1.34 httpfsys.h
@@ -60,8 +60,10 @@
 #include "hxauto.h"
 #include "hxpac.h"
 #include "hxnet.h"
-
+#include "hxplugncompat.h"
 #include "miscsp.h"
+#include "hxthread.h"   // HXMutex
+#include "baseobj.h"
 
 
 /* forward decl. */
@@ -103,10 +105,12 @@
 #define DEFAULT_CHUNK_SIZE 1024 //default size of chunk buffer
 
 #ifdef HELIX_FEATURE_HTTPFSYS_MEM_GROWTH_LIMIT
-
-#define CHUNK_RES_MEM_FLOOR     512000  //512 KB
-#define CHUNK_RES_MEM_CEILING   1000000 // 1MB
-
+# if !defined(CHUNK_RES_MEM_FLOOR)
+#   define CHUNK_RES_MEM_FLOOR     512000
+# endif
+# if !defined(CHUNK_RES_MEM_CEILING)
+#   define CHUNK_RES_MEM_CEILING   1000000
+# endif
 #endif //HELIX_HTTPFSYS_MEM_GROWTH_LIMIT
 
 typedef enum
@@ -121,6 +125,7 @@
 {
     unsigned long    size;
     unsigned long    read;
+    unsigned long    maxChunkSizeAccepted;
     HXBOOL             lastchunk;
     CEState          state;
     char*            buf;
@@ -133,7 +138,7 @@
 public:
     CChunkyResMap();
     virtual ~CChunkyResMap();
-    CChunkyRes* GetChunkyResForURL(const char* pURL, void* pCursorOwner);
+    CChunkyRes* GetChunkyResForURL(const char* pURL, void* pCursorOwner, IUnknown* \
pContext);  void RelinquishChunkyRes(CChunkyRes* pChunkyRes, void* pCursorOwner);
 
 private:
@@ -156,7 +161,9 @@
 class CHTTPFileSystem : public CUnknownIMP,
                        public IHXPlugin,
                        public IHXFileSystemObject,
+#if !defined(_SYMBIAN)                       
                        public IHXFileSystemCache,
+#endif                       
                        public IHXHTTPAutoStream
 {
     DECLARE_UNKNOWN(CHTTPFileSystem)
@@ -222,11 +229,12 @@
 
     STDMETHOD(CreateDir)        (THIS_
                                 IUnknown**     /*OUT*/     ppDirObject);
-
+#if !defined(_SYMBIAN)
     // IHXFileSystemCache methods...
     STDMETHOD (RefreshCache) (THIS);
     STDMETHOD (EmptyCache) (THIS);
     STDMETHOD (MoveCache) (THIS_ const char *path);
+#endif    
 
     // IHXHTTPAutoStream methods...
     STDMETHOD_( void, SetDestinationFile) ( THIS_ const char *pFilename );
@@ -235,15 +243,19 @@
 private:
     IUnknown*                   m_pContext;
     IHXValues*                  m_pOptions;
-    static const char*          zm_pDescription;
-    static const char*          zm_pCopyright;
-    static const char*          zm_pMoreInfoURL;
-    static const char*          zm_pShortName;
-    static const char*          zm_pProtocol;
-
+    static const char* const         zm_pDescription;
+    static const char* const         zm_pCopyright;
+    static const char* const         zm_pMoreInfoURL;
+    static const char* const        zm_pShortName;
+    static const char* const         zm_pProtocol;
+#if !defined(_SYMBIAN)
     // Autostreaming support
     static HXBOOL                 m_bSaveNextStream;
     static CHXString            m_SaveFileName;
+#else    
+    HXBOOL                 m_bSaveNextStream;
+	CHXString            m_SaveFileName;
+#endif	
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -536,7 +548,7 @@
         HX_RESULT   HX_RESULTStatus,
         IHXRequest* pIHXRequestResponse
     );
-
+#if !defined(_SYMBIAN)
     // Support for cache
     STDMETHOD_ (IHXBuffer*, CreateBufferFromValues)     (THIS_ IHXValues /*IN*/ \
                *pHeaderValues);
     STDMETHOD_ (IHXValues*, CreateValuesFromBuffer)     (THIS_ IHXBuffer *pBuffer);
@@ -545,7 +557,7 @@
     STDMETHOD_ (void,        CacheSupport_ReadDone)      (THIS);
     STDMETHOD_ (void,        CacheSupport_HandleSuccess) (THIS_ HTTPResponseMessage* \
                pMessage);
     STDMETHOD  (ProcessCacheCompletions)                 (THIS_ HXBOOL bRedirected);
-
+#endif
     // Support for autostreaming
     STDMETHOD_( void, SetDestinationFile) ( THIS_ const char *pFilename );
 
@@ -667,6 +679,9 @@
     HX_RESULT       HandleSocketRead(HX_RESULT status, IHXBuffer* pBuffer);
     HX_RESULT       HandleHeaderRead(IHXBuffer* pBuffer);
 
+    // MemCache handling
+    HXBOOL	    IsMemCacheFull(void);
+    HXBOOL	    TrimMemCacheIfNeeded(void);
 
     // Error reporting
     void            ReportDNSFailure        ();
@@ -683,6 +698,8 @@
 				 UINT32 ulMetaDataSegmentSize,
 				 UINT32 ulMetaDataSegmentReach,
 				 UINT32 ulMetaDataSize);
+
+    unsigned long   GetMaxChunkSizeAccepted();
     HX_RESULT       DecodeChunkedEncoding(HTTPChunkedEncoding*& pChunkedEncoding,
                                           const char*           pChunk,
                                           int                   l);
@@ -691,6 +708,7 @@
 
     friend class HTTPFileObjCallback;
     friend class HTTPTCPResponse;
+    friend class CChunkyResMap;
 
     HX_RESULT                   m_LastError;
 
@@ -733,6 +751,9 @@
 
     HXBOOL                        m_bTCPReadPending;
     HTTPTCPResponse*            m_pTCPResponse;
+#if defined(_SYMBIAN)    
+    CChunkyResMap*            m_pChunkyResMap;
+#endif    
 
     char*                       m_szBaseURL;
 
@@ -767,6 +788,10 @@
     ULONG32                     m_ulCurrentReadPosition;
     UINT32                      m_ulLastKnownEndOfValidContiguousRange;
 
+    UINT32			m_ulMemCacheSize;
+    UINT32			m_ulMemCacheContigLengthTrimThreshold;
+    UINT32			m_ulMemCacheTrimSize;
+
 #if defined(HELIX_FEATURE_HTTP_GZIP)
     CDecoder*                   m_pDecoder;
 #else
@@ -786,7 +811,6 @@
 
     CHXSimpleList               m_PendingReadList;
     CHXSimpleList               m_PreProcessedReadBuffers;
-    static CHXSimpleList        zm_pList;
 
     int                         m_nPort;
 
@@ -851,6 +875,7 @@
 
     HXBOOL                        m_bKnowContentSize;
     ULONG32                     m_nContentSize;
+    ULONG32                     m_nOriginalContentSize;
     HXBOOL                        m_bEncoded;
 
     HXBOOL                        m_bChunkedEncoding;

Index: pub/http_debug.h
===================================================================
RCS file: /cvsroot/filesystem/http/pub/http_debug.h,v
retrieving revision 1.5
diff -w -u -b -r1.5 http_debug.h
@@ -50,6 +50,7 @@
 #undef  NULLOK
 #define NULLOK(x)     ((x) ? (x) : "Null")
 
+#if !defined(_SYMBIAN)
 #include "hlxclib/time.h"
 
 #if defined(_UNIX) || defined (_MACINTOSH) || defined(__TCS__)
@@ -64,8 +65,8 @@
                                     (x)->tv_sec = time(NULL); \
                                     (x)->tv_usec = stTime.wMilliseconds * 1000
 #endif
-
-#if defined(DEBUG) && defined(ENABLE_LOGGING) && !defined(_OPENWAVE)
+#endif //_SYMBIAN
+#if defined(DEBUG) && defined(ENABLE_LOGGING) && !defined(_OPENWAVE) && \
!defined(_SYMBIAN)  #  include "hlxclib/fcntl.h"
 
    static FILE*           g_fileLog  = NULL;

Index: fileio/chunkres.cpp
===================================================================
RCS file: /cvsroot/common/fileio/chunkres.cpp,v
retrieving revision 1.24
diff -w -u -b -r1.24 chunkres.cpp
@@ -570,12 +570,6 @@
 	
 	if (pChunk)
 	{
-	    ULONG32 ulTempOffset = pChunk->GetTempFileOffset();
-	    if (ulTempOffset)
-	    {
-		m_FreeDiskOffsets.AddHead((void*)ulTempOffset);
-	    }
-	    
 	    delete pChunk;
 	    m_Chunks[ulWhichChunk] = NULL;
 	}
@@ -584,6 +578,76 @@
     return theErr;
 }
 
+/////////////////////////////////////////////////////////////////////////////
+//
+//	Method:
+//
+//		CChunkyRes::TouchRange(ULONG32 offset, ULONG32 count)
+//
+//	Purpose:
+//
+//		Touches the specified range of the file thus making the
+//	the range most recently used.  The end of the range is
+//	is made more recently used over the start of the range.
+//
+//	Parameters:
+//		The location and length of the range to be touched.
+//
+//
+void CChunkyRes::TouchRange(ULONG32 ulOffset, ULONG32 ulCount)
+{
+    ULONG32 ulFirstChunk = ulOffset / DEF_CHUNKYRES_CHUNK_SIZE;
+    ULONG32 ulLastChunk  = (ulOffset + ulCount) / DEF_CHUNKYRES_CHUNK_SIZE;
+    ULONG32 ulWhichChunk;
+    
+    if (ulCount == 0)
+    {
+	return;
+    }
+    
+    if (((ulOffset + ulCount) % DEF_CHUNKYRES_CHUNK_SIZE) == 0)
+    {
+	ulLastChunk--;
+    }
+    
+    // Easier to deal with count than index
+    ulLastChunk++;
+    
+    Lock();
+    
+    if (m_Chunks.GetSize() < ulLastChunk)
+    {
+	ulLastChunk = m_Chunks.GetSize();
+    }
+    
+    for (ulWhichChunk = ulFirstChunk; ulWhichChunk < ulLastChunk; ulWhichChunk++)
+    {
+	CChunkyResChunk* pChunk = (CChunkyResChunk*) m_Chunks[ulWhichChunk];
+	
+	if (pChunk)
+	{
+	    LISTPOSITION pos = m_ChunksMemoryMRU->Find(pChunk);
+	    
+	    if (pos)
+	    {
+		// Move the chunk in range to the front of the List 
+		m_ChunksMemoryMRU->RemoveAt(pos);		    
+		m_ChunksMemoryMRU->AddHead(pChunk);
+	    }
+	    else
+	    {
+		pos = m_ChunksDiskMRU->Find(pChunk);
+		if (pos)
+		{
+		    // Move to memory will move to the front of memory MRU list
+		    pChunk->MakeSureChunkIsInMemory();
+		}
+	    }
+	}
+    }
+		
+    Unlock();
+}
 
 /////////////////////////////////////////////////////////////////////////////
 //
@@ -757,22 +821,18 @@
 	if (m_bDiscardUsedData)
 	{
 		nLastChunk = (int)(m_ulUsedBytes/DEF_CHUNKYRES_CHUNK_SIZE);
-		for (ndx = m_ulFirstChunkIdx; ndx < nLastChunk - 1; ndx++)
+		for (ndx = ((int) m_ulFirstChunkIdx); ndx < nLastChunk - 1; ndx++)
 		{
 			CChunkyResChunk* pChunk = (CChunkyResChunk*)m_Chunks[ndx];
-			HX_ASSERT_VALID_PTR(pChunk);
 
-			UINT32 ulTempOffset = pChunk->GetTempFileOffset();
-			pChunk->DiscardDiskData();
+			if (pChunk)
+			{
+			    delete pChunk;
+			    m_Chunks[ndx] = NULL;
+			}
 
 			// Increment the first valid chunk index
 			m_ulFirstChunkIdx++;
-
-			if (ulTempOffset)
-			{
-			    // Add the disk space to the free space list
-			    m_FreeDiskOffsets.AddHead((void*)ulTempOffset);
-			}
 		}
 	}
 
@@ -881,6 +941,11 @@
 	ULONG32 chunkCount  = count;
 	ULONG32 baseOffset  = 0;
 
+	if (nFirstChunk < m_ulFirstChunkIdx)
+	{
+	    m_ulFirstChunkIdx = nFirstChunk;
+	}
+
 	for (int ndx = nFirstChunk; ndx <= nLastChunk; ndx++)
 	{
 		CChunkyResChunk* pChunk = (CChunkyResChunk*)m_Chunks[ndx];
@@ -935,18 +1000,28 @@
 			CChunkyResChunk* pChunk = (CChunkyResChunk*)m_ChunksMemoryMRU->GetTail();
 			HX_ASSERT_VALID_PTR(pChunk);
 
+			if (pChunk)
+			{
+			    if (m_bDisableDiskIO)
+			    {
+				pChunk->DiscardDiskData();
+			    }
+			    else
+			    {
 			// Discount its usage.
 			m_CurMemUsage -= pChunk->GetSize();
 
-			// Spill this chunk to disk...
-			pChunk->SpillToDisk();
-
 			// Remove the chunk from the end of the Memory MRU
 			m_ChunksMemoryMRU->RemoveTail();
 
+				// Spill this chunk to disk...
+				pChunk->SpillToDisk();
+
 			// And add the chunk to the front of the Disk MRU
 			m_ChunksDiskMRU->AddHead(pChunk);
 		}
+			}
+		}
 
 		// How can this be?!?! Did you really mean to set the memory usage such
 		// that there are no chunks in memory?!?
@@ -1080,7 +1155,7 @@
 	, m_strTempFileName()
 	, m_ulNextTempFileChunk(DEF_START_CHUNK_OFFSET)
 	, m_bHasBeenOpened(FALSE)
-	, m_bDisableDiskIO(FALSE)
+	, m_bDisableDiskIO(TRUE)
 	, m_bDiscardUsedData(FALSE)
 	, m_ulFirstChunkIdx(0)
 	, m_ulUsedBytes(0)
@@ -1307,6 +1382,7 @@
 				&& offset <= pRange->offset + pRange->length)
 			{
 			    ulValidLength = pRange->offset + pRange->length - offset;
+			    break;  // Once we find the encompasing range - there will be no more
 			}
 		}
 		while (rangePos);
@@ -1998,7 +2074,10 @@
 
 	if (posDisk)
 	{
+		ULONG32 ulTempOffset = GetTempFileOffset();
+		
 		m_pChunkRes->m_ChunksDiskMRU->RemoveAt(posDisk);
+		m_pChunkRes->m_FreeDiskOffsets.AddHead((void*) ulTempOffset);
 	}
 
 	// Reset a bunch of our members in case someone tries

Index: fileio/pub/chunkres.h
===================================================================
RCS file: /cvsroot/common/fileio/pub/chunkres.h,v
retrieving revision 1.8
diff -w -u -b -r1.8 chunkres.h
@@ -98,10 +98,13 @@
 
 //#define DEF_CHUNKYRES_MEM_THRESHOLD		0x00008000		//  32 KB
 //#define DEF_CHUNKYRES_MEM_THRESHOLD		0x00080000		// 512 KB
+#if defined(HELIX_FEATURE_MIN_HEAP)
 #define DEF_CHUNKYRES_MEM_THRESHOLD			0x00040000		// 256 KB
-
-//#define DEF_CHUNKYRES_CHUNK_SIZE			0x00002000		//   8 KB
 #define DEF_CHUNKYRES_CHUNK_SIZE			0x00008000		//  32 KB
+#else	// HELIX_FEATURE_MIN_HEAP
+#define DEF_CHUNKYRES_MEM_THRESHOLD			0x00400000		//   4 MB
+#define DEF_CHUNKYRES_CHUNK_SIZE			0x00010000		//  64 KB
+#endif	// HELIX_FEATURE_MIN_HEAP
 
 ///////////////////////////////////////////////////////////////
 //
@@ -219,6 +222,7 @@
 	void				DisableDiskIO	() { m_bDisableDiskIO = TRUE; };
 	void				DiscardUsedData	() { m_bDiscardUsedData = TRUE; };
 	HX_RESULT			DiscardRange( ULONG32 offset, ULONG32 count );
+	void				TouchRange(ULONG32 ulOffset, ULONG32 ulCount);
 	ULONG32				GetDiskUsage() const;
     ULONG32             GetCurrentMemoryUsage() const;
 	HX_RESULT			GetData

Index: include/hxresult.h
===================================================================
RCS file: /cvsroot/common/include/hxresult.h,v
retrieving revision 1.37.2.9
diff -w -u -b -r1.37.2.9 hxresult.h
@@ -252,6 +252,7 @@
 #define HXR_FULL_DOWNLOAD_NEEDED        MAKE_HX_RESULT(1,SS_FIL,20)                 \
// 80040094  #define \
HXR_PROGRESSIVE_DOWNLOAD_TIMEOUT	MAKE_HX_RESULT(1,SS_FIL,21)					// 80040095  #define \
HXR_ADVISE_LOCAL_ACCESS         MAKE_HX_RESULT(0,SS_FIL,22)                 // \
00040096 +#define HXR_ADVISE_NETWORK_ACCESS	MAKE_HX_RESULT(0,SS_FIL,23)               \
// 00040097  
 #define HXR_BAD_SERVER                  MAKE_HX_RESULT(1,SS_PRT,0)                  \
// 800400c0  #define HXR_ADVANCED_SERVER             MAKE_HX_RESULT(1,SS_PRT,1)       \
// 800400c1


["210changes.zip" (application/x-zip-compressed)]

_______________________________________________
Filesystem-dev mailing list
Filesystem-dev@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/filesystem-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic