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 #include "ResourceHandleClient.h" |
40 |
41 #include <FeatMgr.h> |
|
42 // CONSTANTS |
41 // CONSTANTS |
43 _LIT8( KHttpProtString, "HTTP/TCP" ); |
42 _LIT8( KHttpProtString, "HTTP/TCP" ); |
44 _LIT (KNullStr, ""); |
43 _LIT (KNullStr, ""); |
45 const TInt KResetRetryFlagTimeOut = 5*1000*1000; |
44 |
46 TInt doResetFlag(TAny*); |
|
47 class MBrCtlSpecialLoadObserver; |
45 class MBrCtlSpecialLoadObserver; |
48 //FIXME: Below constant need to be properly set or removed after wk30 platform, since it will be defined by platform |
46 |
49 #define KFeatureIdBrowserGracefulSocketShutdown 361 |
|
50 //Below is socket lingering timeout |
|
51 #define SOCKET_LINGERING_TIMEOUT 100000 |
|
52 using namespace WebCore; |
47 using namespace WebCore; |
53 |
48 |
54 HttpSessionManager::HttpSessionManager() |
49 HttpSessionManager::HttpSessionManager() |
55 { |
50 { |
56 m_sessionRunning = false; |
51 m_sessionRunning = false; |
61 m_ReqHdrManager = NULL; |
56 m_ReqHdrManager = NULL; |
62 m_cookieHandler = NULL; |
57 m_cookieHandler = NULL; |
63 m_httpDownload = NULL; |
58 m_httpDownload = NULL; |
64 m_SelfDownloadContentHandler = NULL; |
59 m_SelfDownloadContentHandler = NULL; |
65 m_SelfDownloadContentTypes = KNullStr().Alloc(); |
60 m_SelfDownloadContentTypes = KNullStr().Alloc(); |
66 retryConnectivityFlag = EFalse; |
|
67 m_inSecConnection = EFalse; |
|
68 m_resetTimer = NULL; |
|
69 } |
61 } |
70 |
62 |
71 HttpSessionManager::~HttpSessionManager() |
63 HttpSessionManager::~HttpSessionManager() |
72 { |
64 { |
73 delete m_cacheManager; |
65 delete m_cacheManager; |
74 m_cacheManager = NULL; |
66 m_cacheManager = NULL; |
75 delete m_ReqHdrManager; |
67 delete m_ReqHdrManager; |
76 m_ReqHdrManager = NULL; |
68 m_ReqHdrManager = NULL; |
77 delete m_cookieHandler; |
69 delete m_cookieHandler; |
78 m_cookieHandler = NULL; |
|
79 delete m_httpDownload; |
70 delete m_httpDownload; |
80 m_httpDownload = NULL; |
71 m_httpDownload = NULL; |
81 delete m_SelfDownloadContentHandler; |
72 delete m_SelfDownloadContentHandler; |
82 m_SelfDownloadContentHandler = NULL; |
73 m_SelfDownloadContentHandler = NULL; |
83 delete m_SelfDownloadContentTypes; |
74 delete m_SelfDownloadContentTypes; |
84 m_SelfDownloadContentTypes = NULL; |
75 m_SelfDownloadContentTypes = NULL; |
85 if(m_resetTimer) |
|
86 { |
|
87 m_resetTimer->Cancel(); |
|
88 delete m_resetTimer; |
|
89 m_resetTimer = NULL; |
|
90 } |
|
91 m_ClientAcceptHeaders.ResetAndDestroy(); |
76 m_ClientAcceptHeaders.ResetAndDestroy(); |
92 m_ClientAcceptHeaders.Close(); |
77 m_ClientAcceptHeaders.Close(); |
93 closeHttpSession(); |
78 closeHttpSession(); |
94 } |
79 } |
95 |
80 |
100 m_sessionRunning = true; |
85 m_sessionRunning = true; |
101 // get the connection info |
86 // get the connection info |
102 RStringPool strP = m_httpSession.StringPool(); |
87 RStringPool strP = m_httpSession.StringPool(); |
103 const TStringTable& stringTable = RHTTPSession::GetTable(); |
88 const TStringTable& stringTable = RHTTPSession::GetTable(); |
104 RHTTPConnectionInfo connInfo = m_httpSession.ConnectionInfo(); |
89 RHTTPConnectionInfo connInfo = m_httpSession.ConnectionInfo(); |
105 |
90 |
106 TBool gracefulShutdown = false; |
91 // set shutdown |
107 RStringF retStr; |
92 THTTPHdrVal immediateShutdown = strP.StringF( HTTP::ESocketShutdownImmediate, stringTable ); |
108 TInt err( KErrNone ); |
93 connInfo.SetPropertyL ( strP.StringF( HTTP::ESocketShutdownMode, stringTable ), immediateShutdown ); |
109 |
94 |
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 } |
|
130 // set pipelining |
95 // set pipelining |
131 RStringF maxConnection = strP.StringF( HTTP::EMaxNumTransportHandlers , stringTable ); |
96 RStringF maxConnection = strP.StringF( HTTP::EMaxNumTransportHandlers , stringTable ); |
132 connInfo.SetPropertyL( maxConnection, THTTPHdrVal( KHttpMaxConnectionNum ) ); |
97 connInfo.SetPropertyL( maxConnection, THTTPHdrVal( KHttpMaxConnectionNum ) ); |
133 |
98 |
134 RStringF maxToPipeline = strP.StringF(HTTP::EMaxNumTransactionsToPipeline, stringTable ); |
99 RStringF maxToPipeline = strP.StringF(HTTP::EMaxNumTransactionsToPipeline, stringTable ); |
153 |
118 |
154 //set HTTP socket prioritis to high |
119 //set HTTP socket prioritis to high |
155 THTTPHdrVal enableTranspHndlrPriority(strP.StringF(HTTP::EEnableTranspHndlrPriority, RHTTPSession::GetTable())); |
120 THTTPHdrVal enableTranspHndlrPriority(strP.StringF(HTTP::EEnableTranspHndlrPriority, RHTTPSession::GetTable())); |
156 connInfo.SetPropertyL(strP.StringF(HTTP::ETranspHndlrPriority, RHTTPSession::GetTable()), enableTranspHndlrPriority); |
121 connInfo.SetPropertyL(strP.StringF(HTTP::ETranspHndlrPriority, RHTTPSession::GetTable()), enableTranspHndlrPriority); |
157 |
122 |
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 |
|
163 strP.OpenL( HttpFilterCommonStringsExt::GetTable() ); |
123 strP.OpenL( HttpFilterCommonStringsExt::GetTable() ); |
164 strP.OpenL( HttpFilterCommonStringsExt::GetLanguageTable() ); |
124 strP.OpenL( HttpFilterCommonStringsExt::GetLanguageTable() ); |
165 strP.OpenL( HttpFilterCommonStringsAddition::GetTable() ); |
125 strP.OpenL( HttpFilterCommonStringsAddition::GetTable() ); |
166 |
126 |
167 CHttpFilterAuthenticationInterface::InstallFilterL( m_httpSession, true ); |
127 CHttpFilterAuthenticationInterface::InstallFilterL( m_httpSession, true ); |
177 // http request header manager |
137 // http request header manager |
178 if (!m_ReqHdrManager) { |
138 if (!m_ReqHdrManager) { |
179 m_ReqHdrManager = HttpRequestHeaderManager::NewL(m_httpSession); |
139 m_ReqHdrManager = HttpRequestHeaderManager::NewL(m_httpSession); |
180 } |
140 } |
181 if (!m_cookieHandler) { |
141 if (!m_cookieHandler) { |
182 m_cookieHandler = CookieHandler::init(m_httpSession.StringPool()); |
142 m_cookieHandler = CookieHandler::init(); |
183 } |
143 } |
184 } |
144 } |
185 updateFilters(true); |
145 updateFilters(true); |
186 } |
146 } |
187 |
147 |
193 } |
153 } |
194 |
154 |
195 HttpDownload* HttpSessionManager::httpDownload(bool aCreate) |
155 HttpDownload* HttpSessionManager::httpDownload(bool aCreate) |
196 { |
156 { |
197 if (!m_httpDownload && aCreate){ |
157 if (!m_httpDownload && aCreate){ |
198 TRAPD(err, m_httpDownload = HttpDownload::NewL(this)); |
158 m_httpDownload = new HttpDownload(this); |
199 if(err != KErrNone) |
|
200 { |
|
201 m_httpDownload = NULL; |
|
202 } |
|
203 } |
159 } |
204 return m_httpDownload; |
160 return m_httpDownload; |
205 } |
161 } |
206 |
162 |
207 void HttpSessionManager::closeHttpSession() |
163 void HttpSessionManager::closeHttpSession() |
210 this->handleError(KErrCancel); |
166 this->handleError(KErrCancel); |
211 |
167 |
212 // disconnect the Dl Mgr |
168 // disconnect the Dl Mgr |
213 if (m_httpDownload){ |
169 if (m_httpDownload){ |
214 m_httpDownload->disconnect(); |
170 m_httpDownload->disconnect(); |
215 if(m_cookieHandler) |
|
216 m_cookieHandler->destroy(); |
|
217 |
|
218 } |
171 } |
219 m_httpSession.Close(); |
172 m_httpSession.Close(); |
220 m_sessionRunning = false; |
173 m_sessionRunning = false; |
221 |
174 |
222 delete m_ReqHdrManager; |
175 delete m_ReqHdrManager; |
297 { |
250 { |
298 requests[i]->handleError(error); |
251 requests[i]->handleError(error); |
299 } |
252 } |
300 } |
253 } |
301 |
254 |
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 |
|
330 HttpConnection* HttpSessionManager::firstHttpConnection() |
255 HttpConnection* HttpSessionManager::firstHttpConnection() |
331 { |
256 { |
332 HashMap<HttpConnection *, ResourceHandle *>::const_iterator it = m_pendingHttpRequests.begin(); |
257 HashMap<HttpConnection *, ResourceHandle *>::const_iterator it = m_pendingHttpRequests.begin(); |
333 return it->first; |
258 return it->first; |
334 } |
259 } |
371 |
296 |
372 void HttpSessionManager::downloadL(ResourceHandle* handle, const ResourceRequest& request, |
297 void HttpSessionManager::downloadL(ResourceHandle* handle, const ResourceRequest& request, |
373 const ResourceResponse& response, HttpConnection* connection) |
298 const ResourceResponse& response, HttpConnection* connection) |
374 { |
299 { |
375 RHTTPTransaction* connTransaction = connection->takeOwnershipHttpTransaction(); |
300 RHTTPTransaction* connTransaction = connection->takeOwnershipHttpTransaction(); |
376 removeRequest(connection); |
|
377 WebFrame* webFrame = kit(connection->frame()); |
301 WebFrame* webFrame = kit(connection->frame()); |
378 if (!m_SelfDownloadContentHandler) { |
302 if (!m_SelfDownloadContentHandler) { |
379 m_SelfDownloadContentHandler = SelfDownloadContentHandler::NewL( |
303 m_SelfDownloadContentHandler = SelfDownloadContentHandler::NewL( |
380 webFrame, *m_SelfDownloadContentTypes); |
304 webFrame, *m_SelfDownloadContentTypes); |
381 } else { //m_SpecialLoadObserver in static object m_SelfDownloadContentHandler has to reinitialize |
305 } else { //m_SpecialLoadObserver in static object m_SelfDownloadContentHandler has to reinitialize |
383 } |
307 } |
384 if(m_SelfDownloadContentHandler->IsSupported(request, response, *connTransaction) |
308 if(m_SelfDownloadContentHandler->IsSupported(request, response, *connTransaction) |
385 != KErrNotSupported) { |
309 != KErrNotSupported) { |
386 if (m_OutstandingSelfDl) { |
310 if (m_OutstandingSelfDl) { |
387 // only one outstanding self download is supported |
311 // only one outstanding self download is supported |
388 connTransaction->Close(); |
|
389 User::Leave(KErrCancel); |
312 User::Leave(KErrCancel); |
390 } |
313 } |
391 else { |
314 else { |
392 m_OutstandingSelfDl = true; |
315 m_OutstandingSelfDl = true; |
393 m_SelfDownloadContentHandler->HandleResponseHeadersL(request, response, *connTransaction); |
316 m_SelfDownloadContentHandler->HandleResponseHeadersL(request, response, *connTransaction); |
531 } |
454 } |
532 CleanupStack::PopAndDestroy(); // url8 |
455 CleanupStack::PopAndDestroy(); // url8 |
533 } |
456 } |
534 } |
457 } |
535 |
458 |
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 |
|
575 // end of file |
459 // end of file |