35 #include "SelfDownloadContentHandler.h" |
35 #include "SelfDownloadContentHandler.h" |
36 #include "BrCtl.h" |
36 #include "BrCtl.h" |
37 #include "ResourceHandleManagerSymbian.h" |
37 #include "ResourceHandleManagerSymbian.h" |
38 #include "StaticObjectsContainer.h" |
38 #include "StaticObjectsContainer.h" |
39 #include "WebFrame.h" |
39 #include "WebFrame.h" |
40 |
40 #include "ResourceHandleClient.h" |
|
41 #include <FeatMgr.h> |
41 // CONSTANTS |
42 // CONSTANTS |
42 _LIT8( KHttpProtString, "HTTP/TCP" ); |
43 _LIT8( KHttpProtString, "HTTP/TCP" ); |
43 _LIT (KNullStr, ""); |
44 _LIT (KNullStr, ""); |
44 |
45 const TInt KResetRetryFlagTimeOut = 5*1000*1000; |
|
46 TInt doResetFlag(TAny*); |
45 class MBrCtlSpecialLoadObserver; |
47 class MBrCtlSpecialLoadObserver; |
46 |
48 //FIXME: Below constant need to be properly set or removed after wk30 platform, since it will be defined by platform |
|
49 #define KFeatureIdBrowserGracefulSocketShutdown 361 |
|
50 //Below is socket lingering timeout |
|
51 #define SOCKET_LINGERING_TIMEOUT 100000 |
47 using namespace WebCore; |
52 using namespace WebCore; |
48 |
53 |
49 HttpSessionManager::HttpSessionManager() |
54 HttpSessionManager::HttpSessionManager() |
50 { |
55 { |
51 m_sessionRunning = false; |
56 m_sessionRunning = false; |
56 m_ReqHdrManager = NULL; |
61 m_ReqHdrManager = NULL; |
57 m_cookieHandler = NULL; |
62 m_cookieHandler = NULL; |
58 m_httpDownload = NULL; |
63 m_httpDownload = NULL; |
59 m_SelfDownloadContentHandler = NULL; |
64 m_SelfDownloadContentHandler = NULL; |
60 m_SelfDownloadContentTypes = KNullStr().Alloc(); |
65 m_SelfDownloadContentTypes = KNullStr().Alloc(); |
|
66 retryConnectivityFlag = EFalse; |
|
67 m_inSecConnection = EFalse; |
|
68 m_resetTimer = NULL; |
61 } |
69 } |
62 |
70 |
63 HttpSessionManager::~HttpSessionManager() |
71 HttpSessionManager::~HttpSessionManager() |
64 { |
72 { |
65 delete m_cacheManager; |
73 delete m_cacheManager; |
66 m_cacheManager = NULL; |
74 m_cacheManager = NULL; |
67 delete m_ReqHdrManager; |
75 delete m_ReqHdrManager; |
68 m_ReqHdrManager = NULL; |
76 m_ReqHdrManager = NULL; |
69 delete m_cookieHandler; |
77 delete m_cookieHandler; |
|
78 m_cookieHandler = NULL; |
70 delete m_httpDownload; |
79 delete m_httpDownload; |
71 m_httpDownload = NULL; |
80 m_httpDownload = NULL; |
72 delete m_SelfDownloadContentHandler; |
81 delete m_SelfDownloadContentHandler; |
73 m_SelfDownloadContentHandler = NULL; |
82 m_SelfDownloadContentHandler = NULL; |
74 delete m_SelfDownloadContentTypes; |
83 delete m_SelfDownloadContentTypes; |
75 m_SelfDownloadContentTypes = NULL; |
84 m_SelfDownloadContentTypes = NULL; |
|
85 if(m_resetTimer) |
|
86 { |
|
87 m_resetTimer->Cancel(); |
|
88 delete m_resetTimer; |
|
89 m_resetTimer = NULL; |
|
90 } |
76 m_ClientAcceptHeaders.ResetAndDestroy(); |
91 m_ClientAcceptHeaders.ResetAndDestroy(); |
77 m_ClientAcceptHeaders.Close(); |
92 m_ClientAcceptHeaders.Close(); |
78 closeHttpSession(); |
93 closeHttpSession(); |
79 } |
94 } |
80 |
95 |
85 m_sessionRunning = true; |
100 m_sessionRunning = true; |
86 // get the connection info |
101 // get the connection info |
87 RStringPool strP = m_httpSession.StringPool(); |
102 RStringPool strP = m_httpSession.StringPool(); |
88 const TStringTable& stringTable = RHTTPSession::GetTable(); |
103 const TStringTable& stringTable = RHTTPSession::GetTable(); |
89 RHTTPConnectionInfo connInfo = m_httpSession.ConnectionInfo(); |
104 RHTTPConnectionInfo connInfo = m_httpSession.ConnectionInfo(); |
90 |
105 |
91 // set shutdown |
106 TBool gracefulShutdown = false; |
92 THTTPHdrVal immediateShutdown = strP.StringF( HTTP::ESocketShutdownImmediate, stringTable ); |
107 RStringF retStr; |
93 connInfo.SetPropertyL ( strP.StringF( HTTP::ESocketShutdownMode, stringTable ), immediateShutdown ); |
108 TInt err( KErrNone ); |
94 |
109 |
|
110 #ifdef BRDO_OCC_ENABLED_FF |
|
111 FeatureManager::InitializeLibL(); |
|
112 gracefulShutdown = FeatureManager::FeatureSupported( KFeatureIdBrowserGracefulSocketShutdown ); |
|
113 FeatureManager::UnInitializeLib(); |
|
114 retStr = strP.StringF( HTTP::EHttpEnableOptimalPipelining + 3, stringTable ); |
|
115 |
|
116 #endif |
|
117 |
|
118 if( err == KErrNone && gracefulShutdown && retStr != RStringF()) |
|
119 { |
|
120 //Property exists |
|
121 THTTPHdrVal setValue(SOCKET_LINGERING_TIMEOUT); |
|
122 connInfo.SetPropertyL ( strP.StringF( HTTP::EHttpEnableOptimalPipelining + 3, stringTable ), setValue ); |
|
123 } |
|
124 else |
|
125 { |
|
126 // set shutdown |
|
127 THTTPHdrVal immediateShutdown = strP.StringF( HTTP::ESocketShutdownImmediate, stringTable ); |
|
128 connInfo.SetPropertyL ( strP.StringF( HTTP::ESocketShutdownMode, stringTable ), immediateShutdown ); |
|
129 } |
95 // set pipelining |
130 // set pipelining |
96 RStringF maxConnection = strP.StringF( HTTP::EMaxNumTransportHandlers , stringTable ); |
131 RStringF maxConnection = strP.StringF( HTTP::EMaxNumTransportHandlers , stringTable ); |
97 connInfo.SetPropertyL( maxConnection, THTTPHdrVal( KHttpMaxConnectionNum ) ); |
132 connInfo.SetPropertyL( maxConnection, THTTPHdrVal( KHttpMaxConnectionNum ) ); |
98 |
133 |
99 RStringF maxToPipeline = strP.StringF(HTTP::EMaxNumTransactionsToPipeline, stringTable ); |
134 RStringF maxToPipeline = strP.StringF(HTTP::EMaxNumTransactionsToPipeline, stringTable ); |
118 |
153 |
119 //set HTTP socket prioritis to high |
154 //set HTTP socket prioritis to high |
120 THTTPHdrVal enableTranspHndlrPriority(strP.StringF(HTTP::EEnableTranspHndlrPriority, RHTTPSession::GetTable())); |
155 THTTPHdrVal enableTranspHndlrPriority(strP.StringF(HTTP::EEnableTranspHndlrPriority, RHTTPSession::GetTable())); |
121 connInfo.SetPropertyL(strP.StringF(HTTP::ETranspHndlrPriority, RHTTPSession::GetTable()), enableTranspHndlrPriority); |
156 connInfo.SetPropertyL(strP.StringF(HTTP::ETranspHndlrPriority, RHTTPSession::GetTable()), enableTranspHndlrPriority); |
122 |
157 |
|
158 #ifdef BRDO_MULTITOUCH_ENABLED_FF |
|
159 RStringF strictHeaders = strP.StringF(HTTP::EEnableStrictConnectHeaders, RHTTPSession::GetTable()); |
|
160 connInfo.SetPropertyL(strP.StringF(HTTP::EStrictConnectHeaders, RHTTPSession::GetTable()), strictHeaders); |
|
161 #endif |
|
162 |
123 strP.OpenL( HttpFilterCommonStringsExt::GetTable() ); |
163 strP.OpenL( HttpFilterCommonStringsExt::GetTable() ); |
124 strP.OpenL( HttpFilterCommonStringsExt::GetLanguageTable() ); |
164 strP.OpenL( HttpFilterCommonStringsExt::GetLanguageTable() ); |
125 strP.OpenL( HttpFilterCommonStringsAddition::GetTable() ); |
165 strP.OpenL( HttpFilterCommonStringsAddition::GetTable() ); |
126 |
166 |
127 CHttpFilterAuthenticationInterface::InstallFilterL( m_httpSession, true ); |
167 CHttpFilterAuthenticationInterface::InstallFilterL( m_httpSession, true ); |
137 // http request header manager |
177 // http request header manager |
138 if (!m_ReqHdrManager) { |
178 if (!m_ReqHdrManager) { |
139 m_ReqHdrManager = HttpRequestHeaderManager::NewL(m_httpSession); |
179 m_ReqHdrManager = HttpRequestHeaderManager::NewL(m_httpSession); |
140 } |
180 } |
141 if (!m_cookieHandler) { |
181 if (!m_cookieHandler) { |
142 m_cookieHandler = CookieHandler::init(); |
182 m_cookieHandler = CookieHandler::init(m_httpSession.StringPool()); |
143 } |
183 } |
144 } |
184 } |
145 updateFilters(true); |
185 updateFilters(true); |
146 } |
186 } |
147 |
187 |
153 } |
193 } |
154 |
194 |
155 HttpDownload* HttpSessionManager::httpDownload(bool aCreate) |
195 HttpDownload* HttpSessionManager::httpDownload(bool aCreate) |
156 { |
196 { |
157 if (!m_httpDownload && aCreate){ |
197 if (!m_httpDownload && aCreate){ |
158 m_httpDownload = new HttpDownload(this); |
198 TRAPD(err, m_httpDownload = HttpDownload::NewL(this)); |
|
199 if(err != KErrNone) |
|
200 { |
|
201 m_httpDownload = NULL; |
|
202 } |
159 } |
203 } |
160 return m_httpDownload; |
204 return m_httpDownload; |
161 } |
205 } |
162 |
206 |
163 void HttpSessionManager::closeHttpSession() |
207 void HttpSessionManager::closeHttpSession() |
166 this->handleError(KErrCancel); |
210 this->handleError(KErrCancel); |
167 |
211 |
168 // disconnect the Dl Mgr |
212 // disconnect the Dl Mgr |
169 if (m_httpDownload){ |
213 if (m_httpDownload){ |
170 m_httpDownload->disconnect(); |
214 m_httpDownload->disconnect(); |
|
215 if(m_cookieHandler) |
|
216 m_cookieHandler->destroy(); |
|
217 |
171 } |
218 } |
172 m_httpSession.Close(); |
219 m_httpSession.Close(); |
173 m_sessionRunning = false; |
220 m_sessionRunning = false; |
174 |
221 |
175 delete m_ReqHdrManager; |
222 delete m_ReqHdrManager; |
250 { |
297 { |
251 requests[i]->handleError(error); |
298 requests[i]->handleError(error); |
252 } |
299 } |
253 } |
300 } |
254 |
301 |
|
302 void HttpSessionManager::retryTransactions() |
|
303 { |
|
304 Vector<HttpConnection *> requests; |
|
305 |
|
306 if (m_sessionRunning) |
|
307 { |
|
308 TBool newConn = ETrue; |
|
309 m_httpSession.ConnectionInfo().SetPropertyL(m_httpSession.StringPool().StringF(HttpFilterCommonStringsExt::EHttpNewConnFlag, HttpFilterCommonStringsExt::GetTable()), THTTPHdrVal((TBool)newConn)); |
|
310 } |
|
311 |
|
312 for(HashMap<HttpConnection *, ResourceHandle *>::iterator tmpit = m_pendingHttpRequests.begin(); |
|
313 tmpit != m_pendingHttpRequests.end(); ++tmpit) |
|
314 { |
|
315 requests.append(tmpit->first); |
|
316 } |
|
317 //Submit them again |
|
318 for (int i=0; i<requests.size(); ++i) |
|
319 { |
|
320 if(requests[i]->HttpTransaction()) { |
|
321 requests[i]->HttpTransaction()->SubmitL(); |
|
322 } |
|
323 else { |
|
324 removeRequest(requests[i]); |
|
325 } |
|
326 |
|
327 } |
|
328 } |
|
329 |
255 HttpConnection* HttpSessionManager::firstHttpConnection() |
330 HttpConnection* HttpSessionManager::firstHttpConnection() |
256 { |
331 { |
257 HashMap<HttpConnection *, ResourceHandle *>::const_iterator it = m_pendingHttpRequests.begin(); |
332 HashMap<HttpConnection *, ResourceHandle *>::const_iterator it = m_pendingHttpRequests.begin(); |
258 return it->first; |
333 return it->first; |
259 } |
334 } |
296 |
371 |
297 void HttpSessionManager::downloadL(ResourceHandle* handle, const ResourceRequest& request, |
372 void HttpSessionManager::downloadL(ResourceHandle* handle, const ResourceRequest& request, |
298 const ResourceResponse& response, HttpConnection* connection) |
373 const ResourceResponse& response, HttpConnection* connection) |
299 { |
374 { |
300 RHTTPTransaction* connTransaction = connection->takeOwnershipHttpTransaction(); |
375 RHTTPTransaction* connTransaction = connection->takeOwnershipHttpTransaction(); |
|
376 removeRequest(connection); |
301 WebFrame* webFrame = kit(connection->frame()); |
377 WebFrame* webFrame = kit(connection->frame()); |
302 if (!m_SelfDownloadContentHandler) { |
378 if (!m_SelfDownloadContentHandler) { |
303 m_SelfDownloadContentHandler = SelfDownloadContentHandler::NewL( |
379 m_SelfDownloadContentHandler = SelfDownloadContentHandler::NewL( |
304 webFrame, *m_SelfDownloadContentTypes); |
380 webFrame, *m_SelfDownloadContentTypes); |
305 } else { //m_SpecialLoadObserver in static object m_SelfDownloadContentHandler has to reinitialize |
381 } else { //m_SpecialLoadObserver in static object m_SelfDownloadContentHandler has to reinitialize |
307 } |
383 } |
308 if(m_SelfDownloadContentHandler->IsSupported(request, response, *connTransaction) |
384 if(m_SelfDownloadContentHandler->IsSupported(request, response, *connTransaction) |
309 != KErrNotSupported) { |
385 != KErrNotSupported) { |
310 if (m_OutstandingSelfDl) { |
386 if (m_OutstandingSelfDl) { |
311 // only one outstanding self download is supported |
387 // only one outstanding self download is supported |
|
388 connTransaction->Close(); |
312 User::Leave(KErrCancel); |
389 User::Leave(KErrCancel); |
313 } |
390 } |
314 else { |
391 else { |
315 m_OutstandingSelfDl = true; |
392 m_OutstandingSelfDl = true; |
316 m_SelfDownloadContentHandler->HandleResponseHeadersL(request, response, *connTransaction); |
393 m_SelfDownloadContentHandler->HandleResponseHeadersL(request, response, *connTransaction); |
454 } |
531 } |
455 CleanupStack::PopAndDestroy(); // url8 |
532 CleanupStack::PopAndDestroy(); // url8 |
456 } |
533 } |
457 } |
534 } |
458 |
535 |
|
536 void HttpSessionManager::cancelQueuedTransactions() |
|
537 { |
|
538 Vector<HttpConnection *> requests; |
|
539 for(HashMap<HttpConnection *, ResourceHandle *>::iterator tmpit = m_pendingHttpRequests.begin(); |
|
540 tmpit != m_pendingHttpRequests.end(); ++tmpit) |
|
541 { |
|
542 requests.append(tmpit->first); |
|
543 } |
|
544 |
|
545 for (int i = 0; i < requests.size(); ++i) { |
|
546 if(requests[i]->HttpTransaction()) { |
|
547 requests[i]->HttpTransaction()->Cancel(); |
|
548 } |
|
549 } |
|
550 } |
|
551 |
|
552 void HttpSessionManager::startTimer() |
|
553 { |
|
554 if(m_resetTimer) |
|
555 deleteTimer(); |
|
556 m_resetTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
557 m_resetTimer->Start(KResetRetryFlagTimeOut,0,TCallBack(&doResetFlag,this)); |
|
558 } |
|
559 |
|
560 void HttpSessionManager::deleteTimer() |
|
561 { |
|
562 m_resetTimer->Cancel(); |
|
563 delete m_resetTimer; |
|
564 m_resetTimer = NULL; |
|
565 } |
|
566 |
|
567 TInt doResetFlag(TAny* ptr) |
|
568 { |
|
569 HttpSessionManager* tmp = static_cast<HttpSessionManager*>(ptr); |
|
570 tmp->unSetRetryConnectivityFlag(); |
|
571 tmp->deleteTimer(); |
|
572 return EFalse; |
|
573 } |
|
574 |
459 // end of file |
575 // end of file |