equal
deleted
inserted
replaced
66 void CHttpRequestBatcher::SendRequestImmediatelyL(const TDesC8& aBuffer) |
66 void CHttpRequestBatcher::SendRequestImmediatelyL(const TDesC8& aBuffer) |
67 { |
67 { |
68 #if defined (_DEBUG) && defined (_LOGGING) |
68 #if defined (_DEBUG) && defined (_LOGGING) |
69 __FLOG_0(_T8("!! Send the first request i.e. not batching")); |
69 __FLOG_0(_T8("!! Send the first request i.e. not batching")); |
70 #endif |
70 #endif |
71 |
71 |
|
72 // This function will be called when the request is sent first time on a newly |
|
73 // opened connection. So no need to mark it as sending... |
72 iOutputStream->SendDataReqL(aBuffer); |
74 iOutputStream->SendDataReqL(aBuffer); |
73 } |
75 } |
74 |
76 |
75 void CHttpRequestBatcher::SendRequestsBatchedL(const TDesC8& aBuffer) |
77 void CHttpRequestBatcher::SendRequestsBatchedL(const TDesC8& aBuffer) |
76 { |
78 { |
|
79 if(iSendingRequest) |
|
80 { |
|
81 // The batcher is not having enough data [batching buffer size] size |
|
82 // available. It would have been requested the supplier to provide more data. |
|
83 // By the time the timer would have been expired and the batcher would have been sent the data. |
|
84 // Before the notificaiton of the confirmation of data is sent the supplier can give more data |
|
85 // to the batcher which will make the batcher to send the data again and double RSocket :: Send |
|
86 // will cause the panic.. At this point the excess data will be empty |
|
87 iExcessData.Set(aBuffer); |
|
88 return; // Dont send the data here. Send once the confirmation of previous send has received |
|
89 } |
77 StartTimer(); |
90 StartTimer(); |
78 |
91 |
79 BatchRequestsL(aBuffer); |
92 BatchRequestsL(aBuffer); |
80 } |
93 } |
81 |
94 |
104 #if defined (_DEBUG) && defined (_LOGGING) |
117 #if defined (_DEBUG) && defined (_LOGGING) |
105 __FLOG_0(_T8("!! Buffer has been filled - cancel timer and send batched requests now")); |
118 __FLOG_0(_T8("!! Buffer has been filled - cancel timer and send batched requests now")); |
106 #endif |
119 #endif |
107 |
120 |
108 // Send the request with a filled-up buffer |
121 // Send the request with a filled-up buffer |
|
122 iSendingRequest = ETrue; |
109 iOutputStream->SendDataReqL(iDataToSend); |
123 iOutputStream->SendDataReqL(iDataToSend); |
110 |
124 |
111 // Save the excess data from this request |
125 // Save the excess data from this request |
112 iExcessData.Set(aBuffer.Mid(pos)); |
126 iExcessData.Set(aBuffer.Mid(pos)); |
113 } |
127 } |
186 * Methods from MOutputStreamObserver |
200 * Methods from MOutputStreamObserver |
187 */ |
201 */ |
188 |
202 |
189 void CHttpRequestBatcher::SendDataCnfL() |
203 void CHttpRequestBatcher::SendDataCnfL() |
190 { |
204 { |
|
205 iSendingRequest = EFalse; // Confirmation of data send has received. reset the flag |
191 // If this is the first request send a confirmation to the observer that the data |
206 // If this is the first request send a confirmation to the observer that the data |
192 // has been sent and then set the function pointer to the SendRequestBatched() method. |
207 // has been sent and then set the function pointer to the SendRequestBatched() method. |
193 if (iFuncPtr == &CHttpRequestBatcher::SendRequestImmediatelyL) |
208 if (iFuncPtr == &CHttpRequestBatcher::SendRequestImmediatelyL) |
194 { |
209 { |
195 #if defined (_DEBUG) && defined (_LOGGING) |
210 #if defined (_DEBUG) && defined (_LOGGING) |
233 #endif |
248 #endif |
234 |
249 |
235 // It's possible that the excess data is larger than the maximum allowable size of the buffer in |
250 // It's possible that the excess data is larger than the maximum allowable size of the buffer in |
236 // which case this excess data is used to fill up another buffer and a request made. |
251 // which case this excess data is used to fill up another buffer and a request made. |
237 iDataToSend.Append(iExcessData.Left(iMaxBufferSize)); |
252 iDataToSend.Append(iExcessData.Left(iMaxBufferSize)); |
|
253 iSendingRequest = ETrue; |
238 iOutputStream->SendDataReqL(iDataToSend); |
254 iOutputStream->SendDataReqL(iDataToSend); |
239 iExcessData.Set(iExcessData.Mid(iMaxBufferSize)); |
255 iExcessData.Set(iExcessData.Mid(iMaxBufferSize)); |
240 } |
256 } |
241 else |
257 else |
242 { |
258 { |
288 #if defined (_DEBUG) && defined (_LOGGING) |
304 #if defined (_DEBUG) && defined (_LOGGING) |
289 __FLOG_0(_T8("!! Timer has completed before buffer has been filled - send request now")); |
305 __FLOG_0(_T8("!! Timer has completed before buffer has been filled - send request now")); |
290 #endif |
306 #endif |
291 |
307 |
292 // Timer has completed before the buffer has been filled, therefore send the request now. |
308 // Timer has completed before the buffer has been filled, therefore send the request now. |
|
309 iSendingRequest = ETrue; |
293 iOutputStream->SendDataReqL(iDataToSend); |
310 iOutputStream->SendDataReqL(iDataToSend); |
294 } |
311 } |
295 iTimerCompleted = ETrue; |
312 iTimerCompleted = ETrue; |
296 } |
313 } |
297 |
314 |