equal
deleted
inserted
replaced
26 |
26 |
27 #include "HttpDownloadManagerServerEngine.h" |
27 #include "HttpDownloadManagerServerEngine.h" |
28 #include "HttpDownloadMgrLogger.h" |
28 #include "HttpDownloadMgrLogger.h" |
29 #include "HeaderField.h" |
29 #include "HeaderField.h" |
30 |
30 |
31 #include <sysutil.h> |
31 #include <SysUtil.h> |
32 #include <DocumentHandler.h> |
32 #include <DocumentHandler.h> |
33 #include <apmstd.h> |
33 #include <APMSTD.H> |
34 |
34 |
35 #include "HttpDownloadMgrLogger.h" |
35 #include "HttpDownloadMgrLogger.h" |
36 |
36 |
37 #ifdef __SYNCML_DM_FOTA |
37 #ifdef __SYNCML_DM_FOTA |
38 #include <fotaengine.h> |
38 #include <fotaengine.h> |
77 // |
77 // |
78 void CBuffStorage::ConstructL() |
78 void CBuffStorage::ConstructL() |
79 { |
79 { |
80 LOGGER_ENTERFN( "ConstructL" ); |
80 LOGGER_ENTERFN( "ConstructL" ); |
81 CActiveScheduler::Add( this ); |
81 CActiveScheduler::Add( this ); |
|
82 iWait = new (ELeave) CActiveSchedulerWait; |
82 } |
83 } |
83 |
84 |
84 // ----------------------------------------------------------------------------- |
85 // ----------------------------------------------------------------------------- |
85 // CBuffStorage::NewL |
86 // CBuffStorage::NewL |
86 // Two-phased constructor. |
87 // Two-phased constructor. |
106 Cancel(); |
107 Cancel(); |
107 |
108 |
108 ResetBuffers(); |
109 ResetBuffers(); |
109 |
110 |
110 delete iWritePtr; iWritePtr = 0; |
111 delete iWritePtr; iWritePtr = 0; |
|
112 if(iWait) |
|
113 { |
|
114 delete iWait; |
|
115 iWait = NULL; |
|
116 } |
111 } |
117 } |
112 |
118 |
113 |
119 |
114 |
120 |
115 // --------------------------------------------------------- |
121 // --------------------------------------------------------- |
132 else |
138 else |
133 { |
139 { |
134 CLOG_WRITE_2( "(%08X) CBuffStorage::RunL DH-iStat: %d, ", this, iStatus.Int() ); |
140 CLOG_WRITE_2( "(%08X) CBuffStorage::RunL DH-iStat: %d, ", this, iStatus.Int() ); |
135 } |
141 } |
136 |
142 |
137 if(iWait.IsStarted()) |
143 if(iWait && iWait->IsStarted()) |
138 { |
144 { |
139 CLOG_WRITE_1 ( "(%08X) CBuffStorage::RunL() Stopping iWait", this ); |
145 CLOG_WRITE_1 ( "(%08X) CBuffStorage::RunL() Stopping iWait", this ); |
140 iWait.AsyncStop(); |
146 iWait->AsyncStop(); |
141 } |
147 } |
142 } |
148 } |
143 |
149 |
144 void CBuffStorage::DoCancel() |
150 void CBuffStorage::DoCancel() |
145 { |
151 { |
155 // |
161 // |
156 void CBuffStorage::ResetBuffers() |
162 void CBuffStorage::ResetBuffers() |
157 { |
163 { |
158 CLOG_WRITE_1("(%08X) CBuffStorage::ResetBuffers >>", this); |
164 CLOG_WRITE_1("(%08X) CBuffStorage::ResetBuffers >>", this); |
159 |
165 |
160 if(IsActive()) |
166 if(IsActive()&& iWait && !iWait->IsStarted()) |
161 { |
167 { |
162 // Make sure async writes are finished |
168 // Make sure async writes are finished |
163 iWait.Start(); |
169 iWait->Start(); |
164 } |
170 } |
165 |
171 |
166 // Cleanup |
172 // Cleanup |
167 delete iBuff1; iBuff1 = NULL; |
173 delete iBuff1; iBuff1 = NULL; |
168 delete iBuff2; iBuff2 = NULL; |
174 delete iBuff2; iBuff2 = NULL; |
223 } |
229 } |
224 |
230 |
225 CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL >>", this); |
231 CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL >>", this); |
226 |
232 |
227 // Make sure async writes are finished before doing anything |
233 // Make sure async writes are finished before doing anything |
228 if(IsActive()) |
234 if(IsActive() && iWait && !iWait->IsStarted()) |
229 { |
235 { |
230 CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling >>", this); |
236 CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling >>", this); |
231 iWait.Start(); |
237 iWait->Start(); |
232 CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling <<", this); |
238 CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling <<", this); |
233 } |
239 } |
234 |
240 |
235 if(iLastWriteErrorCode != KErrNone) |
241 if(iLastWriteErrorCode != KErrNone) |
236 { |
242 { |
333 |
339 |
334 // Now we have a full client buffer, better do something with it |
340 // Now we have a full client buffer, better do something with it |
335 |
341 |
336 // Check if previous async write is still ongoing |
342 // Check if previous async write is still ongoing |
337 // Done here so if somebody switched on progressive download midway through we don't mix buffers |
343 // Done here so if somebody switched on progressive download midway through we don't mix buffers |
338 if(IsActive()) |
344 if(IsActive()&& iWait && !iWait->IsStarted()) |
339 { |
345 { |
340 CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling >>", this); |
346 CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling >>", this); |
341 iWait.Start(); |
347 iWait->Start(); |
342 CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling <<", this); |
348 CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling <<", this); |
343 } |
349 } |
344 |
350 |
345 // In case of async writes we have to check if there was error previously |
351 // In case of async writes we have to check if there was error previously |
346 if(iLastWriteErrorCode != KErrNone) |
352 if(iLastWriteErrorCode != KErrNone) |
413 // |
419 // |
414 void CBuffStorage::DoNonbufferingWriteL(const TDesC8& aBuf) |
420 void CBuffStorage::DoNonbufferingWriteL(const TDesC8& aBuf) |
415 { |
421 { |
416 CLOG_WRITE_2("(%08X) CBuffStorage::DoNonbufferingWriteL: %d bytes", this, aBuf.Length()); |
422 CLOG_WRITE_2("(%08X) CBuffStorage::DoNonbufferingWriteL: %d bytes", this, aBuf.Length()); |
417 |
423 |
418 if(IsActive()) |
424 if(IsActive() && iWait && !iWait->IsStarted()) |
419 { |
425 { |
420 CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling >>", this); |
426 CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling >>", this); |
421 iWait.Start(); |
427 iWait->Start(); |
422 CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling <<", this); |
428 CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling <<", this); |
423 } |
429 } |
424 |
430 |
425 TInt len = aBuf.Length(); |
431 TInt len = aBuf.Length(); |
426 if(len) |
432 if(len) |