webengine/osswebengine/WebCore/platform/network/symbian/HttpSessionManager.cpp
branchRCL_3
changeset 49 919f36ff910f
parent 48 79859ed3eea9
child 50 d96eed154187
--- a/webengine/osswebengine/WebCore/platform/network/symbian/HttpSessionManager.cpp	Tue Aug 31 16:17:46 2010 +0300
+++ b/webengine/osswebengine/WebCore/platform/network/symbian/HttpSessionManager.cpp	Wed Sep 01 12:28:30 2010 +0100
@@ -37,13 +37,18 @@
 #include "ResourceHandleManagerSymbian.h"
 #include "StaticObjectsContainer.h"
 #include "WebFrame.h"
-
+#include "ResourceHandleClient.h"
+#include <FeatMgr.h>
 // CONSTANTS
 _LIT8( KHttpProtString, "HTTP/TCP" );
 _LIT (KNullStr, "");
-
+const TInt KResetRetryFlagTimeOut = 5*1000*1000;
+TInt doResetFlag(TAny*);
 class MBrCtlSpecialLoadObserver;
-
+//FIXME: Below constant need to be properly set or removed after wk30 platform, since it will be defined by platform
+#define KFeatureIdBrowserGracefulSocketShutdown 361
+//Below is socket lingering timeout
+#define SOCKET_LINGERING_TIMEOUT 100000
 using namespace WebCore;
 
 HttpSessionManager::HttpSessionManager()
@@ -58,6 +63,9 @@
     m_httpDownload = NULL;
     m_SelfDownloadContentHandler = NULL;
     m_SelfDownloadContentTypes = KNullStr().Alloc();
+    retryConnectivityFlag = EFalse;
+    m_inSecConnection = EFalse;
+    m_resetTimer = NULL;
 }
 
 HttpSessionManager::~HttpSessionManager()
@@ -67,12 +75,19 @@
     delete m_ReqHdrManager;
     m_ReqHdrManager = NULL;
     delete m_cookieHandler;
+    m_cookieHandler = NULL;
     delete m_httpDownload;
     m_httpDownload = NULL;
     delete m_SelfDownloadContentHandler;
     m_SelfDownloadContentHandler = NULL;
     delete m_SelfDownloadContentTypes;
     m_SelfDownloadContentTypes = NULL;
+    if(m_resetTimer)
+        {
+        m_resetTimer->Cancel();
+        delete m_resetTimer;
+        m_resetTimer = NULL;
+        }
     m_ClientAcceptHeaders.ResetAndDestroy();
     m_ClientAcceptHeaders.Close();
     closeHttpSession();
@@ -87,11 +102,31 @@
         RStringPool strP = m_httpSession.StringPool();
         const TStringTable& stringTable = RHTTPSession::GetTable();
         RHTTPConnectionInfo connInfo = m_httpSession.ConnectionInfo();
-
-        // set shutdown
-        THTTPHdrVal immediateShutdown = strP.StringF( HTTP::ESocketShutdownImmediate, stringTable );
-        connInfo.SetPropertyL ( strP.StringF( HTTP::ESocketShutdownMode, stringTable ), immediateShutdown );
-
+        
+        TBool gracefulShutdown = false;
+        RStringF retStr;
+        TInt err( KErrNone );
+        
+#ifdef BRDO_OCC_ENABLED_FF 
+        FeatureManager::InitializeLibL();
+        gracefulShutdown = FeatureManager::FeatureSupported( KFeatureIdBrowserGracefulSocketShutdown );
+        FeatureManager::UnInitializeLib();
+        retStr = strP.StringF( HTTP::EHttpEnableOptimalPipelining + 3, stringTable );
+        
+#endif
+        
+        if( err == KErrNone && gracefulShutdown && retStr != RStringF())
+            {
+            //Property exists
+            THTTPHdrVal setValue(SOCKET_LINGERING_TIMEOUT);
+            connInfo.SetPropertyL ( strP.StringF( HTTP::EHttpEnableOptimalPipelining + 3, stringTable ), setValue );
+            }
+        else 
+            {
+            // set shutdown
+            THTTPHdrVal immediateShutdown = strP.StringF( HTTP::ESocketShutdownImmediate, stringTable );
+            connInfo.SetPropertyL ( strP.StringF( HTTP::ESocketShutdownMode, stringTable ), immediateShutdown );
+            }
         // set pipelining
         RStringF maxConnection = strP.StringF( HTTP::EMaxNumTransportHandlers , stringTable );
         connInfo.SetPropertyL( maxConnection, THTTPHdrVal( KHttpMaxConnectionNum ) );
@@ -120,6 +155,11 @@
 		THTTPHdrVal enableTranspHndlrPriority(strP.StringF(HTTP::EEnableTranspHndlrPriority, RHTTPSession::GetTable()));
 		connInfo.SetPropertyL(strP.StringF(HTTP::ETranspHndlrPriority, RHTTPSession::GetTable()), enableTranspHndlrPriority);
 
+#ifdef BRDO_MULTITOUCH_ENABLED_FF
+        RStringF strictHeaders = strP.StringF(HTTP::EEnableStrictConnectHeaders, RHTTPSession::GetTable());
+        connInfo.SetPropertyL(strP.StringF(HTTP::EStrictConnectHeaders, RHTTPSession::GetTable()), strictHeaders);
+#endif
+
         strP.OpenL( HttpFilterCommonStringsExt::GetTable() );
         strP.OpenL( HttpFilterCommonStringsExt::GetLanguageTable() );
         strP.OpenL( HttpFilterCommonStringsAddition::GetTable() );
@@ -139,7 +179,7 @@
             m_ReqHdrManager = HttpRequestHeaderManager::NewL(m_httpSession);
         }
         if (!m_cookieHandler) {
-            m_cookieHandler = CookieHandler::init();
+            m_cookieHandler = CookieHandler::init(m_httpSession.StringPool());
         }
     }
     updateFilters(true);
@@ -155,7 +195,11 @@
 HttpDownload* HttpSessionManager::httpDownload(bool aCreate)
 {
     if (!m_httpDownload && aCreate){
-        m_httpDownload = new HttpDownload(this);
+        TRAPD(err, m_httpDownload = HttpDownload::NewL(this));
+        if(err != KErrNone)
+           {
+		   m_httpDownload = NULL;
+           }
     }
     return m_httpDownload;
 }
@@ -168,6 +212,9 @@
         // disconnect the Dl Mgr
         if (m_httpDownload){
             m_httpDownload->disconnect();
+        if(m_cookieHandler)
+            m_cookieHandler->destroy();
+   
 		}
         m_httpSession.Close();
         m_sessionRunning = false;
@@ -252,6 +299,34 @@
         }
 }
 
+void HttpSessionManager::retryTransactions()
+{
+    Vector<HttpConnection *> requests;
+
+    if (m_sessionRunning)
+    {
+    TBool newConn = ETrue;
+    m_httpSession.ConnectionInfo().SetPropertyL(m_httpSession.StringPool().StringF(HttpFilterCommonStringsExt::EHttpNewConnFlag, HttpFilterCommonStringsExt::GetTable()), THTTPHdrVal((TBool)newConn));
+    }
+
+    for(HashMap<HttpConnection *, ResourceHandle *>::iterator tmpit = m_pendingHttpRequests.begin();
+        tmpit != m_pendingHttpRequests.end(); ++tmpit)
+        {
+                requests.append(tmpit->first);  
+        }
+    //Submit them again
+    for (int i=0; i<requests.size(); ++i)
+        {
+        if(requests[i]->HttpTransaction()) {
+             requests[i]->HttpTransaction()->SubmitL();
+        }
+        else {
+             removeRequest(requests[i]);
+        }
+                 
+        }
+}
+
 HttpConnection* HttpSessionManager::firstHttpConnection()
 {
     HashMap<HttpConnection *, ResourceHandle *>::const_iterator it = m_pendingHttpRequests.begin();
@@ -298,6 +373,7 @@
                                   const ResourceResponse& response, HttpConnection* connection)
 {
     RHTTPTransaction* connTransaction = connection->takeOwnershipHttpTransaction();
+    removeRequest(connection);
     WebFrame* webFrame = kit(connection->frame());
     if (!m_SelfDownloadContentHandler) {
         m_SelfDownloadContentHandler = SelfDownloadContentHandler::NewL(
@@ -309,6 +385,7 @@
 		!= KErrNotSupported) {
 		if (m_OutstandingSelfDl) {
 			// only one outstanding self download is supported
+            connTransaction->Close();
 			User::Leave(KErrCancel);
 		}
 		else {
@@ -456,4 +533,43 @@
     }
 }
 
+void HttpSessionManager::cancelQueuedTransactions()
+{
+    Vector<HttpConnection *> requests;
+    for(HashMap<HttpConnection *, ResourceHandle *>::iterator tmpit = m_pendingHttpRequests.begin();
+        tmpit != m_pendingHttpRequests.end(); ++tmpit)
+        {
+                requests.append(tmpit->first);  
+        }
+    
+    for (int i = 0; i < requests.size(); ++i) {
+        if(requests[i]->HttpTransaction()) {
+            requests[i]->HttpTransaction()->Cancel();
+        }
+    }
+}
+
+void HttpSessionManager::startTimer()
+{
+    if(m_resetTimer)
+        deleteTimer();
+    m_resetTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+    m_resetTimer->Start(KResetRetryFlagTimeOut,0,TCallBack(&doResetFlag,this));
+}
+
+void HttpSessionManager::deleteTimer()
+{
+    m_resetTimer->Cancel();
+    delete m_resetTimer;
+    m_resetTimer = NULL;
+}
+    
+TInt doResetFlag(TAny* ptr)
+{
+    HttpSessionManager* tmp = static_cast<HttpSessionManager*>(ptr);
+    tmp->unSetRetryConnectivityFlag();
+    tmp->deleteTimer();  
+    return EFalse;
+}
+
 // end of file